changeset 14361:4b901a05d4ee

Merge
author prr
date Mon, 12 Oct 2015 14:41:36 -0700
parents bdc017c292af 640d543aea86
children daf3f9e17405
files src/java.base/share/classes/sun/misc/ConditionLock.java src/java.base/share/classes/sun/misc/IOUtils.java src/java.base/share/classes/sun/misc/Lock.java
diffstat 52 files changed, 5091 insertions(+), 467 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Oct 12 16:26:58 2015 +0300
+++ b/.hgtags	Mon Oct 12 14:41:36 2015 -0700
@@ -327,3 +327,4 @@
 b10b64263b563e21f055c881444f625ec618b826 jdk9-b82
 d11f25ce3c545823f53bb978d454a4d2901abac3 jdk9-b83
 757ef7f6d0042934edea3e0bf616fad2c1a22789 jdk9-b84
+fe40b31c0e526d357cf5b62044fea006e43b53a5 jdk9-b85
--- a/make/src/classes/build/tools/module/ModuleArchive.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/make/src/classes/build/tools/module/ModuleArchive.java	Mon Oct 12 14:41:36 2015 -0700
@@ -105,6 +105,7 @@
                     entries.addAll(stream
                             .filter(p -> !Files.isDirectory(p)
                                     && !classes.relativize(p).toString().startsWith("_the.")
+                                    && !classes.relativize(p).toString().endsWith(".bc")
                                     && !classes.relativize(p).toString().equals("javac_state"))
                             .sorted()
                             .map(p -> toEntry(p, classes, EntryType.CLASS_OR_RESOURCE))
--- a/src/java.base/share/classes/java/lang/ArrayIndexOutOfBoundsException.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/java/lang/ArrayIndexOutOfBoundsException.java	Mon Oct 12 14:41:36 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -26,42 +26,58 @@
 package java.lang;
 
 /**
- * Thrown to indicate that an array has been accessed with an
- * illegal index. The index is either negative or greater than or
- * equal to the size of the array.
+ * Thrown to indicate that an array has been accessed with an illegal index. The
+ * index is either negative or greater than or equal to the size of the array.
  *
- * @author  unascribed
- * @since   1.0
+ * @since 1.0
  */
-public
-class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException {
+public class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException {
     private static final long serialVersionUID = -5116101128118950844L;
 
     /**
-     * Constructs an <code>ArrayIndexOutOfBoundsException</code> with no
-     * detail message.
+     * Constructs an {@code ArrayIndexOutOfBoundsException} with no detail
+     * message.
      */
     public ArrayIndexOutOfBoundsException() {
         super();
     }
 
     /**
-     * Constructs a new <code>ArrayIndexOutOfBoundsException</code>
-     * class with an argument indicating the illegal index.
+     * Constructs an {@code ArrayIndexOutOfBoundsException} class with the
+     * specified detail message.
      *
-     * @param   index   the illegal index.
+     * @param s the detail message.
+     */
+    public ArrayIndexOutOfBoundsException(String s) {
+        super(s);
+    }
+
+    /**
+     * Constructs a new {@code ArrayIndexOutOfBoundsException} class with an
+     * argument indicating the illegal index.
+     *
+     * <p>The index is included in this exception's detail message.  The
+     * exact presentation format of the detail message is unspecified.
+     *
+     * @param index the illegal index.
      */
     public ArrayIndexOutOfBoundsException(int index) {
         super("Array index out of range: " + index);
     }
 
     /**
-     * Constructs an <code>ArrayIndexOutOfBoundsException</code> class
-     * with the specified detail message.
+     * Constructs a new {@code ArrayIndexOutOfBoundsException} class with
+     * arguments indicating two out of bound values.
      *
-     * @param   s   the detail message.
+     * <p>The out of bound values are included in this exception's detail
+     * message.  The exact presentation format of the detail message is
+     * unspecified.
+     *
+     * @param a the first out of bound value.
+     * @param b the second out of bound value.
+     * @since 9
      */
-    public ArrayIndexOutOfBoundsException(String s) {
-        super(s);
+    public ArrayIndexOutOfBoundsException(int a, int b) {
+        super("Array indexed access out of bounds: " + a + ", " + b);
     }
 }
--- a/src/java.base/share/classes/java/lang/FdLibm.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/java/lang/FdLibm.java	Mon Oct 12 14:41:36 2015 -0700
@@ -182,7 +182,7 @@
             }
 
             int k = 0;
-            if (a > 0x1.0p500) {   // a > 2**500
+            if (a > 0x1.00000_ffff_ffffp500) {   // a > ~2**500
                 // scale a and b by 2**-600
                 ha -= 0x25800000;
                 hb -= 0x25800000;
--- a/src/java.base/share/classes/java/lang/IndexOutOfBoundsException.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/java/lang/IndexOutOfBoundsException.java	Mon Oct 12 14:41:36 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2008, 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
@@ -31,28 +31,57 @@
  * <p>
  * Applications can subclass this class to indicate similar exceptions.
  *
- * @author  Frank Yellin
- * @since   1.0
+ * @author Frank Yellin
+ * @since 1.0
  */
-public
-class IndexOutOfBoundsException extends RuntimeException {
+public class IndexOutOfBoundsException extends RuntimeException {
     private static final long serialVersionUID = 234122996006267687L;
 
     /**
-     * Constructs an <code>IndexOutOfBoundsException</code> with no
-     * detail message.
+     * Constructs an {@code IndexOutOfBoundsException} with no detail message.
      */
     public IndexOutOfBoundsException() {
         super();
     }
 
     /**
-     * Constructs an <code>IndexOutOfBoundsException</code> with the
-     * specified detail message.
+     * Constructs an {@code IndexOutOfBoundsException} with the specified detail
+     * message.
      *
-     * @param   s   the detail message.
+     * @param s the detail message
      */
     public IndexOutOfBoundsException(String s) {
         super(s);
     }
+
+    /**
+     * Constructs a new {@code IndexOutOfBoundsException} class with an
+     * argument indicating the illegal index.
+     *
+     * <p>The index is included in this exception's detail message.  The
+     * exact presentation format of the detail message is unspecified.
+     *
+     * @param index the illegal index.
+     * @since 9
+     */
+    public IndexOutOfBoundsException(int index) {
+        super("Index out of range: " + index);
+    }
+
+    /**
+     * Constructs an {@code IndexOutOfBoundsException} with arguments indicating
+     * two out of bound values.
+     *
+     * <p>The out of bound values are included in this exception's detail
+     * message.  The exact presentation format of the detail message is
+     * unspecified.
+     *
+     * @param a the first out of bound value
+     * @param b the second out of bound value
+     * @since 9
+     */
+    public IndexOutOfBoundsException(int a, int b) {
+        super("Indexed access out of bounds: " + a + ", " + b);
+    }
+
 }
--- a/src/java.base/share/classes/java/lang/StringIndexOutOfBoundsException.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/java/lang/StringIndexOutOfBoundsException.java	Mon Oct 12 14:41:36 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -26,44 +26,61 @@
 package java.lang;
 
 /**
- * Thrown by {@code String} methods to indicate that an index
- * is either negative or greater than the size of the string.  For
- * some methods such as the charAt method, this exception also is
- * thrown when the index is equal to the size of the string.
+ * Thrown by {@code String} methods to indicate that an index is either negative
+ * or greater than the size of the string.  For some methods such as the
+ * {@link String#charAt charAt} method, this exception also is thrown when the
+ * index is equal to the size of the string.
  *
- * @author  unascribed
- * @see     java.lang.String#charAt(int)
- * @since   1.0
+ * @see java.lang.String#charAt(int)
+ * @since 1.0
  */
-public
-class StringIndexOutOfBoundsException extends IndexOutOfBoundsException {
+public class StringIndexOutOfBoundsException extends IndexOutOfBoundsException {
     private static final long serialVersionUID = -6762910422159637258L;
 
     /**
-     * Constructs a {@code StringIndexOutOfBoundsException} with no
-     * detail message.
+     * Constructs a {@code StringIndexOutOfBoundsException} with no detail
+     * message.
      */
     public StringIndexOutOfBoundsException() {
         super();
     }
 
     /**
-     * Constructs a {@code StringIndexOutOfBoundsException} with
-     * the specified detail message.
+     * Constructs a {@code StringIndexOutOfBoundsException} with the specified
+     * detail message.
      *
-     * @param   s   the detail message.
+     * @param s the detail message.
      */
     public StringIndexOutOfBoundsException(String s) {
         super(s);
     }
 
     /**
-     * Constructs a new {@code StringIndexOutOfBoundsException}
-     * class with an argument indicating the illegal index.
+     * Constructs a new {@code StringIndexOutOfBoundsException} class with an
+     * argument indicating the illegal index.
      *
-     * @param   index   the illegal index.
+     * <p>The index is included in this exception's detail message.  The
+     * exact presentation format of the detail message is unspecified.
+     *
+     * @param index the illegal index.
      */
     public StringIndexOutOfBoundsException(int index) {
         super("String index out of range: " + index);
     }
+
+    /**
+     * Constructs a new {@code StringIndexOutOfBoundsException} class with
+     * arguments indicating two out of bound values.
+     *
+     * <p>The out of bound values are included in this exception's detail
+     * message.  The exact presentation format of the detail message is
+     * unspecified.
+     *
+     * @param a the first out of bound value.
+     * @param b the second out of bound value.
+     * @since 9
+     */
+    public StringIndexOutOfBoundsException(int a, int b) {
+        super("String indexed access out of bounds: " + a + ", " + b);
+    }
 }
--- a/src/java.base/share/classes/java/net/URLStreamHandlerFactory.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/java/net/URLStreamHandlerFactory.java	Mon Oct 12 14:41:36 2015 -0700
@@ -28,9 +28,9 @@
 /**
  * This interface defines a factory for {@code URL} stream
  * protocol handlers.
- * <p>
- * It is used by the {@code URL} class to create a
- * {@code URLStreamHandler} for a specific protocol.
+ *
+ * <p> A URL stream handler factory is used as specified in the
+ * {@linkplain java.net.URL#URL(String,String,int,String) URL constructor}.
  *
  * @author  Arthur van Hoff
  * @see     java.net.URL
--- a/src/java.base/share/classes/java/net/spi/URLStreamHandlerProvider.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/java/net/spi/URLStreamHandlerProvider.java	Mon Oct 12 14:41:36 2015 -0700
@@ -41,6 +41,9 @@
  * fully-qualified concrete URL stream handler provider class names, one per
  * line.
  *
+ * <p> URL stream handler providers are located at runtime, as specified in the
+ * {@linkplain java.net.URL#URL(String,String,int,String) URL constructor}.
+ *
  * @since 1.9
  */
 public abstract class URLStreamHandlerProvider
--- a/src/java.base/share/classes/java/security/AuthProvider.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/java/security/AuthProvider.java	Mon Oct 12 14:41:36 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, 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
@@ -79,8 +79,10 @@
      *          this provider to obtain authentication information
      *          from the caller, which may be {@code null}
      *
-     * @exception LoginException if the login operation fails
-     * @exception SecurityException if the caller does not pass a
+     * @throws IllegalStateException if the provider requires configuration
+     * and {@link configure} has not been called
+     * @throws LoginException if the login operation fails
+     * @throws SecurityException if the caller does not pass a
      *  security check for
      *  {@code SecurityPermission("authProvider.name")},
      *  where {@code name} is the value returned by
@@ -92,8 +94,10 @@
     /**
      * Log out from this provider.
      *
-     * @exception LoginException if the logout operation fails
-     * @exception SecurityException if the caller does not pass a
+     * @throws IllegalStateException if the provider requires configuration
+     * and {@link configure} has not been called
+     * @throws LoginException if the logout operation fails
+     * @throws SecurityException if the caller does not pass a
      *  security check for
      *  {@code SecurityPermission("authProvider.name")},
      *  where {@code name} is the value returned by
@@ -118,7 +122,9 @@
      * @param handler a {@code CallbackHandler} for obtaining
      *          authentication information, which may be {@code null}
      *
-     * @exception SecurityException if the caller does not pass a
+     * @throws IllegalStateException if the provider requires configuration
+     * and {@link configure} has not been called
+     * @throws SecurityException if the caller does not pass a
      *  security check for
      *  {@code SecurityPermission("authProvider.name")},
      *  where {@code name} is the value returned by
--- a/src/java.base/share/classes/java/security/Provider.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/java/security/Provider.java	Mon Oct 12 14:41:36 2015 -0700
@@ -187,13 +187,30 @@
      *         is invalid.
      * @return a provider configured with the supplied configuration argument.
      *
-     * @since 1.9
+     * @since 9
      */
     public Provider configure(String configArg) {
         throw new UnsupportedOperationException("configure is not supported");
     }
 
     /**
+     * Check if this provider instance has been configured.
+     *
+     * @implSpec
+     * The default implementation returns true.
+     * Subclasses should override this method if the provider instance requires
+     * an explicit {@code configure} call after being constructed.
+     *
+     * @return true if no further configuration is needed, false otherwise.
+     *
+     * @since 9
+     */
+    public boolean isConfigured() {
+        return true;
+    }
+
+
+    /**
      * Returns the name of this provider.
      *
      * @return the name of this provider.
--- a/src/java.base/share/classes/java/security/SecurityPermission.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/java/security/SecurityPermission.java	Mon Oct 12 14:41:36 2015 -0700
@@ -53,6 +53,17 @@
  * </tr>
  *
  * <tr>
+ *   <td>authProvider.{provider name}</td>
+ *   <td>Allow the named provider to be an AuthProvider for login and
+ * logout operations. </td>
+ *   <td>This allows the named provider to perform login and logout
+ * operations. The named provider must extend {@code AuthProvider}
+ * and care must be taken to grant to a trusted provider since
+ * login operations involve sensitive authentication information
+ * such as PINs and passwords. </td>
+ * </tr>
+ *
+ * <tr>
  *   <td>createAccessControlContext</td>
  *   <td>Creation of an AccessControlContext</td>
  *   <td>This allows someone to instantiate an AccessControlContext
--- a/src/java.base/share/classes/java/util/Currency.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/java/util/Currency.java	Mon Oct 12 14:41:36 2015 -0700
@@ -371,8 +371,8 @@
      * instance is needed
      * @return the <code>Currency</code> instance for the country of the given
      * locale, or {@code null}
-     * @exception NullPointerException if <code>locale</code> or its country
-     * code is {@code null}
+     * @exception NullPointerException if <code>locale</code>
+     * is {@code null}
      * @exception IllegalArgumentException if the country of the given {@code locale}
      * is not a supported ISO 3166 country code.
      */
--- a/src/java.base/share/classes/java/util/Objects.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/java/util/Objects.java	Mon Oct 12 14:41:36 2015 -0700
@@ -25,13 +25,29 @@
 
 package java.util;
 
+import java.util.function.BiFunction;
 import java.util.function.Supplier;
 
 /**
  * This class consists of {@code static} utility methods for operating
- * on objects.  These utilities include {@code null}-safe or {@code
- * null}-tolerant methods for computing the hash code of an object,
- * returning a string for an object, and comparing two objects.
+ * on objects, or checking certain conditions before operation.  These utilities
+ * include {@code null}-safe or {@code null}-tolerant methods for computing the
+ * hash code of an object, returning a string for an object, comparing two
+ * objects, and checking if indexes or sub-range values are out of bounds.
+ *
+ * @apiNote
+ * Static methods such as {@link Objects#checkIndex},
+ * {@link Objects#checkFromToIndex}, and {@link Objects#checkFromIndexSize} are
+ * provided for the convenience of checking if values corresponding to indexes
+ * and sub-ranges are out of bounds.
+ * Variations of these static methods support customization of the runtime
+ * exception, and corresponding exception detail message, that is thrown when
+ * values are out of bounds.  Such methods accept a functional interface
+ * argument, instances of {@code BiFunction}, that maps out of bound values to a
+ * runtime exception.  Care should be taken when using such methods in
+ * combination with an argument that is a lambda expression, method reference or
+ * class that capture values.  In such cases the cost of capture, related to
+ * functional interface allocation, may exceed the cost of checking bounds.
  *
  * @since 1.7
  */
@@ -290,4 +306,230 @@
             throw new NullPointerException(messageSupplier.get());
         return obj;
     }
+
+    /**
+     * Maps out of bounds values to a runtime exception.
+     *
+     * @param a the first out of bound value
+     * @param b the second out of bound value
+     * @param oobe the exception mapping function that when applied with out of
+     *        bounds arguments returns a runtime exception.  If {@code null}
+     *        then, it's as if an exception mapping function was supplied that
+     *        returns {@link IndexOutOfBoundsException} for any given arguments.
+     * @return the runtime exception
+     */
+    private static RuntimeException outOfBounds(
+            int a, int b, BiFunction<Integer, Integer, ? extends RuntimeException> oobe) {
+        return oobe == null
+               ? new IndexOutOfBoundsException(a, b)
+               : oobe.apply(a, b);
+    }
+
+    /**
+     * Checks if the {@code index} is within the bounds of the range from
+     * {@code 0} (inclusive) to {@code length} (exclusive).
+     *
+     * <p>The {@code index} is defined to be out of bounds if any of the
+     * following inequalities is true:
+     * <ul>
+     *  <li>{@code index < 0}</li>
+     *  <li>{@code index >= length}</li>
+     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
+     * </ul>
+     *
+     * @param index the index
+     * @param length the upper-bound (exclusive) of the range
+     * @return {@code index} if it is within bounds of the range
+     * @throws IndexOutOfBoundsException if the {@code index} is out of bounds
+     * @since 9
+     */
+    public static
+    int checkIndex(int index, int length) throws IndexOutOfBoundsException {
+        return checkIndex(index, length, null);
+    }
+
+    /**
+     * Checks if the {@code index} is within the bounds of the range from
+     * {@code 0} (inclusive) to {@code length} (exclusive).
+     *
+     * <p>The {@code index} is defined to be out of bounds if any of the
+     * following inequalities is true:
+     * <ul>
+     *  <li>{@code index < 0}</li>
+     *  <li>{@code index >= length}</li>
+     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
+     * </ul>
+     *
+     * <p>If the {@code index} is out of bounds, then a runtime exception is
+     * thrown that is the result of applying the arguments {@code index} and
+     * {@code length} to the given exception mapping function.
+     *
+     * @param <T> the type of runtime exception to throw if the arguments are
+     *        out of bounds
+     * @param index the index
+     * @param length the upper-bound (exclusive) of the range
+     * @param oobe the exception mapping function that when applied with out
+     *        of bounds arguments returns a runtime exception.  If {@code null}
+     *        then, it's as if an exception mapping function was supplied that
+     *        returns {@link IndexOutOfBoundsException} for any given arguments.
+     * @return {@code index} if it is within bounds of the range
+     * @throws T if the {@code index} is out of bounds, then a runtime exception
+     *         is thrown that is the result of applying the out of bounds
+     *         arguments to the exception mapping function.
+     * @throws IndexOutOfBoundsException if the {@code index} is out of bounds
+     *         and the exception mapping function is {@code null}
+     * @since 9
+     */
+    /*
+    @HotSpotIntrinsicCandidate
+    This method will be made intrinsic in C2 to guide HotSpot to perform
+    unsigned comparisons of the index and length when it is known the length is
+    a non-negative value (such as that of an array length or from the upper
+    bound of a loop)
+    */
+    public static <T extends RuntimeException>
+    int checkIndex(int index, int length,
+                   BiFunction<Integer, Integer, T> oobe) throws T, IndexOutOfBoundsException {
+        if (index < 0 || index >= length)
+            throw outOfBounds(index, length, oobe);
+        return index;
+    }
+
+    /**
+     * Checks if the sub-range from {@code fromIndex} (inclusive) to
+     * {@code toIndex} (exclusive) is within the bounds of range from {@code 0}
+     * (inclusive) to {@code length} (exclusive).
+     *
+     * <p>The sub-range is defined to be out of bounds if any of the following
+     * inequalities is true:
+     * <ul>
+     *  <li>{@code fromIndex < 0}</li>
+     *  <li>{@code fromIndex > toIndex}</li>
+     *  <li>{@code toIndex > length}</li>
+     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
+     * </ul>
+     *
+     * @param fromIndex the lower-bound (inclusive) of the sub-range
+     * @param toIndex the upper-bound (exclusive) of the sub-range
+     * @param length the upper-bound (exclusive) the range
+     * @return {@code fromIndex} if the sub-range within bounds of the range
+     * @throws IndexOutOfBoundsException if the sub-range is out of bounds
+     * @since 9
+     */
+    public static
+    int checkFromToIndex(int fromIndex, int toIndex, int length) throws IndexOutOfBoundsException {
+        return checkFromToIndex(fromIndex, toIndex, length, null);
+    }
+
+    /**
+     * Checks if the sub-range from {@code fromIndex} (inclusive) to
+     * {@code toIndex} (exclusive) is within the bounds of range from {@code 0}
+     * (inclusive) to {@code length} (exclusive).
+     *
+     * <p>The sub-range is defined to be out of bounds if any of the following
+     * inequalities is true:
+     * <ul>
+     *  <li>{@code fromIndex < 0}</li>
+     *  <li>{@code fromIndex > toIndex}</li>
+     *  <li>{@code toIndex > length}</li>
+     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
+     * </ul>
+     *
+     * <p>If the sub-range is out of bounds, then a runtime exception is thrown
+     * that is the result of applying the arguments {@code fromIndex} and
+     * {@code toIndex} to the given exception mapping function.
+     *
+     * @param <T> the type of runtime exception to throw if the arguments are
+     *        out of bounds
+     * @param fromIndex the lower-bound (inclusive) of the sub-range
+     * @param toIndex the upper-bound (exclusive) of the sub-range
+     * @param length the upper-bound (exclusive) the range
+     * @param oobe the exception mapping function that when applied with out
+     *        of bounds arguments returns a runtime exception.  If {@code null}
+     *        then, it's as if an exception mapping function was supplied that
+     *        returns {@link IndexOutOfBoundsException} for any given arguments.
+     * @return {@code fromIndex} if the sub-range within bounds of the range
+     * @throws T if the sub-range is out of bounds, then a runtime exception is
+     *         thrown that is the result of applying the out of bounds arguments
+     *         to the exception mapping function.
+     * @throws IndexOutOfBoundsException if the sub-range is out of bounds and
+     *         the exception mapping function is {@code null}
+     * @since 9
+     */
+    public static <T extends RuntimeException>
+    int checkFromToIndex(int fromIndex, int toIndex, int length,
+                         BiFunction<Integer, Integer, T> oobe) throws T, IndexOutOfBoundsException {
+        if (fromIndex < 0 || fromIndex > toIndex || toIndex > length)
+            throw outOfBounds(fromIndex, toIndex, oobe);
+        return fromIndex;
+    }
+
+    /**
+     * Checks if the sub-range from {@code fromIndex} (inclusive) to
+     * {@code fromIndex + size} (exclusive) is within the bounds of range from
+     * {@code 0} (inclusive) to {@code length} (exclusive).
+     *
+     * <p>The sub-range is defined to be out of bounds if any of the following
+     * inequalities is true:
+     * <ul>
+     *  <li>{@code fromIndex < 0}</li>
+     *  <li>{@code size < 0}</li>
+     *  <li>{@code fromIndex + size > length}, taking into account integer overflow</li>
+     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
+     * </ul>
+     *
+     * @param fromIndex the lower-bound (inclusive) of the sub-interval
+     * @param size the size of the sub-range
+     * @param length the upper-bound (exclusive) of the range
+     * @return {@code fromIndex} if the sub-range within bounds of the range
+     * @throws IndexOutOfBoundsException if the sub-range is out of bounds
+     * @since 9
+     */
+    public static
+    int checkFromIndexSize(int fromIndex, int size, int length) throws IndexOutOfBoundsException {
+        return checkFromIndexSize(fromIndex, size, length, null);
+    }
+
+    /**
+     * Checks if the sub-range from {@code fromIndex} (inclusive) to
+     * {@code fromIndex + size} (exclusive) is within the bounds of range from
+     * {@code 0} (inclusive) to {@code length} (exclusive).
+     *
+     * <p>The sub-range is defined to be out of bounds if any of the following
+     * inequalities is true:
+     * <ul>
+     *  <li>{@code fromIndex < 0}</li>
+     *  <li>{@code size < 0}</li>
+     *  <li>{@code fromIndex + size > length}, taking into account integer overflow</li>
+     *  <li>{@code length < 0}, which is implied from the former inequalities</li>
+     * </ul>
+     *
+     * <p>If the sub-range is out of bounds then, a runtime exception is thrown
+     * that is the result of applying the arguments {@code fromIndex} and
+     * {@code size} to the given exception mapping function.
+     *
+     * @param <T> the type of runtime exception to throw if the arguments are
+     *        out of bounds
+     * @param fromIndex the lower-bound (inclusive) of the sub-interval
+     * @param size the size of the sub-range
+     * @param length the upper-bound (exclusive) of the range
+     * @param oobe the exception mapping function that when applied with out
+     *        of bounds arguments returns a runtime exception.  If {@code null}
+     *        then, it's as if an exception mapping function was supplied that
+     *        returns {@link IndexOutOfBoundsException} for any given arguments.
+     * @return {@code fromIndex} if the sub-range within bounds of the range
+     * @throws T if the sub-range is out of bounds, then a runtime exception is
+     *         thrown that is the result of applying the out of bounds arguments
+     *         to the exception mapping function.
+     * @throws IndexOutOfBoundsException if the sub-range is out of bounds and
+     *         the exception mapping function is {@code null}
+     * @since 9
+     */
+    public static <T extends RuntimeException>
+    int checkFromIndexSize(int fromIndex, int size, int length,
+                           BiFunction<Integer, Integer, T> oobe) throws T, IndexOutOfBoundsException {
+        if ((length | fromIndex | size) < 0 || size > length - fromIndex)
+            throw outOfBounds(fromIndex, size, oobe);
+        return fromIndex;
+    }
 }
--- a/src/java.base/share/classes/java/util/jar/JarFile.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/java/util/jar/JarFile.java	Mon Oct 12 14:41:36 2015 -0700
@@ -37,7 +37,6 @@
 import java.security.AccessController;
 import java.security.CodeSource;
 import jdk.internal.misc.SharedSecrets;
-import sun.misc.IOUtils;
 import sun.security.action.GetPropertyAction;
 import sun.security.util.ManifestEntryVerifier;
 import sun.security.util.SignatureFileVerifier;
@@ -438,7 +437,12 @@
      */
     private byte[] getBytes(ZipEntry ze) throws IOException {
         try (InputStream is = super.getInputStream(ze)) {
-            return IOUtils.readFully(is, (int)ze.getSize(), true);
+            int len = (int)ze.getSize();
+            byte[] b = is.readAllBytes();
+            if (len != -1 && b.length != len)
+                throw new EOFException("Expected:" + len + ", read:" + b.length);
+
+            return b;
         }
     }
 
--- a/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java	Mon Oct 12 14:41:36 2015 -0700
@@ -58,7 +58,7 @@
 
         try {
             substrate = ImageNativeSubstrate.openImage(imagePath, byteOrder);
-        } catch (UnsatisfiedLinkError ex) {
+        } catch (UnsatisfiedLinkError | NoClassDefFoundError ex) {
             substrate = ImageJavaSubstrate.openImage(imagePath, byteOrder);
         }
 
--- a/src/java.base/share/classes/sun/invoke/anon/AnonymousClassLoader.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/sun/invoke/anon/AnonymousClassLoader.java	Mon Oct 12 14:41:36 2015 -0700
@@ -25,10 +25,10 @@
 
 package sun.invoke.anon;
 
+import java.io.EOFException;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import sun.misc.IOUtils;
 
 /**
  * Anonymous class loader.  Will load any valid classfile, producing
@@ -225,6 +225,10 @@
         if (contentLength < 0)
             throw new IOException("invalid content length "+contentLength);
 
-        return IOUtils.readFully(connection.getInputStream(), contentLength, true);
+        byte[] b = connection.getInputStream().readAllBytes();
+        if (b.length != contentLength)
+            throw new EOFException("Expected:" + contentLength + ", read:" + b.length);
+
+        return b;
     }
 }
--- a/src/java.base/share/classes/sun/misc/ConditionLock.java	Mon Oct 12 16:26:58 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 1994, 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.misc;
-
-/**
- * ConditionLock is a Lock with a built in state variable.  This class
- * provides the ability to wait for the state variable to be set to a
- * desired value and then acquire the lock.<p>
- *
- * The lockWhen() and unlockWith() methods can be safely intermixed
- * with the lock() and unlock() methods. However if there is a thread
- * waiting for the state variable to become a particular value and you
- * simply call Unlock(), that thread will not be able to acquire the
- * lock until the state variable equals its desired value.
- *
- * @author      Peter King
- */
-public final
-class ConditionLock extends Lock {
-    private int state = 0;
-
-    /**
-     * Creates a ConditionLock.
-     */
-    public ConditionLock () {
-    }
-
-    /**
-     * Creates a ConditionLock in an initialState.
-     */
-    public ConditionLock (int initialState) {
-        state = initialState;
-    }
-
-    /**
-     * Acquires the lock when the state variable equals the desired state.
-     *
-     * @param desiredState the desired state
-     * @exception  java.lang.InterruptedException if any thread has
-     *               interrupted this thread.
-     */
-    public synchronized void lockWhen(int desiredState)
-        throws InterruptedException
-    {
-        while (state != desiredState) {
-            wait();
-        }
-        lock();
-    }
-
-    /**
-     * Releases the lock, and sets the state to a new value.
-     * @param newState the new state
-     */
-    public synchronized void unlockWith(int newState) {
-        state = newState;
-        unlock();
-    }
-}
--- a/src/java.base/share/classes/sun/misc/IOUtils.java	Mon Oct 12 16:26:58 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/**
- * IOUtils: A collection of IO-related public static methods.
- */
-
-package sun.misc;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-
-public class IOUtils {
-
-    /**
-     * Read up to <code>length</code> of bytes from <code>in</code>
-     * until EOF is detected.
-     * @param is input stream, must not be null
-     * @param length number of bytes to read, -1 or Integer.MAX_VALUE means
-     *        read as much as possible
-     * @param readAll if true, an EOFException will be thrown if not enough
-     *        bytes are read. Ignored when length is -1 or Integer.MAX_VALUE
-     * @return bytes read
-     * @throws IOException Any IO error or a premature EOF is detected
-     */
-    public static byte[] readFully(InputStream is, int length, boolean readAll)
-            throws IOException {
-        byte[] output = {};
-        if (length == -1) length = Integer.MAX_VALUE;
-        int pos = 0;
-        while (pos < length) {
-            int bytesToRead;
-            if (pos >= output.length) { // Only expand when there's no room
-                bytesToRead = Math.min(length - pos, output.length + 1024);
-                if (output.length < pos + bytesToRead) {
-                    output = Arrays.copyOf(output, pos + bytesToRead);
-                }
-            } else {
-                bytesToRead = output.length - pos;
-            }
-            int cc = is.read(output, pos, bytesToRead);
-            if (cc < 0) {
-                if (readAll && length != Integer.MAX_VALUE) {
-                    throw new EOFException("Detect premature EOF");
-                } else {
-                    if (output.length != pos) {
-                        output = Arrays.copyOf(output, pos);
-                    }
-                    break;
-                }
-            }
-            pos += cc;
-        }
-        return output;
-    }
-}
--- a/src/java.base/share/classes/sun/misc/Lock.java	Mon Oct 12 16:26:58 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 1994, 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.misc;
-
-/**
- * The Lock class provides a simple, useful interface to a lock.
- * Unlike monitors which synchronize access to an object, locks
- * synchronize access to an arbitrary set of resources (objects,
- * methods, variables, etc.). <p>
- *
- * The programmer using locks must be responsible for clearly defining
- * the semantics of their use and should handle deadlock avoidance in
- * the face of exceptions. <p>
- *
- * For example, if you want to protect a set of method invocations with
- * a lock, and one of the methods may throw an exception, you must be
- * prepared to release the lock similarly to the following example:
- * <pre>
- *      class SomeClass {
- *          Lock myLock = new Lock();
-
- *          void someMethod() {
- *              myLock.lock();
- *              try {
- *                  StartOperation();
- *                  ContinueOperation();
- *                  EndOperation();
- *              } finally {
- *                  myLock.unlock();
- *              }
- *          }
- *      }
- * </pre>
- *
- * @author      Peter King
- */
-public
-class Lock {
-    private boolean locked = false;
-
-    /**
-     * Create a lock, which is initially not locked.
-     */
-    public Lock () {
-    }
-
-    /**
-     * Acquire the lock.  If someone else has the lock, wait until it
-     * has been freed, and then try to acquire it again.  This method
-     * will not return until the lock has been acquired.
-     *
-     * @exception  java.lang.InterruptedException if any thread has
-     *               interrupted this thread.
-     */
-    public final synchronized void lock() throws InterruptedException {
-        while (locked) {
-            wait();
-        }
-        locked = true;
-    }
-
-    /**
-     * Release the lock.  If someone else is waiting for the lock, the
-     * will be notitified so they can try to acquire the lock again.
-     */
-    public final synchronized void unlock() {
-        locked = false;
-        notifyAll();
-    }
-}
--- a/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java	Mon Oct 12 14:41:36 2015 -0700
@@ -25,6 +25,7 @@
 
 package sun.reflect.misc;
 
+import java.io.EOFException;
 import java.security.AllPermission;
 import java.security.AccessController;
 import java.security.PermissionCollection;
@@ -43,7 +44,6 @@
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
-import sun.misc.IOUtils;
 
 
 class Trampoline {
@@ -368,15 +368,12 @@
             }
         }
         int len = uc.getContentLength();
-        InputStream in = new BufferedInputStream(uc.getInputStream());
-
-        byte[] b;
-        try {
-            b = IOUtils.readFully(in, len, true);
-        } finally {
-            in.close();
+        try (InputStream in = new BufferedInputStream(uc.getInputStream())) {
+            byte[] b = in.readAllBytes();
+            if (len != -1 && b.length != len)
+                throw new EOFException("Expected:" + len + ", read:" + b.length);
+            return b;
         }
-        return b;
     }
 
 
--- a/src/java.base/share/classes/sun/security/provider/DomainKeyStore.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/sun/security/provider/DomainKeyStore.java	Mon Oct 12 14:41:36 2015 -0700
@@ -33,7 +33,6 @@
 import java.security.cert.CertificateException;
 import java.util.*;
 
-import sun.misc.IOUtils;
 import sun.security.pkcs.EncryptedPrivateKeyInfo;
 import sun.security.util.PolicyUtil;
 
--- a/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java	Mon Oct 12 14:41:36 2015 -0700
@@ -32,9 +32,9 @@
 import java.security.cert.CertificateException;
 import java.util.*;
 
-import sun.misc.IOUtils;
 import sun.security.pkcs.EncryptedPrivateKeyInfo;
 import sun.security.pkcs12.PKCS12KeyStore;
+import sun.security.util.IOUtils;
 import sun.security.util.KeyStoreDelegator;
 
 /**
--- a/src/java.base/share/classes/sun/security/timestamp/HttpTimestamper.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/sun/security/timestamp/HttpTimestamper.java	Mon Oct 12 14:41:36 2015 -0700
@@ -27,13 +27,13 @@
 
 import java.io.BufferedInputStream;
 import java.io.DataOutputStream;
+import java.io.EOFException;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URL;
 import java.net.HttpURLConnection;
 import java.util.*;
 
-import sun.misc.IOUtils;
 import sun.security.util.Debug;
 
 /**
@@ -147,8 +147,11 @@
             }
             verifyMimeType(connection.getContentType());
 
-            int contentLength = connection.getContentLength();
-            replyBuffer = IOUtils.readFully(input, contentLength, false);
+            int clen = connection.getContentLength();
+            replyBuffer = input.readAllBytes();
+            if (clen != -1 && replyBuffer.length != clen)
+                throw new EOFException("Expected:" + clen +
+                                       ", read:" + replyBuffer.length);
 
             if (debug != null) {
                 debug.println("received timestamp response (length=" +
--- a/src/java.base/share/classes/sun/security/util/DerValue.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.base/share/classes/sun/security/util/DerValue.java	Mon Oct 12 14:41:36 2015 -0700
@@ -28,7 +28,6 @@
 import java.io.*;
 import java.math.BigInteger;
 import java.util.Date;
-import sun.misc.IOUtils;
 
 /**
  * Represents a single DER-encoded value.  DER encoding rules are a subset
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/sun/security/util/IOUtils.java	Mon Oct 12 14:41:36 2015 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * IOUtils: A collection of IO-related public static methods.
+ */
+
+package sun.security.util;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+
+public class IOUtils {
+
+    /**
+     * Read up to <code>length</code> of bytes from <code>in</code>
+     * until EOF is detected.
+     * @param is input stream, must not be null
+     * @param length number of bytes to read, -1 or Integer.MAX_VALUE means
+     *        read as much as possible
+     * @param readAll if true, an EOFException will be thrown if not enough
+     *        bytes are read. Ignored when length is -1 or Integer.MAX_VALUE
+     * @return bytes read
+     * @throws IOException Any IO error or a premature EOF is detected
+     */
+    public static byte[] readFully(InputStream is, int length, boolean readAll)
+            throws IOException {
+        byte[] output = {};
+        if (length == -1) length = Integer.MAX_VALUE;
+        int pos = 0;
+        while (pos < length) {
+            int bytesToRead;
+            if (pos >= output.length) { // Only expand when there's no room
+                bytesToRead = Math.min(length - pos, output.length + 1024);
+                if (output.length < pos + bytesToRead) {
+                    output = Arrays.copyOf(output, pos + bytesToRead);
+                }
+            } else {
+                bytesToRead = output.length - pos;
+            }
+            int cc = is.read(output, pos, bytesToRead);
+            if (cc < 0) {
+                if (readAll && length != Integer.MAX_VALUE) {
+                    throw new EOFException("Detect premature EOF");
+                } else {
+                    if (output.length != pos) {
+                        output = Arrays.copyOf(output, pos);
+                    }
+                    break;
+                }
+            }
+            pos += cc;
+        }
+        return output;
+    }
+}
--- a/src/java.desktop/share/classes/sun/applet/AppletClassLoader.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.desktop/share/classes/sun/applet/AppletClassLoader.java	Mon Oct 12 14:41:36 2015 -0700
@@ -33,6 +33,7 @@
 import java.net.MalformedURLException;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.io.EOFException;
 import java.io.File;
 import java.io.FilePermission;
 import java.io.IOException;
@@ -51,7 +52,6 @@
 import java.security.PermissionCollection;
 import sun.awt.AppContext;
 import sun.awt.SunToolkit;
-import sun.misc.IOUtils;
 import sun.misc.ManagedLocalsThread;
 import sun.net.www.ParseUtil;
 import sun.security.util.SecurityConstants;
@@ -334,7 +334,9 @@
 
         byte[] b;
         try {
-            b = IOUtils.readFully(in, len, true);
+            b = in.readAllBytes();
+            if (len != -1 && b.length != len)
+                throw new EOFException("Expected:" + len + ", read:" + b.length);
         } finally {
             in.close();
         }
--- a/src/java.logging/share/classes/java/util/logging/LogManager.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.logging/share/classes/java/util/logging/LogManager.java	Mon Oct 12 14:41:36 2015 -0700
@@ -32,8 +32,14 @@
 import java.lang.ref.ReferenceQueue;
 import java.lang.ref.WeakReference;
 import java.util.concurrent.ConcurrentHashMap;
+import java.nio.file.Paths;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.locks.ReentrantLock;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 import jdk.internal.misc.JavaAWTAccess;
 import jdk.internal.misc.SharedSecrets;
 import sun.misc.ManagedLocalsThread;
@@ -57,37 +63,28 @@
  * <p>
  * At startup the LogManager class is located using the
  * java.util.logging.manager system property.
+ *
+ * <h3>LogManager Configuration</h3>
+ *
+ * A LogManager initializes the logging configuration via
+ * the {@link #readConfiguration()} method during LogManager initialization.
+ * By default, LogManager default configuration is used.
+ * The logging configuration read by LogManager must be in the
+ * {@linkplain Properties properties file} format.
  * <p>
  * The LogManager defines two optional system properties that allow control over
- * the initial configuration:
+ * the initial configuration, as specified in the {@link #readConfiguration()}
+ * method:
  * <ul>
  * <li>"java.util.logging.config.class"
  * <li>"java.util.logging.config.file"
  * </ul>
- * These two properties may be specified on the command line to the "java"
+ * <p>
+ * These two system properties may be specified on the command line to the "java"
  * command, or as system property definitions passed to JNI_CreateJavaVM.
  * <p>
- * If the "java.util.logging.config.class" property is set, then the
- * property value is treated as a class name.  The given class will be
- * loaded, an object will be instantiated, and that object's constructor
- * is responsible for reading in the initial configuration.  (That object
- * may use other system properties to control its configuration.)  The
- * alternate configuration class can use {@code readConfiguration(InputStream)}
- * to define properties in the LogManager.
- * <p>
- * If "java.util.logging.config.class" property is <b>not</b> set,
- * then the "java.util.logging.config.file" system property can be used
- * to specify a properties file (in java.util.Properties format). The
- * initial logging configuration will be read from this file.
- * <p>
- * If neither of these properties is defined then the LogManager uses its
- * default configuration. The default configuration is typically loaded from the
- * properties file "{@code conf/logging.properties}" in the Java installation
- * directory.
- * <p>
- * The properties for loggers and Handlers will have names starting
- * with the dot-separated name for the handler or logger.
- * <p>
+ * The {@linkplain Properties properties} for loggers and Handlers will have
+ * names starting with the dot-separated name for the handler or logger.<br>
  * The global logging properties may include:
  * <ul>
  * <li>A property "handlers".  This defines a whitespace or comma separated
@@ -788,7 +785,7 @@
             // instantiation of the handler is done in the LogManager.addLogger
             // implementation as a handler class may be only visible to LogManager
             // subclass for the custom log manager case
-            processParentHandlers(logger, name);
+            processParentHandlers(logger, name, VisitedLoggers.NEVER);
 
             // Find the new node and its parent.
             LogNode node = getNode(name);
@@ -836,7 +833,8 @@
 
         // If logger.getUseParentHandlers() returns 'true' and any of the logger's
         // parents have levels or handlers defined, make sure they are instantiated.
-        private void processParentHandlers(final Logger logger, final String name) {
+        private void processParentHandlers(final Logger logger, final String name,
+               Predicate<Logger> visited) {
             final LogManager owner = getOwner();
             AccessController.doPrivileged(new PrivilegedAction<Void>() {
                 @Override
@@ -862,7 +860,9 @@
                     owner.getProperty(pname + ".handlers") != null) {
                     // This pname has a level/handlers definition.
                     // Make sure it exists.
-                    demandLogger(pname, null, null);
+                    if (visited.test(demandLogger(pname, null, null))) {
+                        break;
+                    }
                 }
                 ix = ix2+1;
             }
@@ -942,48 +942,64 @@
     private void loadLoggerHandlers(final Logger logger, final String name,
                                     final String handlersPropertyName)
     {
-        AccessController.doPrivileged(new PrivilegedAction<Object>() {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
             @Override
-            public Object run() {
-                String names[] = parseClassNames(handlersPropertyName);
-                final boolean ensureCloseOnReset = names.length > 0
-                    && getBooleanProperty(handlersPropertyName + ".ensureCloseOnReset",true);
-
-                int count = 0;
-                for (String type : names) {
-                    try {
-                        Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(type);
-                        Handler hdl = (Handler) clz.newInstance();
-                        // Check if there is a property defining the
-                        // this handler's level.
-                        String levs = getProperty(type + ".level");
-                        if (levs != null) {
-                            Level l = Level.findLevel(levs);
-                            if (l != null) {
-                                hdl.setLevel(l);
-                            } else {
-                                // Probably a bad level. Drop through.
-                                System.err.println("Can't set level for " + type);
-                            }
-                        }
-                        // Add this Handler to the logger
-                        logger.addHandler(hdl);
-                        if (++count == 1 && ensureCloseOnReset) {
-                            // add this logger to the closeOnResetLoggers list.
-                            closeOnResetLoggers.addIfAbsent(CloseOnReset.create(logger));
-                        }
-                    } catch (Exception ex) {
-                        System.err.println("Can't load log handler \"" + type + "\"");
-                        System.err.println("" + ex);
-                        ex.printStackTrace();
-                    }
-                }
-
+            public Void run() {
+                setLoggerHandlers(logger, name, handlersPropertyName,
+                    createLoggerHandlers(name, handlersPropertyName));
                 return null;
             }
         });
     }
 
+    private void setLoggerHandlers(final Logger logger, final String name,
+                                   final String handlersPropertyName,
+                                   List<Handler> handlers)
+    {
+        final boolean ensureCloseOnReset = ! handlers.isEmpty()
+                    && getBooleanProperty(handlersPropertyName + ".ensureCloseOnReset",true);
+        int count = 0;
+        for (Handler hdl : handlers) {
+            logger.addHandler(hdl);
+            if (++count == 1 && ensureCloseOnReset) {
+                // add this logger to the closeOnResetLoggers list.
+                closeOnResetLoggers.addIfAbsent(CloseOnReset.create(logger));
+            }
+        }
+    }
+
+    private List<Handler> createLoggerHandlers(final String name, final String handlersPropertyName)
+    {
+        String names[] = parseClassNames(handlersPropertyName);
+        List<Handler> handlers = new ArrayList<>(names.length);
+        for (String type : names) {
+            try {
+                Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(type);
+                Handler hdl = (Handler) clz.newInstance();
+                // Check if there is a property defining the
+                // this handler's level.
+                String levs = getProperty(type + ".level");
+                if (levs != null) {
+                    Level l = Level.findLevel(levs);
+                    if (l != null) {
+                        hdl.setLevel(l);
+                    } else {
+                        // Probably a bad level. Drop through.
+                        System.err.println("Can't set level for " + type);
+                    }
+                }
+                // Add this Handler to the logger
+                handlers.add(hdl);
+            } catch (Exception ex) {
+                System.err.println("Can't load log handler \"" + type + "\"");
+                System.err.println("" + ex);
+                ex.printStackTrace();
+            }
+        }
+
+        return handlers;
+    }
+
 
     // loggerRefQueue holds LoggerWeakRef objects for Logger objects
     // that have been GC'ed.
@@ -1242,21 +1258,48 @@
     }
 
     /**
-     * Reinitialize the logging properties and reread the logging configuration.
+     * Reads and initializes the logging configuration.
      * <p>
-     * The same rules are used for locating the configuration properties
-     * as are used at startup.  So normally the logging properties will
-     * be re-read from the same file that was used at startup.
-     * <P>
-     * Any log level definitions in the new configuration file will be
-     * applied using Logger.setLevel(), if the target Logger exists.
+     * If the "java.util.logging.config.class" system property is set, then the
+     * property value is treated as a class name.  The given class will be
+     * loaded, an object will be instantiated, and that object's constructor
+     * is responsible for reading in the initial configuration.  (That object
+     * may use other system properties to control its configuration.)  The
+     * alternate configuration class can use {@code readConfiguration(InputStream)}
+     * to define properties in the LogManager.
+     * <p>
+     * If "java.util.logging.config.class" system property is <b>not</b> set,
+     * then this method will read the initial configuration from a properties
+     * file and calls the {@link #readConfiguration(InputStream)} method to initialize
+     * the configuration. The "java.util.logging.config.file" system property can be used
+     * to specify the properties file that will be read as the initial configuration;
+     * if not set, then the LogManager default configuration is used.
+     * The default configuration is typically loaded from the
+     * properties file "{@code conf/logging.properties}" in the Java installation
+     * directory.
+     *
      * <p>
      * Any {@linkplain #addConfigurationListener registered configuration
      * listener} will be invoked after the properties are read.
      *
-     * @exception  SecurityException  if a security manager exists and if
-     *             the caller does not have LoggingPermission("control").
-     * @exception  IOException if there are IO problems reading the configuration.
+     * @apiNote This {@code readConfiguration} method should only be used for
+     * initializing the configuration during LogManager initialization or
+     * used with the "java.util.logging.config.class" property.
+     * When this method is called after loggers have been created, and
+     * the "java.util.logging.config.class" system property is not set, all
+     * existing loggers will be {@linkplain #reset() reset}. Then any
+     * existing loggers that have a level property specified in the new
+     * configuration stream will be {@linkplain
+     * Logger#setLevel(java.util.logging.Level) set} to the specified log level.
+     * <p>
+     * To properly update the logging configuration, use the
+     * {@link #updateConfiguration(java.util.function.Function)} or
+     * {@link #updateConfiguration(java.io.InputStream, java.util.function.Function)}
+     * methods instead.
+     *
+     * @throws   SecurityException  if a security manager exists and if
+     *              the caller does not have LoggingPermission("control").
+     * @throws   IOException if there are IO problems reading the configuration.
      */
     public void readConfiguration() throws IOException, SecurityException {
         checkPermission();
@@ -1284,20 +1327,24 @@
             }
         }
 
+        String fname = getConfigurationFileName();
+        try (final InputStream in = new FileInputStream(fname)) {
+            final BufferedInputStream bin = new BufferedInputStream(in);
+            readConfiguration(bin);
+        }
+    }
+
+    String getConfigurationFileName() throws IOException {
         String fname = System.getProperty("java.util.logging.config.file");
         if (fname == null) {
             fname = System.getProperty("java.home");
             if (fname == null) {
                 throw new Error("Can't find java.home ??");
             }
-            File f = new File(fname, "conf");
-            f = new File(f, "logging.properties");
-            fname = f.getCanonicalPath();
+            fname = Paths.get(fname, "conf", "logging.properties")
+                    .toAbsolutePath().normalize().toString();
         }
-        try (final InputStream in = new FileInputStream(fname)) {
-            final BufferedInputStream bin = new BufferedInputStream(in);
-            readConfiguration(bin);
-        }
+        return fname;
     }
 
     /**
@@ -1305,9 +1352,17 @@
      * <p>
      * For all named loggers, the reset operation removes and closes
      * all Handlers and (except for the root logger) sets the level
-     * to null.  The root logger's level is set to Level.INFO.
+     * to {@code null}. The root logger's level is set to {@code Level.INFO}.
      *
-     * @exception  SecurityException  if a security manager exists and if
+     * @apiNote Calling this method also clears the LogManager {@linkplain
+     * #getProperty(java.lang.String) properties}. The {@link
+     * #updateConfiguration(java.util.function.Function)
+     * updateConfiguration(Function)} or
+     * {@link #updateConfiguration(java.io.InputStream, java.util.function.Function)
+     * updateConfiguration(InputStream, Function)} method can be used to
+     * properly update to a new configuration.
+     *
+     * @throws  SecurityException  if a security manager exists and if
      *             the caller does not have LoggingPermission("control").
      */
 
@@ -1421,18 +1476,32 @@
     }
 
     /**
-     * Reinitialize the logging properties and reread the logging configuration
-     * from the given stream, which should be in java.util.Properties format.
+     * Reads and initializes the logging configuration from the given input stream.
+     *
+     * <p>
      * Any {@linkplain #addConfigurationListener registered configuration
      * listener} will be invoked after the properties are read.
      * <p>
-     * Any log level definitions in the new configuration file will be
-     * applied using Logger.setLevel(), if the target Logger exists.
+     * @apiNote This {@code readConfiguration} method should only be used for
+     * initializing the configuration during LogManager initialization or
+     * used with the "java.util.logging.config.class" property.
+     * When this method is called after loggers have been created, all
+     * existing loggers will be {@linkplain #reset() reset}. Then any
+     * existing loggers that have a level property specified in the
+     * given input stream will be {@linkplain
+     * Logger#setLevel(java.util.logging.Level) set} to the specified log level.
+     * <p>
+     * To properly update the logging configuration, use the
+     * {@link #updateConfiguration(java.util.function.Function)} or
+     * {@link #updateConfiguration(java.io.InputStream, java.util.function.Function)}
+     * method instead.
      *
-     * @param ins       stream to read properties from
-     * @exception  SecurityException  if a security manager exists and if
+     * @param ins  stream to read properties from
+     * @throws  SecurityException  if a security manager exists and if
      *             the caller does not have LoggingPermission("control").
-     * @exception  IOException if there are problems reading from the stream.
+     * @throws  IOException if there are problems reading from the stream,
+     *             or the given stream is not in the
+     *             {@linkplain java.util.Properties properties file} format.
      */
     public void readConfiguration(InputStream ins) throws IOException, SecurityException {
         checkPermission();
@@ -1506,6 +1575,633 @@
         invokeConfigurationListeners();
     }
 
+    // This enum enumerate the configuration properties that will be
+    // updated on existing loggers when the configuration is updated
+    // with LogManager.updateConfiguration().
+    //
+    // Note that this works properly only for the global LogManager - as
+    // Handler and its subclasses get their configuration from
+    // LogManager.getLogManager().
+    //
+    static enum ConfigProperty {
+        LEVEL(".level"), HANDLERS(".handlers"), USEPARENT(".useParentHandlers");
+        final String suffix;
+        final int length;
+        private ConfigProperty(String suffix) {
+            this.suffix = Objects.requireNonNull(suffix);
+            length = suffix.length();
+        }
+
+        public boolean handleKey(String key) {
+            if (this == HANDLERS && suffix.substring(1).equals(key)) return true;
+            if (this == HANDLERS && suffix.equals(key)) return false;
+            return key.endsWith(suffix);
+        }
+        String key(String loggerName) {
+            if (this == HANDLERS && (loggerName == null || loggerName.isEmpty())) {
+                return suffix.substring(1);
+            }
+            return loggerName + suffix;
+        }
+        String loggerName(String key) {
+            assert key.equals(suffix.substring(1)) && this == HANDLERS || key.endsWith(suffix);
+            if (this == HANDLERS && suffix.substring(1).equals(key)) return "";
+            return key.substring(0, key.length() - length);
+        }
+
+        /**
+         * If the property is one that should be updated on existing loggers by
+         * updateConfiguration, returns the name of the logger for which the
+         * property is configured. Otherwise, returns null.
+         * @param property a property key in 'props'
+         * @return the name of the logger on which the property is to be set,
+         *         if the property is one that should be updated on existing
+         *         loggers, {@code null} otherwise.
+         */
+        static String getLoggerName(String property) {
+            for (ConfigProperty p : ConfigProperty.ALL) {
+                if (p.handleKey(property)) {
+                    return p.loggerName(property);
+                }
+            }
+            return null; // Not a property that should be updated.
+        }
+
+        /**
+         * Find the ConfigProperty corresponding to the given
+         * property key (may find none).
+         * @param property a property key in 'props'
+         * @return An optional containing a ConfigProperty object,
+         *         if the property is one that should be updated on existing
+         *         loggers, empty otherwise.
+         */
+        static Optional<ConfigProperty> find(String property) {
+            return ConfigProperty.ALL.stream()
+                    .filter(p -> p.handleKey(property))
+                    .findFirst();
+         }
+
+        /**
+         * Returns true if the given property is one that should be updated
+         * on existing loggers.
+         * Used to filter property name streams.
+         * @param property a property key from the configuration.
+         * @return true if this property is of interest for updateConfiguration.
+         */
+        static boolean matches(String property) {
+            return find(property).isPresent();
+        }
+
+        /**
+         * Returns true if the new property value is different from the old,
+         * and therefore needs to be updated on existing loggers.
+         * @param k a property key in the configuration
+         * @param previous the old configuration
+         * @param next the new configuration
+         * @return true if the property is changing value between the two
+         *         configurations.
+         */
+        static boolean needsUpdating(String k, Properties previous, Properties next) {
+            final String p = trim(previous.getProperty(k, null));
+            final String n = trim(next.getProperty(k, null));
+            return ! Objects.equals(p,n);
+        }
+
+        /**
+         * Applies the mapping function for the given key to the next
+         * configuration.
+         * If the mapping function is null then this method does nothing.
+         * Otherwise, it calls the mapping function to compute the value
+         * that should be associated with {@code key} in the resulting
+         * configuration, and applies it to {@code next}.
+         * If the mapping function returns {@code null} the key is removed
+         * from {@code next}.
+         *
+         * @param k a property key in the configuration
+         * @param previous the old configuration
+         * @param next the new configuration (modified by this function)
+         * @param remappingFunction the mapping function.
+         */
+        static void merge(String k, Properties previous, Properties next,
+                          BiFunction<String, String, String> mappingFunction) {
+            String p = trim(previous.getProperty(k, null));
+            String n = trim(next.getProperty(k, null));
+            String mapped = trim(mappingFunction.apply(p,n));
+            if (!Objects.equals(n, mapped)) {
+                if (mapped == null) {
+                    next.remove(k);
+                } else {
+                    next.setProperty(k, mapped);
+                }
+            }
+        }
+
+        private static final EnumSet<ConfigProperty> ALL =
+                EnumSet.allOf(ConfigProperty.class);
+    }
+
+    // trim the value if not null.
+    private static String trim(String value) {
+        return value == null ? null : value.trim();
+    }
+
+    /**
+     * An object that keep track of loggers we have already visited.
+     * Used when updating configuration, to avoid processing the same logger
+     * twice.
+     */
+    static final class VisitedLoggers implements Predicate<Logger> {
+        final IdentityHashMap<Logger,Boolean> visited;
+        private VisitedLoggers(IdentityHashMap<Logger,Boolean> visited) {
+            this.visited = visited;
+        }
+        VisitedLoggers() {
+            this(new IdentityHashMap<>());
+        }
+        @Override
+        public boolean test(Logger logger) {
+            return visited != null && visited.put(logger, Boolean.TRUE) != null;
+        }
+        public void clear() {
+            if (visited != null) visited.clear();
+        }
+
+        // An object that considers that no logger has ever been visited.
+        // This is used when processParentHandlers is called from
+        // LoggerContext.addLocalLogger
+        static final VisitedLoggers NEVER = new VisitedLoggers(null);
+    }
+
+
+    /**
+     * Type of the modification for a given property. One of SAME, ADDED, CHANGED,
+     * or REMOVED.
+     */
+    static enum ModType {
+        SAME,    // property had no value in the old and new conf, or had the
+                 // same value in both.
+        ADDED,   // property had no value in the old conf, but has one in the new.
+        CHANGED, // property has a different value in the old conf and the new conf.
+        REMOVED; // property has no value in the new conf, but had one in the old.
+        static ModType of(String previous, String next) {
+            if (previous == null && next != null) {
+                return ADDED;
+            }
+            if (next == null && previous != null) {
+                return REMOVED;
+            }
+            if (!Objects.equals(trim(previous), trim(next))) {
+                return CHANGED;
+            }
+            return SAME;
+        }
+    }
+
+    /**
+     * Updates the logging configuration.
+     * <p>
+     * If the "java.util.logging.config.file" system property is set,
+     * then the property value specifies the properties file to be read
+     * as the new configuration. Otherwise, the LogManager default
+     * configuration is used.
+     * <br>The default configuration is typically loaded from the
+     * properties file "{@code conf/logging.properties}" in the
+     * Java installation directory.
+     * <p>
+     * This method reads the new configuration and calls the {@link
+     * #updateConfiguration(java.io.InputStream, java.util.function.Function)
+     * updateConfiguration(ins, mapper)} method to
+     * update the configuration.
+     *
+     * @apiNote
+     * This method updates the logging configuration from reading
+     * a properties file and ignores the "java.util.logging.config.class"
+     * system property.  The "java.util.logging.config.class" property is
+     * only used by the {@link #readConfiguration()}  method to load a custom
+     * configuration class as an initial configuration.
+     *
+     * @param mapper a functional interface that takes a configuration
+     *   key <i>k</i> and returns a function <i>f(o,n)</i> whose returned
+     *   value will be applied to the resulting configuration. The
+     *   function <i>f</i> may return {@code null} to indicate that the property
+     *   <i>k</i> will not be added to the resulting configuration.
+     *   <br>
+     *   If {@code mapper} is {@code null} then {@code (k) -> ((o, n) -> n)} is
+     *   assumed.
+     *   <br>
+     *   For each <i>k</i>, the mapped function <i>f</i> will
+     *   be invoked with the value associated with <i>k</i> in the old
+     *   configuration (i.e <i>o</i>) and the value associated with
+     *   <i>k</i> in the new configuration (i.e. <i>n</i>).
+     *   <br>A {@code null} value for <i>o</i> or <i>n</i> indicates that no
+     *   value was present for <i>k</i> in the corresponding configuration.
+     *
+     * @throws  SecurityException  if a security manager exists and if
+     *          the caller does not have LoggingPermission("control"), or
+     *          does not have the permissions required to set up the
+     *          configuration (e.g. open file specified for FileHandlers
+     *          etc...)
+     *
+     * @throws  NullPointerException  if {@code mapper} returns a {@code null}
+     *         function when invoked.
+     *
+     * @throws  IOException if there are problems reading from the
+     *          logging configuration file.
+     *
+     * @see #updateConfiguration(java.io.InputStream, java.util.function.Function)
+     */
+    public void updateConfiguration(Function<String, BiFunction<String,String,String>> mapper)
+            throws IOException {
+        checkPermission();
+        ensureLogManagerInitialized();
+        drainLoggerRefQueueBounded();
+
+        String fname = getConfigurationFileName();
+        try (final InputStream in = new FileInputStream(fname)) {
+            final BufferedInputStream bin = new BufferedInputStream(in);
+            updateConfiguration(bin, mapper);
+        }
+    }
+
+    /**
+     * Updates the logging configuration.
+     * <p>
+     * For each configuration key in the {@linkplain
+     * #getProperty(java.lang.String) existing configuration} and
+     * the given input stream configuration, the given {@code mapper} function
+     * is invoked to map from the configuration key to a function,
+     * <i>f(o,n)</i>, that takes the old value and new value and returns
+     * the resulting value to be applied in the resulting configuration,
+     * as specified in the table below.
+     * <p>Let <i>k</i> be a configuration key in the old or new configuration,
+     * <i>o</i> be the old value (i.e. the value associated
+     * with <i>k</i> in the old configuration), <i>n</i> be the
+     * new value (i.e. the value associated with <i>k</i> in the new
+     * configuration), and <i>f</i> be the function returned
+     * by {@code mapper.apply(}<i>k</i>{@code )}: then <i>v = f(o,n)</i> is the
+     * resulting value. If <i>v</i> is not {@code null}, then a property
+     * <i>k</i> with value <i>v</i> will be added to the resulting configuration.
+     * Otherwise, it will be omitted.
+     * <br>A {@code null} value may be passed to function
+     * <i>f</i> to indicate that the corresponding configuration has no
+     * configuration key <i>k</i>.
+     * The function <i>f</i> may return {@code null} to indicate that
+     * there will be no value associated with <i>k</i> in the resulting
+     * configuration.
+     * <p>
+     * If {@code mapper} is {@code null}, then <i>v</i> will be set to
+     * <i>n</i>.
+     * <p>
+     * LogManager {@linkplain #getProperty(java.lang.String) properties} are
+     * updated with the resulting value in the resulting configuration.
+     * <p>
+     * The registered {@linkplain #addConfigurationListener configuration
+     * listeners} will be invoked after the configuration is successfully updated.
+     * <br><br>
+     * <table summary="Updating configuration properties">
+     * <tr>
+     * <th>Property</th>
+     * <th>Resulting Behavior</th>
+     * </tr>
+     * <tr>
+     * <td valign="top">{@code <logger>.level}</td>
+     * <td>
+     * <ul>
+     *   <li>If the resulting configuration defines a level for a logger and
+     *       if the resulting level is different than the level specified in the
+     *       the old configuration, or not specified in
+     *       the old configuration, then if the logger exists or if children for
+     *       that logger exist, the level for that logger will be updated,
+     *       and the change propagated to any existing logger children.
+     *       This may cause the logger to be created, if necessary.
+     *   </li>
+     *   <li>If the old configuration defined a level for a logger, and the
+     *       resulting configuration doesn't, then this change will not be
+     *       propagated to existing loggers, if any.
+     *       To completely replace a configuration - the caller should therefore
+     *       call {@link #reset() reset} to empty the current configuration,
+     *       before calling {@code updateConfiguration}.
+     *   </li>
+     * </ul>
+     * </td>
+     * <tr>
+     * <td valign="top">{@code <logger>.useParentHandlers}</td>
+     * <td>
+     * <ul>
+     *   <li>If either the resulting or the old value for the useParentHandlers
+     *       property is not null, then if the logger exists or if children for
+     *       that logger exist, that logger will be updated to the resulting
+     *       value.
+     *       The value of the useParentHandlers property is the value specified
+     *       in the configuration; if not specified, the default is true.
+     *   </li>
+     * </ul>
+     * </td>
+     * </tr>
+     * <tr>
+     * <td valign="top">{@code <logger>.handlers}</td>
+     * <td>
+     * <ul>
+     *   <li>If the resulting configuration defines a list of handlers for a
+     *       logger, and if the resulting list is different than the list
+     *       specified in the old configuration for that logger (that could be
+     *       empty), then if the logger exists or its children exist, the
+     *       handlers associated with that logger are closed and removed and
+     *       the new handlers will be created per the resulting configuration
+     *       and added to that logger, creating that logger if necessary.
+     *   </li>
+     *   <li>If the old configuration defined some handlers for a logger, and
+     *       the resulting configuration doesn't, if that logger exists,
+     *       its handlers will be removed and closed.
+     *   </li>
+     *   <li>Changing the list of handlers on an existing logger will cause all
+     *       its previous handlers to be removed and closed, regardless of whether
+     *       they had been created from the configuration or programmatically.
+     *       The old handlers will be replaced by new handlers, if any.
+     *   </li>
+     * </ul>
+     * </td>
+     * </tr>
+     * <tr>
+     * <td valign="top">{@code <handler-name>.*}</td>
+     * <td>
+     * <ul>
+     *   <li>Properties configured/changed on handler classes will only affect
+     *       newly created handlers. If a node is configured with the same list
+     *       of handlers in the old and the resulting configuration, then these
+     *       handlers will remain unchanged.
+     *   </li>
+     * </ul>
+     * </td>
+     * </tr>
+     * <tr>
+     * <td valign="top">{@code config} and any other property</td>
+     * <td>
+     * <ul>
+     *   <li>The resulting value for these property will be stored in the
+     *   LogManager properties, but {@code updateConfiguration} will not parse
+     *   or process their values.
+     *   </li>
+     * </ul>
+     * </td>
+     * </tr>
+     * </table>
+     * <p>
+     * <em>Example mapper functions:</em>
+     * <br><br>
+     * <ul>
+     * <li>Replace all logging properties with the new configuration:
+     * <br><br>{@code     (k) -> ((o, n) -> n)}:
+     * <br><br>this is equivalent to passing a null {@code mapper} parameter.
+     * </li>
+     * <li>Merge the new configuration and old configuration and use the
+     * new value if <i>k</i> exists in the new configuration:
+     * <br><br>{@code     (k) -> ((o, n) -> n == null ? o : n)}:
+     * <br><br>as if merging two collections as follows:
+     * {@code result.putAll(oldc); result.putAll(newc)}.<br></li>
+     * <li>Merge the new configuration and old configuration and use the old
+     * value if <i>k</i> exists in the old configuration:
+     * <br><br>{@code     (k) -> ((o, n) -> o == null ? n : o)}:
+     * <br><br>as if merging two collections as follows:
+     * {@code result.putAll(newc); result.putAll(oldc)}.<br></li>
+     * <li>Replace all properties with the new configuration except the handler
+     * property to configure Logger's handler that is not root logger:
+     * <br>
+     * <pre>{@code (k) -> k.endsWith(".handlers")}
+     *      {@code     ? ((o, n) -> (o == null ? n : o))}
+     *      {@code     : ((o, n) -> n)}</pre>
+     * </li>
+     * </ul>
+     * <p>
+     * To completely reinitialize a configuration, an application can first call
+     * {@link #reset() reset} to fully remove the old configuration, followed by
+     * {@code updateConfiguration} to initialize the new configuration.
+     *
+     * @param ins    a stream to read properties from
+     * @param mapper a functional interface that takes a configuration
+     *   key <i>k</i> and returns a function <i>f(o,n)</i> whose returned
+     *   value will be applied to the resulting configuration. The
+     *   function <i>f</i> may return {@code null} to indicate that the property
+     *   <i>k</i> will not be added to the resulting configuration.
+     *   <br>
+     *   If {@code mapper} is {@code null} then {@code (k) -> ((o, n) -> n)} is
+     *   assumed.
+     *   <br>
+     *   For each <i>k</i>, the mapped function <i>f</i> will
+     *   be invoked with the value associated with <i>k</i> in the old
+     *   configuration (i.e <i>o</i>) and the value associated with
+     *   <i>k</i> in the new configuration (i.e. <i>n</i>).
+     *   <br>A {@code null} value for <i>o</i> or <i>n</i> indicates that no
+     *   value was present for <i>k</i> in the corresponding configuration.
+     *
+     * @throws  SecurityException if a security manager exists and if
+     *          the caller does not have LoggingPermission("control"), or
+     *          does not have the permissions required to set up the
+     *          configuration (e.g. open files specified for FileHandlers)
+     *
+     * @throws  NullPointerException if {@code ins} is null or if
+     *          {@code mapper} returns a null function when invoked.
+     *
+     * @throws  IOException if there are problems reading from the stream,
+     *          or the given stream is not in the
+     *          {@linkplain java.util.Properties properties file} format.
+     */
+    public void updateConfiguration(InputStream ins,
+            Function<String, BiFunction<String,String,String>> mapper)
+            throws IOException {
+        checkPermission();
+        ensureLogManagerInitialized();
+        drainLoggerRefQueueBounded();
+
+        final Properties previous;
+        final Set<String> updatePropertyNames;
+        List<LoggerContext> cxs = Collections.emptyList();
+        final VisitedLoggers visited = new VisitedLoggers();
+        final Properties next = new Properties();
+
+        try {
+            // Load the properties
+            next.load(ins);
+        } catch (IllegalArgumentException x) {
+            // props.load may throw an IllegalArgumentException if the stream
+            // contains malformed Unicode escape sequences.
+            // We wrap that in an IOException as updateConfiguration is
+            // specified to throw IOException if there are problems reading
+            // from the stream.
+            // Note: new IOException(x.getMessage(), x) allow us to get a more
+            // concise error message than new IOException(x);
+            throw new IOException(x.getMessage(), x);
+        }
+
+        if (globalHandlersState == STATE_SHUTDOWN) return;
+
+        // exclusive lock: readConfiguration/reset/updateConfiguration can't
+        //           run concurrently.
+        // configurationLock.writeLock().lock();
+        configurationLock.lock();
+        try {
+            if (globalHandlersState == STATE_SHUTDOWN) return;
+            previous = props;
+
+            // Builds a TreeSet of all (old and new) property names.
+            updatePropertyNames =
+                    Stream.concat(previous.stringPropertyNames().stream(),
+                                  next.stringPropertyNames().stream())
+                        .collect(Collectors.toCollection(TreeSet::new));
+
+            if (mapper != null) {
+                // mapper will potentially modify the content of
+                // 'next', so we need to call it before affecting props=next.
+                // give a chance to the mapper to control all
+                // properties - not just those we will reset.
+                updatePropertyNames.stream()
+                        .forEachOrdered(k -> ConfigProperty
+                                .merge(k, previous, next,
+                                       Objects.requireNonNull(mapper.apply(k))));
+            }
+
+            props = next;
+
+            // allKeys will contain all keys:
+            //    - which correspond to a configuration property we are interested in
+            //      (first filter)
+            //    - whose value needs to be updated (because it's new, removed, or
+            //      different) in the resulting configuration (second filter)
+            final Stream<String> allKeys = updatePropertyNames.stream()
+                    .filter(ConfigProperty::matches)
+                    .filter(k -> ConfigProperty.needsUpdating(k, previous, next));
+
+            // Group configuration properties by logger name
+            // We use a TreeMap so that parent loggers will be visited before
+            // child loggers.
+            final Map<String, TreeSet<String>> loggerConfigs =
+                    allKeys.collect(Collectors.groupingBy(ConfigProperty::getLoggerName,
+                                    TreeMap::new,
+                                    Collectors.toCollection(TreeSet::new)));
+
+            if (!loggerConfigs.isEmpty()) {
+                cxs = contexts();
+            }
+            final List<Logger> loggers = cxs.isEmpty()
+                    ? Collections.emptyList() : new ArrayList<>(cxs.size());
+            for (Map.Entry<String, TreeSet<String>> e : loggerConfigs.entrySet()) {
+                // This can be a logger name, or something else...
+                // The only thing we know is that we found a property
+                //    we are interested in.
+                // For instance, if we found x.y.z.level, then x.y.z could be
+                // a logger, but it could also be a handler class...
+                // Anyway...
+                final String name = e.getKey();
+                final Set<String> properties = e.getValue();
+                loggers.clear();
+                for (LoggerContext cx : cxs) {
+                    Logger l = cx.findLogger(name);
+                    if (l != null && !visited.test(l)) {
+                        loggers.add(l);
+                    }
+                }
+                if (loggers.isEmpty()) continue;
+                for (String pk : properties) {
+                    ConfigProperty cp = ConfigProperty.find(pk).get();
+                    String p = previous.getProperty(pk, null);
+                    String n = next.getProperty(pk, null);
+
+                    // Determines the type of modification.
+                    ModType mod = ModType.of(p, n);
+
+                    // mod == SAME means that the two values are equals, there
+                    // is nothing to do. Usually, this should not happen as such
+                    // properties should have been filtered above.
+                    // It could happen however if the properties had
+                    // trailing/leading whitespaces.
+                    if (mod == ModType.SAME) continue;
+
+                    switch (cp) {
+                        case LEVEL:
+                            if (mod == ModType.REMOVED) continue;
+                            Level level = Level.findLevel(trim(n));
+                            if (level != null) {
+                                if (name.isEmpty()) {
+                                    rootLogger.setLevel(level);
+                                }
+                                for (Logger l : loggers) {
+                                    if (!name.isEmpty() || l != rootLogger) {
+                                        l.setLevel(level);
+                                    }
+                                }
+                            }
+                            break;
+                        case USEPARENT:
+                            if (!name.isEmpty()) {
+                                boolean useParent = getBooleanProperty(pk, true);
+                                if (n != null || p != null) {
+                                    // reset the flag only if the previous value
+                                    // or the new value are not null.
+                                    for (Logger l : loggers) {
+                                        l.setUseParentHandlers(useParent);
+                                    }
+                                }
+                            }
+                            break;
+                        case HANDLERS:
+                            List<Handler> hdls = null;
+                            if (name.isEmpty()) {
+                                // special handling for the root logger.
+                                globalHandlersState = STATE_READING_CONFIG;
+                                try {
+                                    closeHandlers(rootLogger);
+                                    globalHandlersState = STATE_UNINITIALIZED;
+                                } catch (Throwable t) {
+                                    globalHandlersState = STATE_INITIALIZED;
+                                    throw t;
+                                }
+                            }
+                            for (Logger l : loggers) {
+                                if (l == rootLogger) continue;
+                                closeHandlers(l);
+                                if (mod == ModType.REMOVED) {
+                                    closeOnResetLoggers.removeIf(c -> c.logger == l);
+                                    continue;
+                                }
+                                if (hdls == null) {
+                                    hdls = name.isEmpty()
+                                            ? Arrays.asList(rootLogger.getHandlers())
+                                            : createLoggerHandlers(name, pk);
+                                }
+                                setLoggerHandlers(l, name, pk, hdls);
+                            }
+                            break;
+                        default: break;
+                    }
+                }
+            }
+        } finally {
+            configurationLock.unlock();
+            visited.clear();
+        }
+
+        // Now ensure that if an existing logger has acquired a new parent
+        // in the configuration, this new parent will be created - if needed,
+        // and added to the context of the existing child.
+        //
+        drainLoggerRefQueueBounded();
+        for (LoggerContext cx : cxs) {
+            for (Enumeration<String> names = cx.getLoggerNames() ; names.hasMoreElements();) {
+                String name = names.nextElement();
+                if (name.isEmpty()) continue;  // don't need to process parents on root.
+                Logger l = cx.findLogger(name);
+                if (l != null && !visited.test(l)) {
+                    // should pass visited here to cut the processing when
+                    // reaching a logger already visited.
+                    cx.processParentHandlers(l, name, visited);
+                }
+            }
+        }
+
+        // We changed the configuration: invoke configuration listeners
+        invokeConfigurationListeners();
+    }
+
     /**
      * Get the value of a logging property.
      * The method returns null if the property is not found.
--- a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java	Mon Oct 12 14:41:36 2015 -0700
@@ -45,7 +45,6 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.InvocationTargetException;
 import java.util.Arrays;
-import sun.misc.IOUtils;
 import javax.net.SocketFactory;
 
 /**
@@ -862,7 +861,7 @@
                     }
 
                     // read in seqlen bytes
-                    byte[] left = IOUtils.readFully(in, seqlen, false);
+                    byte[] left = readFully(in, seqlen);
                     inbuf = Arrays.copyOf(inbuf, offset + left.length);
                     System.arraycopy(left, 0, inbuf, offset, left.length);
                     offset += left.length;
@@ -957,6 +956,31 @@
         }
     }
 
+    private static byte[] readFully(InputStream is, int length)
+        throws IOException
+    {
+        byte[] buf = new byte[Math.min(length, 8192)];
+        int nread = 0;
+        while (nread < length) {
+            int bytesToRead;
+            if (nread >= buf.length) {  // need to allocate a larger buffer
+                bytesToRead = Math.min(length - nread, buf.length + 8192);
+                if (buf.length < nread + bytesToRead) {
+                    buf = Arrays.copyOf(buf, nread + bytesToRead);
+                }
+            } else {
+                bytesToRead = buf.length - nread;
+            }
+            int count = is.read(buf, nread, bytesToRead);
+            if (count < 0) {
+                if (buf.length != nread)
+                    buf = Arrays.copyOf(buf, nread);
+                break;
+            }
+            nread += count;
+        }
+        return buf;
+    }
 
     // This code must be uncommented to run the LdapAbandonTest.
     /*public void sendSearchReqs(String dn, int numReqs) {
--- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/NetClient.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/NetClient.java	Mon Oct 12 14:41:36 2015 -0700
@@ -31,10 +31,9 @@
 
 package sun.security.krb5.internal;
 
-import sun.misc.IOUtils;
-
 import java.io.*;
 import java.net.*;
+import sun.security.util.IOUtils;
 
 public abstract class NetClient implements AutoCloseable {
     public static NetClient getInstance(String protocol, String hostname, int port,
--- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java	Mon Oct 12 14:41:36 2015 -0700
@@ -36,10 +36,10 @@
 import java.util.List;
 import java.util.StringTokenizer;
 
-import sun.misc.IOUtils;
 import sun.security.krb5.*;
 import sun.security.krb5.internal.*;
 import sun.security.krb5.internal.util.KrbDataInputStream;
+import sun.security.util.IOUtils;
 
 /**
  * This class extends KrbDataInputStream. It is used for parsing FCC-format
--- a/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/SunPKCS11.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/SunPKCS11.java	Mon Oct 12 14:41:36 2015 -0700
@@ -106,9 +106,9 @@
     public Provider configure(String configArg) throws InvalidParameterException {
         final String newConfigName = checkNull(configArg);
         try {
-            return AccessController.doPrivileged(new PrivilegedExceptionAction<Provider>() {
+            return AccessController.doPrivileged(new PrivilegedExceptionAction<>() {
                 @Override
-                public Provider run() throws Exception {
+                public SunPKCS11 run() throws Exception {
                     return new SunPKCS11(new Config(newConfigName));
                 }
             });
@@ -119,6 +119,11 @@
         }
     }
 
+    @Override
+    public boolean isConfigured() {
+        return (config != null);
+    }
+
     private static <T> T checkNull(T obj) {
         if (obj == null) {
             throw new NullPointerException();
@@ -1142,8 +1147,10 @@
      * @param handler the <code>CallbackHandler</code> used by
      *  this provider to communicate with the caller
      *
-     * @exception LoginException if the login operation fails
-     * @exception SecurityException if the does not pass a security check for
+     * @throws IllegalStateException if the provider requires configuration
+     * and Provider.configure has not been called
+     * @throws LoginException if the login operation fails
+     * @throws SecurityException if the does not pass a security check for
      *  <code>SecurityPermission("authProvider.<i>name</i>")</code>,
      *  where <i>name</i> is the value returned by
      *  this provider's <code>getName</code> method
@@ -1151,8 +1158,11 @@
     public void login(Subject subject, CallbackHandler handler)
         throws LoginException {
 
+        if (!isConfigured()) {
+            throw new IllegalStateException("Configuration is required");
+        }
+
         // security check
-
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
             if (debug != null) {
@@ -1271,16 +1281,21 @@
     /**
      * Log out from this provider
      *
-     * @exception LoginException if the logout operation fails
-     * @exception SecurityException if the does not pass a security check for
+     * @throws IllegalStateException if the provider requires configuration
+     * and Provider.configure has not been called
+     * @throws LoginException if the logout operation fails
+     * @throws SecurityException if the does not pass a security check for
      *  <code>SecurityPermission("authProvider.<i>name</i>")</code>,
      *  where <i>name</i> is the value returned by
      *  this provider's <code>getName</code> method
      */
     public void logout() throws LoginException {
 
+        if (!isConfigured()) {
+            throw new IllegalStateException("Configuration is required");
+        }
+
         // security check
-
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
             sm.checkPermission
@@ -1353,7 +1368,9 @@
      * @param handler a <code>CallbackHandler</code> for obtaining
      *          authentication information, which may be <code>null</code>
      *
-     * @exception SecurityException if the caller does not pass a
+     * @throws IllegalStateException if the provider requires configuration
+     * and Provider.configure has not been called
+     * @throws SecurityException if the caller does not pass a
      *  security check for
      *  <code>SecurityPermission("authProvider.<i>name</i>")</code>,
      *  where <i>name</i> is the value returned by
@@ -1361,8 +1378,11 @@
      */
     public void setCallbackHandler(CallbackHandler handler) {
 
+        if (!isConfigured()) {
+            throw new IllegalStateException("Configuration is required");
+        }
+
         // security check
-
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
             sm.checkPermission
--- a/src/jdk.localedata/share/classes/sun/util/resources/en/GB/TimeZoneNames_en_GB.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/jdk.localedata/share/classes/sun/util/resources/en/GB/TimeZoneNames_en_GB.java	Mon Oct 12 14:41:36 2015 -0700
@@ -47,7 +47,8 @@
     protected final Object[][] getContents() {
         return new Object[][] {
             {"Europe/London", new String[] {"Greenwich Mean Time", "GMT",
-                                            "British Summer Time", "BST"}},
+                                            "British Summer Time", "BST",
+                                            "British Time", "BT"}},
         };
     }
 }
--- a/src/jdk.localedata/share/classes/sun/util/resources/hi/TimeZoneNames_hi.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/src/jdk.localedata/share/classes/sun/util/resources/hi/TimeZoneNames_hi.java	Mon Oct 12 14:41:36 2015 -0700
@@ -40,7 +40,8 @@
             {"Asia/Calcutta",
                 new String[] {
                     "\u092d\u093e\u0930\u0924\u0940\u092f \u0938\u092e\u092f", "IST",
-                    "\u092d\u093e\u0930\u0924\u0940\u092f \u0938\u092e\u092f", "IST"
+                    "\u092d\u093e\u0930\u0924\u0940\u092f \u0938\u092e\u092f", "IST",
+                    "\u092d\u093e\u0930\u0924\u0940\u092f \u0938\u092e\u092f", "IT"
                 }
             },
         };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/StrictMath/FdlibmTranslit.java	Mon Oct 12 14:41:36 2015 -0700
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * A transliteration of the "Freely Distributable Math Library"
+ * algorithms from C into Java. That is, this port of the algorithms
+ * is as close to the C originals as possible while still being
+ * readable legal Java.
+ */
+public class FdlibmTranslit {
+    private FdlibmTranslit() {
+        throw new UnsupportedOperationException("No FdLibmTranslit instances for you.");
+    }
+
+    /**
+     * Return the low-order 32 bits of the double argument as an int.
+     */
+    private static int __LO(double x) {
+        long transducer = Double.doubleToRawLongBits(x);
+        return (int)transducer;
+    }
+
+    /**
+     * Return a double with its low-order bits of the second argument
+     * and the high-order bits of the first argument..
+     */
+    private static double __LO(double x, int low) {
+        long transX = Double.doubleToRawLongBits(x);
+        return Double.longBitsToDouble((transX & 0xFFFF_FFFF_0000_0000L)|low );
+    }
+
+    /**
+     * Return the high-order 32 bits of the double argument as an int.
+     */
+    private static int __HI(double x) {
+        long transducer = Double.doubleToRawLongBits(x);
+        return (int)(transducer >> 32);
+    }
+
+    /**
+     * Return a double with its high-order bits of the second argument
+     * and the low-order bits of the first argument..
+     */
+    private static double __HI(double x, int high) {
+        long transX = Double.doubleToRawLongBits(x);
+        return Double.longBitsToDouble((transX & 0x0000_0000_FFFF_FFFFL)|( ((long)high)) << 32 );
+    }
+
+    public static double hypot(double x, double y) {
+        return Hypot.compute(x, y);
+    }
+
+    /**
+     * hypot(x,y)
+     *
+     * Method :
+     *      If (assume round-to-nearest) z = x*x + y*y
+     *      has error less than sqrt(2)/2 ulp, than
+     *      sqrt(z) has error less than 1 ulp (exercise).
+     *
+     *      So, compute sqrt(x*x + y*y) with some care as
+     *      follows to get the error below 1 ulp:
+     *
+     *      Assume x > y > 0;
+     *      (if possible, set rounding to round-to-nearest)
+     *      1. if x > 2y  use
+     *              x1*x1 + (y*y + (x2*(x + x1))) for x*x + y*y
+     *      where x1 = x with lower 32 bits cleared, x2 = x - x1; else
+     *      2. if x <= 2y use
+     *              t1*y1 + ((x-y) * (x-y) + (t1*y2 + t2*y))
+     *      where t1 = 2x with lower 32 bits cleared, t2 = 2x - t1,
+     *      y1= y with lower 32 bits chopped, y2 = y - y1.
+     *
+     *      NOTE: scaling may be necessary if some argument is too
+     *            large or too tiny
+     *
+     * Special cases:
+     *      hypot(x,y) is INF if x or y is +INF or -INF; else
+     *      hypot(x,y) is NAN if x or y is NAN.
+     *
+     * Accuracy:
+     *      hypot(x,y) returns sqrt(x^2 + y^2) with error less
+     *      than 1 ulps (units in the last place)
+     */
+    static class Hypot {
+        public static double compute(double x, double y) {
+            double a = x;
+            double b = y;
+            double t1, t2, y1, y2, w;
+            int j, k, ha, hb;
+
+            ha = __HI(x) & 0x7fffffff;        // high word of  x
+            hb = __HI(y) & 0x7fffffff;        // high word of  y
+            if(hb > ha) {
+                a = y;
+                b = x;
+                j = ha;
+                ha = hb;
+                hb = j;
+            } else {
+                a = x;
+                b = y;
+            }
+            a = __HI(a, ha);   // a <- |a|
+            b = __HI(b, hb);   // b <- |b|
+            if ((ha - hb) > 0x3c00000) {
+                return a + b;  // x / y > 2**60
+            }
+            k=0;
+            if (ha > 0x5f300000) {   // a>2**500
+                if (ha >= 0x7ff00000) {       // Inf or NaN
+                    w = a + b;                // for sNaN
+                    if (((ha & 0xfffff) | __LO(a)) == 0)
+                        w = a;
+                    if (((hb ^ 0x7ff00000) | __LO(b)) == 0)
+                        w = b;
+                    return w;
+                }
+                // scale a and b by 2**-600
+                ha -= 0x25800000;
+                hb -= 0x25800000;
+                k += 600;
+                a = __HI(a, ha);
+                b = __HI(b, hb);
+            }
+            if (hb < 0x20b00000) {   // b < 2**-500
+                if (hb <= 0x000fffff) {      // subnormal b or 0 */
+                    if ((hb | (__LO(b))) == 0)
+                        return a;
+                    t1 = 0;
+                    t1 = __HI(t1, 0x7fd00000);  // t1=2^1022
+                    b *= t1;
+                    a *= t1;
+                    k -= 1022;
+                } else {            // scale a and b by 2^600
+                    ha += 0x25800000;       // a *= 2^600
+                    hb += 0x25800000;       // b *= 2^600
+                    k -= 600;
+                    a = __HI(a, ha);
+                    b = __HI(b, hb);
+                }
+            }
+            // medium size a and b
+            w = a - b;
+            if (w > b) {
+                t1 = 0;
+                t1 = __HI(t1, ha);
+                t2 = a - t1;
+                w  = Math.sqrt(t1*t1 - (b*(-b) - t2 * (a + t1)));
+            } else {
+                a  = a + a;
+                y1 = 0;
+                y1 = __HI(y1, hb);
+                y2 = b - y1;
+                t1 = 0;
+                t1 = __HI(t1, ha + 0x00100000);
+                t2 = a - t1;
+                w  = Math.sqrt(t1*y1 - (w*(-w) - (t1*y2 + t2*b)));
+            }
+            if (k != 0) {
+                t1 = 1.0;
+                int t1_hi = __HI(t1);
+                t1_hi += (k << 20);
+                t1 = __HI(t1, t1_hi);
+                return t1 * w;
+            } else
+                return w;
+        }
+    }
+}
--- a/test/java/lang/StrictMath/HypotTests.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/test/java/lang/StrictMath/HypotTests.java	Mon Oct 12 14:41:36 2015 -0700
@@ -24,10 +24,19 @@
 /*
  * @test
  * @bug 4851638
+ * @key randomness
  * @summary Tests for StrictMath.hypot
+ * @library /lib/testlibrary/
+ * @build jdk.testlibrary.*
+ * @build Tests
+ * @build FdlibmTranslit
+ * @build HypotTests
+ * @run main HypotTests
  * @author Joseph D. Darcy
  */
 
+import jdk.testlibrary.RandomFactory;
+
 /**
  * The tests in ../Math/HypotTests.java test properties that should
  * hold for any hypot implementation, including the FDLIBM-based one
@@ -42,6 +51,19 @@
 public class HypotTests {
     private HypotTests(){}
 
+    public static void main(String... args) {
+        int failures = 0;
+
+        failures += testHypot();
+        failures += testAgainstTranslit();
+
+        if (failures > 0) {
+            System.err.println("Testing hypot incurred "
+                               + failures + " failures.");
+            throw new RuntimeException();
+        }
+    }
+
     /**
      * The hypot implementation is commutative, {@code hypot(a, b) ==
      * hypot(b, a)}, and independent of sign, {@code hypot(a, b) ==
@@ -663,6 +685,12 @@
             {0x1.0p-450,              0x1.fffffffffffffp-499,  0x1.0p-450},
             {0x1.0000000000001p-450,  0x1.fffffffffffffp-499,  0x1.0000000000001p-450},
 
+            {0x1.00000_ffff_0000p500,  0x1.fffffffffffffp499,  0x1.6a09f1b837ccfp500},
+            {0x1.00000_0000_0001p500,  0x1.fffffffffffffp499,  0x1.6a09e667f3bcdp500},
+            {0x1.00000_ffff_ffffp500,  0x1.fffffffffffffp499,  0x1.6a09f1b8431d3p500},
+            {0x1.00001_0000_0000p500,  0x1.fffffffffffffp499,  0x1.6a09f1b8431d5p500},
+
+
             // 0x1.0p-1022 is MIN_NORMAL
             {0x1.0000000000001p-1022, 0x1.0000000000001p-1022, 0x1.6a09e667f3bcep-1022},
             {0x1.0000000000001p-1022, 0x1.0p-1022,             0x1.6a09e667f3bcdp-1022},
@@ -686,15 +714,30 @@
         return failures;
     }
 
-    public static void main(String... args) {
+    // Initialize shared random number generator
+    private static java.util.Random random = RandomFactory.getRandom();
+
+    /**
+     * Test StrictMath.hypot against transliteration port of hypot.
+     */
+    private static int testAgainstTranslit() {
         int failures = 0;
+        double x = Tests.createRandomDouble(random);
+        double y = Tests.createRandomDouble(random);
 
-        failures += testHypot();
+        // Make the increment twice the ulp value in case the random
+        // value is near an exponent threshold.
+        double increment_x = 2.0 * Math.ulp(x);
+        double increment_y = 2.0 * Math.ulp(y);
 
-        if (failures > 0) {
-            System.err.println("Testing hypot incurred "
-                               + failures + " failures.");
-            throw new RuntimeException();
+        // Don't worry about x or y overflowing to infinity if their
+        // exponent is MAX_EXPONENT.
+        for (int i = 0; i < 200; i++, x += increment_x) {
+            for (int j = 0; j < 200; j++, y += increment_y) {
+                failures += testHypotCase(x, y, FdlibmTranslit.hypot(x, y));
+            }
         }
+
+        return failures;
     }
 }
--- a/test/java/lang/StrictMath/Tests.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/test/java/lang/StrictMath/Tests.java	Mon Oct 12 14:41:36 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 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
@@ -60,6 +60,16 @@
             return 0;
     }
 
+    /**
+     * Returns a double over the normalized range of floating-point values.
+     * @return a double over the normalized range of floating-point values
+     */
+    static double createRandomDouble(java.util.Random random) {
+        final int EXPONENT_RANGE = Double.MAX_EXPONENT - Double.MIN_EXPONENT + 1;
 
-
+        int targetExponent = Double.MIN_EXPONENT + random.nextInt(EXPONENT_RANGE + 1);
+        double tmp = random.nextDouble(); // Double in the range of [0.0, 1.0)
+        int tmpExponent = Math.getExponent(tmp);
+        return Math.scalb(tmp, targetExponent - tmpExponent);
+    }
 }
--- a/test/java/rmi/registry/readTest/readTest.sh	Mon Oct 12 16:26:58 2015 +0300
+++ b/test/java/rmi/registry/readTest/readTest.sh	Mon Oct 12 14:41:36 2015 -0700
@@ -27,6 +27,7 @@
 # @build TestLibrary
 # @summary remove java.rmi.server.codebase property parsing from registyimpl
 # @run shell readTest.sh
+# @key intermittent
 
 OS=`uname -s`
 VER=`uname -r`
--- a/test/java/security/PermissionCollection/AddToReadOnlyPermissionCollection.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/test/java/security/PermissionCollection/AddToReadOnlyPermissionCollection.java	Mon Oct 12 14:41:36 2015 -0700
@@ -107,11 +107,11 @@
 
     static void tryFilePC() throws Exception {
         try {
-            FilePermission p0 = new FilePermission("/home/foobar","read");
+            FilePermission p0 = new FilePermission("/tmp/foobar","read");
             PermissionCollection pc = p0.newPermissionCollection();
             pc.setReadOnly();   // this should lock out future adds
             //
-            FilePermission p1 = new FilePermission("/home/quux","read");
+            FilePermission p1 = new FilePermission("/tmp/quux","read");
             pc.add(p1);
             throw new
                 Exception("Failed...FilePermission added to readonly FilePermissionCollection.");
--- a/test/java/security/PermissionCollection/Concurrent.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/test/java/security/PermissionCollection/Concurrent.java	Mon Oct 12 14:41:36 2015 -0700
@@ -166,9 +166,9 @@
         new AllPermission(), new AllPermission()};
 
     private static final Permission[] filep = new Permission[]{
-        new FilePermission("/home/foobar", "read"),
-        new FilePermission("/home/foo", "write"),
-        new FilePermission("/home/foobar", "read,write"),
+        new FilePermission("/tmp/foobar", "read"),
+        new FilePermission("/tmp/foo", "write"),
+        new FilePermission("/tmp/foobar", "read,write"),
             };
 
     private static final Permission[] sockp = new Permission[]{
--- a/test/java/security/PermissionCollection/PermissionCollectionStreamTest.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/test/java/security/PermissionCollection/PermissionCollectionStreamTest.java	Mon Oct 12 14:41:36 2015 -0700
@@ -50,9 +50,9 @@
                 {
                         "FilePermission",
                         new Permission[]{
-                                new FilePermission("/home/foobar", "read"),
-                                new FilePermission("/home/foo", "write"),
-                                new FilePermission("/home/foobar", "read,write"),
+                                new FilePermission("/tmp/foobar", "read"),
+                                new FilePermission("/tmp/foo", "write"),
+                                new FilePermission("/tmp/foobar", "read,write"),
                         }
                 },
         };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/Objects/CheckIndex.java	Mon Oct 12 14:41:36 2015 -0700
@@ -0,0 +1,219 @@
+/*
+ * 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 IndexOutOfBoundsException check index tests
+ * @run testng CheckIndex
+ * @bug 8135248
+ */
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.IntSupplier;
+
+import static org.testng.Assert.*;
+
+public class CheckIndex {
+
+    static class AssertingOutOfBoundsException extends RuntimeException {
+    }
+
+    static BiFunction<Integer, Integer, AssertingOutOfBoundsException> assertingOutOfBounds(
+            int expFromIndex, int expToIndexOrSizeOrLength) {
+        return (fromIndex, toIndexOrSizeorLength) -> {
+            assertEquals(fromIndex, Integer.valueOf(expFromIndex));
+            assertEquals(toIndexOrSizeorLength, Integer.valueOf(expToIndexOrSizeOrLength));
+            return new AssertingOutOfBoundsException();
+        };
+    }
+
+    static final int[] VALUES = {0, 1, Integer.MAX_VALUE - 1, Integer.MAX_VALUE, -1, Integer.MIN_VALUE + 1, Integer.MIN_VALUE};
+
+    @DataProvider
+    static Object[][] checkIndexProvider() {
+        List<Object[]> l = new ArrayList<>();
+        for (int index : VALUES) {
+            for (int length : VALUES) {
+                boolean withinBounds = index >= 0 &&
+                                       length >= 0 &&
+                                       index < length;
+                l.add(new Object[]{index, length, withinBounds});
+            }
+        }
+        return l.toArray(new Object[0][0]);
+    }
+
+    interface X {
+        int apply(int a, int b, int c);
+    }
+
+    @Test(dataProvider = "checkIndexProvider")
+    public void testCheckIndex(int index, int length, boolean withinBounds) {
+        BiConsumer<Class<? extends RuntimeException>, IntSupplier> check = (ec, s) -> {
+            try {
+                int rIndex = s.getAsInt();
+                if (!withinBounds)
+                    fail(String.format(
+                            "Index %d is out of bounds of [0, %d), but was reported to be within bounds", index, length));
+                assertEquals(rIndex, index);
+            }
+            catch (RuntimeException e) {
+                assertTrue(ec.isInstance(e));
+                if (withinBounds)
+                    fail(String.format(
+                            "Index %d is within bounds of [0, %d), but was reported to be out of bounds", index, length));
+            }
+        };
+
+        check.accept(AssertingOutOfBoundsException.class,
+                     () -> Objects.checkIndex(index, length, assertingOutOfBounds(index, length)));
+        check.accept(IndexOutOfBoundsException.class,
+                     () -> Objects.checkIndex(index, length, null));
+        check.accept(IndexOutOfBoundsException.class,
+                     () -> Objects.checkIndex(index, length));
+    }
+
+
+    @DataProvider
+    static Object[][] checkFromToIndexProvider() {
+        List<Object[]> l = new ArrayList<>();
+        for (int fromIndex : VALUES) {
+            for (int toIndex : VALUES) {
+                for (int length : VALUES) {
+                    boolean withinBounds = fromIndex >= 0 &&
+                                           toIndex >= 0 &&
+                                           length >= 0 &&
+                                           fromIndex <= toIndex &&
+                                           toIndex <= length;
+                    l.add(new Object[]{fromIndex, toIndex, length, withinBounds});
+                }
+            }
+        }
+        return l.toArray(new Object[0][0]);
+    }
+
+    @Test(dataProvider = "checkFromToIndexProvider")
+    public void testCheckFromToIndex(int fromIndex, int toIndex, int length, boolean withinBounds) {
+        BiConsumer<Class<? extends RuntimeException>, IntSupplier> check = (ec, s) -> {
+            try {
+                int rIndex = s.getAsInt();
+                if (!withinBounds)
+                    fail(String.format(
+                            "Range [%d, %d) is out of bounds of [0, %d), but was reported to be withing bounds", fromIndex, toIndex, length));
+                assertEquals(rIndex, fromIndex);
+            }
+            catch (RuntimeException e) {
+                assertTrue(ec.isInstance(e));
+                if (withinBounds)
+                    fail(String.format(
+                            "Range [%d, %d) is within bounds of [0, %d), but was reported to be out of bounds", fromIndex, toIndex, length));
+            }
+        };
+
+        check.accept(AssertingOutOfBoundsException.class,
+                     () -> Objects.checkFromToIndex(fromIndex, toIndex, length, assertingOutOfBounds(fromIndex, toIndex)));
+        check.accept(IndexOutOfBoundsException.class,
+                     () -> Objects.checkFromToIndex(fromIndex, toIndex, length, null));
+        check.accept(IndexOutOfBoundsException.class,
+                     () -> Objects.checkFromToIndex(fromIndex, toIndex, length));
+    }
+
+
+    @DataProvider
+    static Object[][] checkFromIndexSizeProvider() {
+        List<Object[]> l = new ArrayList<>();
+        for (int fromIndex : VALUES) {
+            for (int size : VALUES) {
+                for (int length : VALUES) {
+                    // Explicitly convert to long
+                    long lFromIndex = fromIndex;
+                    long lSize = size;
+                    long lLength = length;
+                    // Avoid overflow
+                    long lToIndex = lFromIndex + lSize;
+
+                    boolean withinBounds = lFromIndex >= 0L &&
+                                           lSize >= 0L &&
+                                           lLength >= 0L &&
+                                           lFromIndex <= lToIndex &&
+                                           lToIndex <= lLength;
+                    l.add(new Object[]{fromIndex, size, length, withinBounds});
+                }
+            }
+        }
+        return l.toArray(new Object[0][0]);
+    }
+
+    @Test(dataProvider = "checkFromIndexSizeProvider")
+    public void testCheckFromIndexSize(int fromIndex, int size, int length, boolean withinBounds) {
+        BiConsumer<Class<? extends RuntimeException>, IntSupplier> check = (ec, s) -> {
+            try {
+                int rIndex = s.getAsInt();
+                if (!withinBounds)
+                    fail(String.format(
+                            "Range [%d, %d + %d) is out of bounds of [0, %d), but was reported to be withing bounds", fromIndex, fromIndex, size, length));
+                assertEquals(rIndex, fromIndex);
+            }
+            catch (RuntimeException e) {
+                assertTrue(ec.isInstance(e));
+                if (withinBounds)
+                    fail(String.format(
+                            "Range [%d, %d + %d) is within bounds of [0, %d), but was reported to be out of bounds", fromIndex, fromIndex, size, length));
+            }
+        };
+
+        check.accept(AssertingOutOfBoundsException.class,
+                     () -> Objects.checkFromIndexSize(fromIndex, size, length, assertingOutOfBounds(fromIndex, size)));
+        check.accept(IndexOutOfBoundsException.class,
+                     () -> Objects.checkFromIndexSize(fromIndex, size, length, null));
+        check.accept(IndexOutOfBoundsException.class,
+                     () -> Objects.checkFromIndexSize(fromIndex, size, length));
+    }
+
+    @Test
+    public void checkIndexOutOfBoundsExceptionConstructors() {
+        BiConsumer<Class<? extends RuntimeException>, IntSupplier> check = (ec, s) -> {
+            try {
+                s.getAsInt();
+                fail("Runtime exception expected");
+            }
+            catch (RuntimeException e) {
+                assertTrue(ec.isInstance(e));
+            }
+        };
+
+        check.accept(IndexOutOfBoundsException.class,
+                     () -> Objects.checkIndex(1, 0, IndexOutOfBoundsException::new));
+        check.accept(StringIndexOutOfBoundsException.class,
+                     () -> Objects.checkIndex(1, 0, StringIndexOutOfBoundsException::new));
+        check.accept(ArrayIndexOutOfBoundsException.class,
+                     () -> Objects.checkIndex(1, 0, ArrayIndexOutOfBoundsException::new));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexResetUpdate.java	Mon Oct 12 14:41:36 2015 -0700
@@ -0,0 +1,548 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FilePermission;
+import java.io.IOException;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.logging.FileHandler;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import java.util.logging.LoggingPermission;
+
+/**
+ * @test
+ * @bug 8033661
+ * @summary tests that FileHandlers configured on abstract nodes in logging.properties
+ *          will be closed on reset and reopened on updateConfiguration().
+ *          Test a complex reconfiguration where a logger with handlers
+ *          suddenly appears in the hierarchy between a child logger and the
+ *          root logger.
+ * @run main/othervm HandlersOnComplexResetUpdate UNSECURE
+ * @run main/othervm HandlersOnComplexResetUpdate SECURE
+ * @author danielfuchs
+ */
+public class HandlersOnComplexResetUpdate {
+
+    /**
+     * We will test the handling of abstract logger nodes with file handlers in
+     * two configurations:
+     * UNSECURE: No security manager.
+     * SECURE: With the security manager present - and the required
+     *         permissions granted.
+     */
+    public static enum TestCase {
+        UNSECURE, SECURE;
+        public void run(List<Properties> properties) throws Exception {
+            System.out.println("Running test case: " + name());
+            Configure.setUp(this, properties.get(0));
+            test(this.name(), properties);
+        }
+    }
+
+
+    private static final String PREFIX =
+            "FileHandler-" + UUID.randomUUID() + ".log";
+    private static final String userDir = System.getProperty("user.dir", ".");
+    private static final boolean userDirWritable = Files.isWritable(Paths.get(userDir));
+
+    private static final List<Properties> properties;
+    static {
+        // The test will call reset() and updateConfiguration() with each of these
+        // properties in sequence. The child logger is not released between each
+        // configuration. What is interesting here is mostly what happens between
+        // props4 and props5:
+        //
+        // In step 4 (props4) the configuration defines a handler for the
+        // logger com.foo (the direct parent of com.foo.child - which is the
+        // logger we hold on to).
+        //
+        // In step 5 (props5) the configuration has nothing concerning
+        // 'com.foo', but the handler has been migrated to 'com'.
+        // Since there doesn't exist any logger for 'com' (the previous
+        // configuration didn't have any configuration for 'com'), then
+        // 'com' will not be found when we process the existing loggers named
+        // in the configuration.
+        //
+        // So if we didn't also process the existing loggers not named in the
+        // configuration (such as com.foo.child) then no logger for 'com'
+        // would be created, which means that com.foo.child would not be
+        // able to inherit its configuration for 'com' until someone explicitely
+        // creates a logger for 'com'.
+        //
+        // This test check that a logger for 'com' will be created because
+        // 'com.foo.child' still exists when updateConfiguration() is called.
+
+        Properties props1 = new Properties();
+        props1.setProperty("test.name", "parent logger with handler");
+        props1.setProperty(FileHandler.class.getName() + ".pattern", PREFIX);
+        props1.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE));
+        props1.setProperty(FileHandler.class.getName() + ".level", "ALL");
+        props1.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter");
+        props1.setProperty("com.foo.handlers", FileHandler.class.getName());
+        props1.setProperty("test.checkHandlersOnParent", "true");
+        props1.setProperty("test.checkHandlersOn", "com.foo");
+        props1.setProperty("com.bar.level", "FINEST");
+
+        Properties props2 = new Properties();
+        props2.setProperty("java.util.logging.LogManager.reconfigureHandlers", "true");
+        props2.setProperty(FileHandler.class.getName() + ".pattern", PREFIX);
+        props2.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE));
+        props2.setProperty(FileHandler.class.getName() + ".level", "ALL");
+        props2.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter");
+        props2.setProperty("com.foo.handlers", FileHandler.class.getName());
+        props2.setProperty("test.checkHandlersOnParent", "true");
+        props2.setProperty("test.checkHandlersOn", "com.foo");
+        props2.setProperty("com.bar.level", "FINEST");
+
+        Properties props3 = new Properties();
+        props3.setProperty("test.name", "parent logger with handler");
+        props3.setProperty(FileHandler.class.getName() + ".pattern", PREFIX);
+        props3.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE));
+        props3.setProperty(FileHandler.class.getName() + ".level", "ALL");
+        props3.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter");
+        props3.setProperty("com.foo.handlers", FileHandler.class.getName());
+        props3.setProperty("test.checkHandlersOnParent", "true");
+        props3.setProperty("test.checkHandlersOn", "com.foo");
+        props3.setProperty("com.bar.level", "FINEST");
+
+        Properties props4 = new Properties();
+        props4.setProperty("java.util.logging.LogManager.reconfigureHandlers", "true");
+        props4.setProperty(FileHandler.class.getName() + ".pattern", PREFIX);
+        props4.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE));
+        props4.setProperty(FileHandler.class.getName() + ".level", "ALL");
+        props4.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter");
+        props4.setProperty("test.checkHandlersOnParent", "true");
+        props4.setProperty("test.checkHandlersOn", "com.foo");
+        props4.setProperty("com.foo.handlers", FileHandler.class.getName());
+
+        Properties props5 = new Properties();
+        props5.setProperty("test.name", "parent logger with handler");
+        props5.setProperty(FileHandler.class.getName() + ".pattern", PREFIX);
+        props5.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE));
+        props5.setProperty(FileHandler.class.getName() + ".level", "ALL");
+        props5.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter");
+        props5.setProperty("test.checkHandlersOnParent", "false");
+        props5.setProperty("test.checkHandlersOn", "com");
+        props5.setProperty("com.handlers", FileHandler.class.getName());
+
+        properties = Collections.unmodifiableList(Arrays.asList(
+                    props1, props2, props3, props4, props5));
+    }
+
+    /**
+     * This is the main test method. The rest is infrastructure.
+     * Creates a child of the 'com.foo' logger (com.foo.child) and holds on to
+     * it.
+     * <p>
+     * Then applies all given configurations in sequence and verifies assumptions
+     * about the handlers that com.foo should have, or not have.
+     * In the last configuration (props5) it also verifies that the
+     * logger 'com' has been created and has now the expected handler.
+     * <p>
+     * Finally releases the child logger after all configurations have been
+     * applied.
+     *
+     * @param name
+     * @param properties
+     * @throws Exception
+     */
+    static void test(String name, List<Properties> properties)
+            throws Exception {
+
+        System.out.println("\nTesting: " + name);
+        if (!userDirWritable) {
+            throw new RuntimeException("Not writable: "+userDir);
+        }
+
+        // Then create a child of the com.foo logger.
+        Logger fooChild = Logger.getLogger("com.foo.child");
+        fooChild.info("hello world");
+        Logger barChild = Logger.getLogger("com.bar.child");
+        barChild.info("hello world");
+
+        ReferenceQueue<Logger> queue = new ReferenceQueue();
+        WeakReference<Logger> fooRef = new WeakReference<>(Logger.getLogger("com.foo"), queue);
+        if (fooRef.get() != fooChild.getParent()) {
+            throw new RuntimeException("Unexpected parent logger: "
+                    + fooChild.getParent() +"\n\texpected: " + fooRef.get());
+        }
+        WeakReference<Logger> barRef = new WeakReference<>(Logger.getLogger("com.bar"), queue);
+        if (barRef.get() != barChild.getParent()) {
+            throw new RuntimeException("Unexpected parent logger: "
+                    + barChild.getParent() +"\n\texpected: " + barRef.get());
+        }
+        Reference<? extends Logger> ref2;
+        int max = 3;
+        barChild = null;
+        while ((ref2 = queue.poll()) == null) {
+            System.gc();
+            Thread.sleep(100);
+            if (--max == 0) break;
+        }
+
+        Throwable failed = null;
+        try {
+            if (ref2 != null) {
+                String refName = ref2 == fooRef ? "fooRef" : ref2 == barRef ? "barRef" : "unknown";
+                if (ref2 != barRef) {
+                    throw new RuntimeException("Unexpected logger reference cleared: " + refName);
+                } else {
+                    System.out.println("Reference " + refName + " cleared as expected");
+                }
+            } else if (ref2 == null) {
+                throw new RuntimeException("Expected 'barRef' to be cleared");
+            }
+            // Now lets try to reset, check that ref2 has no handlers, and
+            // attempt to configure again.
+            Properties previousProps  = properties.get(0);
+            int expectedHandlersCount = 1;
+            boolean checkHandlersOnParent = Boolean.parseBoolean(
+                    previousProps.getProperty("test.checkHandlersOnParent", "true"));
+            String checkHandlersOn = previousProps.getProperty("test.checkHandlersOn", null);
+            for (int i=1; i<properties.size(); i++) {
+                System.out.println("\n*** Reconfiguration with properties["+i+"]\n");
+                Properties nextProps = properties.get(i);
+                boolean reconfigureHandlers = true;
+
+                if (checkHandlersOnParent) {
+                    assertEquals(expectedHandlersCount,
+                            fooChild.getParent().getHandlers().length,
+                            "fooChild.getParent().getHandlers().length");
+                }
+                if (checkHandlersOn != null) {
+                    Logger loggerWithHandlers = LogManager.getLogManager().getLogger(checkHandlersOn);
+                    if (loggerWithHandlers == null) {
+                        throw new RuntimeException("Logger with handlers not found: " + checkHandlersOn);
+                    }
+                    assertEquals(expectedHandlersCount,
+                            loggerWithHandlers.getHandlers().length,
+                            checkHandlersOn + ".getHandlers().length");
+                }
+
+                // Reset
+                Configure.doPrivileged(() -> LogManager.getLogManager().reset());
+                assertEquals(0, fooChild.getParent().getHandlers().length, "fooChild.getParent().getHandlers().length");
+                if (checkHandlersOn != null) {
+                    Logger loggerWithHandlers = LogManager.getLogManager().getLogger(checkHandlersOn);
+                    if (loggerWithHandlers == null) {
+                        throw new RuntimeException("Logger with handlers not found: " + checkHandlersOn);
+                    }
+                    assertEquals(0, loggerWithHandlers.getHandlers().length,
+                            checkHandlersOn + ".getHandlers().length");
+                }
+
+                if (i == 4) {
+                    System.out.println("Last configuration...");
+                }
+                // Read configuration
+                Configure.doPrivileged(() -> Configure.updateConfigurationWith(nextProps, false));
+
+                expectedHandlersCount = reconfigureHandlers ? 1 : 0;
+                checkHandlersOnParent = Boolean.parseBoolean(
+                    nextProps.getProperty("test.checkHandlersOnParent", "true"));
+                checkHandlersOn = nextProps.getProperty("test.checkHandlersOn", null);
+
+                if (checkHandlersOnParent) {
+                    assertEquals(expectedHandlersCount,
+                        fooChild.getParent().getHandlers().length,
+                        "fooChild.getParent().getHandlers().length");
+                } else {
+                    assertEquals(0,
+                        fooChild.getParent().getHandlers().length,
+                        "fooChild.getParent().getHandlers().length");
+                }
+                if (checkHandlersOn != null) {
+                    Logger loggerWithHandlers = LogManager.getLogManager().getLogger(checkHandlersOn);
+                    if (loggerWithHandlers == null) {
+                        throw new RuntimeException("Logger with handlers not found: " + checkHandlersOn);
+                    }
+                    assertEquals(expectedHandlersCount,
+                            loggerWithHandlers.getHandlers().length,
+                            checkHandlersOn + ".getHandlers().length");
+                }
+            }
+        } catch (Throwable t) {
+            failed = t;
+        } finally {
+            final Throwable suppressed = failed;
+            Configure.doPrivileged(() -> LogManager.getLogManager().reset());
+            Configure.doPrivileged(() -> {
+                try {
+                    StringBuilder builder = new StringBuilder();
+                    Files.list(Paths.get(userDir))
+                        .filter((f) -> f.toString().contains(PREFIX))
+                        .filter((f) -> f.toString().endsWith(".lck"))
+                        .forEach((f) -> {
+                                builder.append(f.toString()).append('\n');
+                        });
+                    if (!builder.toString().isEmpty()) {
+                        throw new RuntimeException("Lock files not cleaned:\n"
+                                + builder.toString());
+                    }
+                } catch(RuntimeException | Error x) {
+                    if (suppressed != null) x.addSuppressed(suppressed);
+                    throw x;
+                } catch(Exception x) {
+                    if (suppressed != null) x.addSuppressed(suppressed);
+                    throw new RuntimeException(x);
+                }
+            });
+            fooChild = null;
+            System.out.println("Setting fooChild to: " + fooChild);
+            while ((ref2 = queue.poll()) == null) {
+                System.gc();
+                Thread.sleep(1000);
+            }
+            if (ref2 != fooRef) {
+                throw new RuntimeException("Unexpected reference: "
+                        + ref2 +"\n\texpected: " + fooRef);
+            }
+            if (ref2.get() != null) {
+                throw new RuntimeException("Referent not cleared: " + ref2.get());
+            }
+            System.out.println("Got fooRef after reset(), fooChild is " + fooChild);
+
+        }
+        if (failed != null) {
+            // should rarely happen...
+            throw new RuntimeException(failed);
+        }
+
+    }
+
+    public static void main(String... args) throws Exception {
+
+
+        if (args == null || args.length == 0) {
+            args = new String[] {
+                TestCase.UNSECURE.name(),
+                TestCase.SECURE.name(),
+            };
+        }
+
+        try {
+            for (String testName : args) {
+                TestCase test = TestCase.valueOf(testName);
+                test.run(properties);
+            }
+        } finally {
+            if (userDirWritable) {
+                Configure.doPrivileged(() -> {
+                    // cleanup - delete files that have been created
+                    try {
+                        Files.list(Paths.get(userDir))
+                            .filter((f) -> f.toString().contains(PREFIX))
+                            .forEach((f) -> {
+                                try {
+                                    System.out.println("deleting " + f);
+                                    Files.delete(f);
+                                } catch(Throwable t) {
+                                    System.err.println("Failed to delete " + f + ": " + t);
+                                }
+                            });
+                    } catch(Throwable t) {
+                        System.err.println("Cleanup failed to list files: " + t);
+                        t.printStackTrace();
+                    }
+                });
+            }
+        }
+    }
+
+    static class Configure {
+        static Policy policy = null;
+        static final ThreadLocal<AtomicBoolean> allowAll = new ThreadLocal<AtomicBoolean>() {
+            @Override
+            protected AtomicBoolean initialValue() {
+                return  new AtomicBoolean(false);
+            }
+        };
+        static void setUp(TestCase test, Properties propertyFile) {
+            switch (test) {
+                case SECURE:
+                    if (policy == null && System.getSecurityManager() != null) {
+                        throw new IllegalStateException("SecurityManager already set");
+                    } else if (policy == null) {
+                        policy = new SimplePolicy(TestCase.SECURE, allowAll);
+                        Policy.setPolicy(policy);
+                        System.setSecurityManager(new SecurityManager());
+                    }
+                    if (System.getSecurityManager() == null) {
+                        throw new IllegalStateException("No SecurityManager.");
+                    }
+                    if (policy == null) {
+                        throw new IllegalStateException("policy not configured");
+                    }
+                    break;
+                case UNSECURE:
+                    if (System.getSecurityManager() != null) {
+                        throw new IllegalStateException("SecurityManager already set");
+                    }
+                    break;
+                default:
+                    new InternalError("No such testcase: " + test);
+            }
+            doPrivileged(() -> {
+                updateConfigurationWith(propertyFile, false);
+            });
+        }
+
+        static void updateConfigurationWith(Properties propertyFile, boolean append) {
+            try {
+                ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+                propertyFile.store(bytes, propertyFile.getProperty("test.name"));
+                ByteArrayInputStream bais = new ByteArrayInputStream(bytes.toByteArray());
+                Function<String, BiFunction<String,String,String>> remapper =
+                        append ? (x) -> ((o, n) -> n == null ? o : n)
+                               : (x) -> ((o, n) -> n);
+                LogManager.getLogManager().updateConfiguration(bais, remapper);
+            } catch (IOException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+
+        static void doPrivileged(Runnable run) {
+            final boolean old = allowAll.get().getAndSet(true);
+            try {
+                run.run();
+            } finally {
+                allowAll.get().set(old);
+            }
+        }
+        static <T> T callPrivileged(Callable<T> call) throws Exception {
+            final boolean old = allowAll.get().getAndSet(true);
+            try {
+                return call.call();
+            } finally {
+                allowAll.get().set(old);
+            }
+        }
+    }
+
+    @FunctionalInterface
+    public static interface FileHandlerSupplier {
+        public FileHandler test() throws Exception;
+    }
+
+    static final class TestAssertException extends RuntimeException {
+        TestAssertException(String msg) {
+            super(msg);
+        }
+    }
+
+    private static void assertEquals(long expected, long received, String msg) {
+        if (expected != received) {
+            throw new TestAssertException("Unexpected result for " + msg
+                    + ".\n\texpected: " + expected
+                    +  "\n\tactual:   " + received);
+        } else {
+            System.out.println("Got expected " + msg + ": " + received);
+        }
+    }
+
+    final static class PermissionsBuilder {
+        final Permissions perms;
+        public PermissionsBuilder() {
+            this(new Permissions());
+        }
+        public PermissionsBuilder(Permissions perms) {
+            this.perms = perms;
+        }
+        public PermissionsBuilder add(Permission p) {
+            perms.add(p);
+            return this;
+        }
+        public PermissionsBuilder addAll(PermissionCollection col) {
+            if (col != null) {
+                for (Enumeration<Permission> e = col.elements(); e.hasMoreElements(); ) {
+                    perms.add(e.nextElement());
+                }
+            }
+            return this;
+        }
+        public Permissions toPermissions() {
+            final PermissionsBuilder builder = new PermissionsBuilder();
+            builder.addAll(perms);
+            return builder.perms;
+        }
+    }
+
+    public static class SimplePolicy extends Policy {
+
+        final Permissions permissions;
+        final Permissions allPermissions;
+        final ThreadLocal<AtomicBoolean> allowAll; // actually: this should be in a thread locale
+        public SimplePolicy(TestCase test, ThreadLocal<AtomicBoolean> allowAll) {
+            this.allowAll = allowAll;
+            permissions = new Permissions();
+            permissions.add(new LoggingPermission("control", null));
+            permissions.add(new FilePermission(PREFIX+".lck", "read,write,delete"));
+            permissions.add(new FilePermission(PREFIX, "read,write"));
+
+            // these are used for configuring the test itself...
+            allPermissions = new Permissions();
+            allPermissions.add(new java.security.AllPermission());
+
+        }
+
+        @Override
+        public boolean implies(ProtectionDomain domain, Permission permission) {
+            if (allowAll.get().get()) return allPermissions.implies(permission);
+            return permissions.implies(permission);
+        }
+
+        @Override
+        public PermissionCollection getPermissions(CodeSource codesource) {
+            return new PermissionsBuilder().addAll(allowAll.get().get()
+                    ? allPermissions : permissions).toPermissions();
+        }
+
+        @Override
+        public PermissionCollection getPermissions(ProtectionDomain domain) {
+            return new PermissionsBuilder().addAll(allowAll.get().get()
+                    ? allPermissions : permissions).toPermissions();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexUpdate.java	Mon Oct 12 14:41:36 2015 -0700
@@ -0,0 +1,547 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FilePermission;
+import java.io.IOException;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.logging.FileHandler;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import java.util.logging.LoggingPermission;
+
+/**
+ * @test
+ * @bug 8033661
+ * @summary tests that FileHandlers configured on abstract nodes in logging.properties
+ *          will be properly closed and reopened on updateConfiguration().
+ *          Test a complex reconfiguration where a logger with handlers
+ *          suddenly appears in the hierarchy between a child logger and the
+ *          root logger.
+ * @run main/othervm HandlersOnComplexUpdate UNSECURE
+ * @run main/othervm HandlersOnComplexUpdate SECURE
+ * @author danielfuchs
+ */
+public class HandlersOnComplexUpdate {
+
+    /**
+     * We will test the handling of abstract logger nodes with file handlers in
+     * two configurations:
+     * UNSECURE: No security manager.
+     * SECURE: With the security manager present - and the required
+     *         permissions granted.
+     */
+    public static enum TestCase {
+        UNSECURE, SECURE;
+        public void run(List<Properties> properties) throws Exception {
+            System.out.println("Running test case: " + name());
+            Configure.setUp(this, properties.get(0));
+            test(this.name(), properties);
+        }
+    }
+
+
+    private static final String PREFIX =
+            "FileHandler-" + UUID.randomUUID() + ".log";
+    private static final String userDir = System.getProperty("user.dir", ".");
+    private static final boolean userDirWritable = Files.isWritable(Paths.get(userDir));
+
+    private static final List<Properties> properties;
+    static {
+        // The test will call updateConfiguration() with each of these
+        // properties in sequence. The child logger is not released between each
+        // configuration. What is interesting here is mostly what happens between
+        // props4 and props5:
+        //
+        // In step 4 (props4) the configuration defines a handler for the
+        // logger com.foo (the direct parent of com.foo.child - which is the
+        // logger we hold on to).
+        //
+        // In step 5 (props5) the configuration has nothing concerning
+        // 'com.foo', but the handler has been migrated to 'com'.
+        // Since there doesn't exist any logger for 'com' (the previous
+        // configuration didn't have any configuration for 'com'), then
+        // 'com' will not be found when we process the existing loggers named
+        // in the configuration.
+        //
+        // So if we didn't also process the existing loggers not named in the
+        // configuration (such as com.foo.child) then no logger for 'com'
+        // would be created, which means that com.foo.child would not be
+        // able to inherit its configuration for 'com' until someone explicitely
+        // creates a logger for 'com'.
+        //
+        // This test check that a logger for 'com' will be created because
+        // 'com.foo.child' still exists when updateConfiguration() is called.
+
+        Properties props1 = new Properties();
+        props1.setProperty("test.name", "parent logger with handler");
+        props1.setProperty(FileHandler.class.getName() + ".pattern", PREFIX);
+        props1.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE));
+        props1.setProperty(FileHandler.class.getName() + ".level", "ALL");
+        props1.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter");
+        props1.setProperty("com.foo.handlers", FileHandler.class.getName());
+        props1.setProperty("test.checkHandlersOnParent", "true");
+        props1.setProperty("test.checkHandlersOn", "com.foo");
+        props1.setProperty("com.bar.level", "FINEST");
+
+        Properties props2 = new Properties();
+        props2.setProperty("test.name", "parent logger with handler");
+        props2.setProperty(FileHandler.class.getName() + ".pattern", PREFIX);
+        props2.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE));
+        props2.setProperty(FileHandler.class.getName() + ".level", "ALL");
+        props2.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter");
+        props2.setProperty("com.foo.handlers", FileHandler.class.getName());
+        props2.setProperty("test.checkHandlersOnParent", "true");
+        props2.setProperty("test.checkHandlersOn", "com.foo");
+        props2.setProperty("com.bar.level", "FINEST");
+
+        Properties props3 = new Properties();
+        props3.setProperty("test.name", "parent logger with handler");
+        props3.setProperty(FileHandler.class.getName() + ".pattern", PREFIX);
+        props3.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE));
+        props3.setProperty(FileHandler.class.getName() + ".level", "ALL");
+        props3.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter");
+        props3.setProperty("com.foo.handlers", FileHandler.class.getName());
+        props3.setProperty("test.checkHandlersOnParent", "true");
+        props3.setProperty("test.checkHandlersOn", "com.foo");
+        props3.setProperty("com.bar.level", "FINEST");
+
+        Properties props4 = new Properties();
+        props4.setProperty("test.name", "parent logger with handler");
+        props4.setProperty(FileHandler.class.getName() + ".pattern", PREFIX);
+        props4.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE));
+        props4.setProperty(FileHandler.class.getName() + ".level", "ALL");
+        props4.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter");
+        props4.setProperty("test.checkHandlersOnParent", "true");
+        props4.setProperty("test.checkHandlersOn", "com.foo");
+        props4.setProperty("com.foo.handlers", FileHandler.class.getName());
+
+        Properties props5 = new Properties();
+        props5.setProperty("test.name", "parent logger with handler");
+        props5.setProperty(FileHandler.class.getName() + ".pattern", PREFIX);
+        props5.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE));
+        props5.setProperty(FileHandler.class.getName() + ".level", "ALL");
+        props5.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter");
+        props5.setProperty("test.checkHandlersOnParent", "false");
+        props5.setProperty("test.checkHandlersOn", "com");
+        props5.setProperty("com.handlers", FileHandler.class.getName());
+
+        properties = Collections.unmodifiableList(Arrays.asList(
+                    props1, props2, props3, props4, props5));
+    }
+
+    /**
+     * This is the main test method. The rest is infrastructure.
+     * Creates a child of the 'com.foo' logger (com.foo.child) and holds on to
+     * it.
+     * <p>
+     * Then applies all given configurations in sequence and verifies assumptions
+     * about the handlers that com.foo should have, or not have.
+     * In the last configuration (props5) it also verifies that the
+     * logger 'com' has been created and has now the expected handler.
+     * <p>
+     * Finally releases the child logger after all configurations have been
+     * applied.
+     *
+     * @param name
+     * @param properties
+     * @throws Exception
+     */
+    static void test(String name, List<Properties> properties)
+            throws Exception {
+
+        System.out.println("\nTesting: " + name);
+        if (!userDirWritable) {
+            throw new RuntimeException("Not writable: "+userDir);
+        }
+
+        // Then create a child of the com.foo logger.
+        Logger fooChild = Logger.getLogger("com.foo.child");
+        fooChild.info("hello world");
+        Logger barChild = Logger.getLogger("com.bar.child");
+        barChild.info("hello world");
+
+        ReferenceQueue<Logger> queue = new ReferenceQueue();
+        WeakReference<Logger> fooRef = new WeakReference<>(Logger.getLogger("com.foo"), queue);
+        if (fooRef.get() != fooChild.getParent()) {
+            throw new RuntimeException("Unexpected parent logger: "
+                    + fooChild.getParent() +"\n\texpected: " + fooRef.get());
+        }
+        WeakReference<Logger> barRef = new WeakReference<>(Logger.getLogger("com.bar"), queue);
+        if (barRef.get() != barChild.getParent()) {
+            throw new RuntimeException("Unexpected parent logger: "
+                    + barChild.getParent() +"\n\texpected: " + barRef.get());
+        }
+        Reference<? extends Logger> ref2;
+        int max = 3;
+        barChild = null;
+        while ((ref2 = queue.poll()) == null) {
+            System.gc();
+            Thread.sleep(100);
+            if (--max == 0) break;
+        }
+
+        Throwable failed = null;
+        try {
+            if (ref2 != null) {
+                String refName = ref2 == fooRef ? "fooRef" : ref2 == barRef ? "barRef" : "unknown";
+                if (ref2 != barRef) {
+                    throw new RuntimeException("Unexpected logger reference cleared: " + refName);
+                } else {
+                    System.out.println("Reference " + refName + " cleared as expected");
+                }
+            } else if (ref2 == null) {
+                throw new RuntimeException("Expected 'barRef' to be cleared");
+            }
+            // Now lets try to check handlers, and
+            // attempt to update the configuration again.
+            Properties previousProps  = properties.get(0);
+            int expectedHandlersCount = 1;
+            boolean checkHandlersOnParent = Boolean.parseBoolean(
+                    previousProps.getProperty("test.checkHandlersOnParent", "true"));
+            String checkHandlersOn = previousProps.getProperty("test.checkHandlersOn", null);
+            for (int i=1; i<properties.size(); i++) {
+                System.out.println("\n*** Reconfiguration with properties["+i+"]\n");
+                Properties nextProps = properties.get(i);
+                boolean reconfigureHandlers = true;
+
+                if (checkHandlersOnParent) {
+                    assertEquals(expectedHandlersCount,
+                            fooChild.getParent().getHandlers().length,
+                            "fooChild.getParent().getHandlers().length");
+                }
+                if (checkHandlersOn != null) {
+                    Logger loggerWithHandlers = LogManager.getLogManager().getLogger(checkHandlersOn);
+                    if (loggerWithHandlers == null) {
+                        throw new RuntimeException("Logger with handlers not found: " + checkHandlersOn);
+                    }
+                    assertEquals(expectedHandlersCount,
+                            loggerWithHandlers.getHandlers().length,
+                            checkHandlersOn + ".getHandlers().length");
+                }
+
+                if (i == 4) {
+                    System.out.println("Last configuration...");
+                }
+                // Read configuration
+                Configure.doPrivileged(() -> Configure.updateConfigurationWith(nextProps, false));
+
+                expectedHandlersCount = reconfigureHandlers ? 1 : 0;
+                checkHandlersOnParent = Boolean.parseBoolean(
+                    nextProps.getProperty("test.checkHandlersOnParent", "true"));
+                checkHandlersOn = nextProps.getProperty("test.checkHandlersOn", null);
+
+                if (checkHandlersOnParent) {
+                    assertEquals(expectedHandlersCount,
+                        fooChild.getParent().getHandlers().length,
+                        "fooChild.getParent().getHandlers().length");
+                } else {
+                    assertEquals(0,
+                        fooChild.getParent().getHandlers().length,
+                        "fooChild.getParent().getHandlers().length");
+                }
+                if (checkHandlersOn != null) {
+                    Logger loggerWithHandlers = LogManager.getLogManager().getLogger(checkHandlersOn);
+                    if (loggerWithHandlers == null) {
+                        throw new RuntimeException("Logger with handlers not found: " + checkHandlersOn);
+                    }
+                    assertEquals(expectedHandlersCount,
+                            loggerWithHandlers.getHandlers().length,
+                            checkHandlersOn + ".getHandlers().length");
+                }
+            }
+        } catch (Throwable t) {
+            failed = t;
+        } finally {
+            final Throwable suppressed = failed;
+            Configure.doPrivileged(() -> LogManager.getLogManager().reset());
+            Configure.doPrivileged(() -> {
+                try {
+                    StringBuilder builder = new StringBuilder();
+                    Files.list(Paths.get(userDir))
+                        .filter((f) -> f.toString().contains(PREFIX))
+                        .filter((f) -> f.toString().endsWith(".lck"))
+                        .forEach((f) -> {
+                                builder.append(f.toString()).append('\n');
+                        });
+                    if (!builder.toString().isEmpty()) {
+                        throw new RuntimeException("Lock files not cleaned:\n"
+                                + builder.toString());
+                    }
+                } catch(RuntimeException | Error x) {
+                    if (suppressed != null) x.addSuppressed(suppressed);
+                    throw x;
+                } catch(Exception x) {
+                    if (suppressed != null) x.addSuppressed(suppressed);
+                    throw new RuntimeException(x);
+                }
+            });
+            fooChild = null;
+            System.out.println("Setting fooChild to: " + fooChild);
+            while ((ref2 = queue.poll()) == null) {
+                System.gc();
+                Thread.sleep(1000);
+            }
+            if (ref2 != fooRef) {
+                throw new RuntimeException("Unexpected reference: "
+                        + ref2 +"\n\texpected: " + fooRef);
+            }
+            if (ref2.get() != null) {
+                throw new RuntimeException("Referent not cleared: " + ref2.get());
+            }
+            System.out.println("Got fooRef after reset(), fooChild is " + fooChild);
+
+        }
+        if (failed != null) {
+            // should rarely happen...
+            throw new RuntimeException(failed);
+        }
+
+    }
+
+    public static void main(String... args) throws Exception {
+
+
+        if (args == null || args.length == 0) {
+            args = new String[] {
+                TestCase.UNSECURE.name(),
+                TestCase.SECURE.name(),
+            };
+        }
+
+        try {
+            for (String testName : args) {
+                TestCase test = TestCase.valueOf(testName);
+                test.run(properties);
+            }
+        } finally {
+            if (userDirWritable) {
+                Configure.doPrivileged(() -> {
+                    // cleanup - delete files that have been created
+                    try {
+                        Files.list(Paths.get(userDir))
+                            .filter((f) -> f.toString().contains(PREFIX))
+                            .forEach((f) -> {
+                                try {
+                                    System.out.println("deleting " + f);
+                                    Files.delete(f);
+                                } catch(Throwable t) {
+                                    System.err.println("Failed to delete " + f + ": " + t);
+                                }
+                            });
+                    } catch(Throwable t) {
+                        System.err.println("Cleanup failed to list files: " + t);
+                        t.printStackTrace();
+                    }
+                });
+            }
+        }
+    }
+
+    static class Configure {
+        static Policy policy = null;
+        static final ThreadLocal<AtomicBoolean> allowAll = new ThreadLocal<AtomicBoolean>() {
+            @Override
+            protected AtomicBoolean initialValue() {
+                return  new AtomicBoolean(false);
+            }
+        };
+        static void setUp(TestCase test, Properties propertyFile) {
+            switch (test) {
+                case SECURE:
+                    if (policy == null && System.getSecurityManager() != null) {
+                        throw new IllegalStateException("SecurityManager already set");
+                    } else if (policy == null) {
+                        policy = new SimplePolicy(TestCase.SECURE, allowAll);
+                        Policy.setPolicy(policy);
+                        System.setSecurityManager(new SecurityManager());
+                    }
+                    if (System.getSecurityManager() == null) {
+                        throw new IllegalStateException("No SecurityManager.");
+                    }
+                    if (policy == null) {
+                        throw new IllegalStateException("policy not configured");
+                    }
+                    break;
+                case UNSECURE:
+                    if (System.getSecurityManager() != null) {
+                        throw new IllegalStateException("SecurityManager already set");
+                    }
+                    break;
+                default:
+                    new InternalError("No such testcase: " + test);
+            }
+            doPrivileged(() -> {
+                configureWith(propertyFile);
+            });
+        }
+
+        static void configureWith(Properties propertyFile) {
+            try {
+                ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+                propertyFile.store(bytes, propertyFile.getProperty("test.name"));
+                ByteArrayInputStream bais = new ByteArrayInputStream(bytes.toByteArray());
+                LogManager.getLogManager().readConfiguration(bais);
+            } catch (IOException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+
+        static void updateConfigurationWith(Properties propertyFile, boolean append) {
+            try {
+                ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+                propertyFile.store(bytes, propertyFile.getProperty("test.name"));
+                ByteArrayInputStream bais = new ByteArrayInputStream(bytes.toByteArray());
+                Function<String, BiFunction<String,String,String>> remapper =
+                        append ? (x) -> ((o, n) -> n == null ? o : n)
+                               : (x) -> ((o, n) -> n);
+                LogManager.getLogManager().updateConfiguration(bais, remapper);
+            } catch (IOException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+
+        static void doPrivileged(Runnable run) {
+            final boolean old = allowAll.get().getAndSet(true);
+            try {
+                run.run();
+            } finally {
+                allowAll.get().set(old);
+            }
+        }
+        static <T> T callPrivileged(Callable<T> call) throws Exception {
+            final boolean old = allowAll.get().getAndSet(true);
+            try {
+                return call.call();
+            } finally {
+                allowAll.get().set(old);
+            }
+        }
+    }
+
+    @FunctionalInterface
+    public static interface FileHandlerSupplier {
+        public FileHandler test() throws Exception;
+    }
+
+    static final class TestAssertException extends RuntimeException {
+        TestAssertException(String msg) {
+            super(msg);
+        }
+    }
+
+    private static void assertEquals(long expected, long received, String msg) {
+        if (expected != received) {
+            throw new TestAssertException("Unexpected result for " + msg
+                    + ".\n\texpected: " + expected
+                    +  "\n\tactual:   " + received);
+        } else {
+            System.out.println("Got expected " + msg + ": " + received);
+        }
+    }
+
+    final static class PermissionsBuilder {
+        final Permissions perms;
+        public PermissionsBuilder() {
+            this(new Permissions());
+        }
+        public PermissionsBuilder(Permissions perms) {
+            this.perms = perms;
+        }
+        public PermissionsBuilder add(Permission p) {
+            perms.add(p);
+            return this;
+        }
+        public PermissionsBuilder addAll(PermissionCollection col) {
+            if (col != null) {
+                for (Enumeration<Permission> e = col.elements(); e.hasMoreElements(); ) {
+                    perms.add(e.nextElement());
+                }
+            }
+            return this;
+        }
+        public Permissions toPermissions() {
+            final PermissionsBuilder builder = new PermissionsBuilder();
+            builder.addAll(perms);
+            return builder.perms;
+        }
+    }
+
+    public static class SimplePolicy extends Policy {
+
+        final Permissions permissions;
+        final Permissions allPermissions;
+        final ThreadLocal<AtomicBoolean> allowAll; // actually: this should be in a thread locale
+        public SimplePolicy(TestCase test, ThreadLocal<AtomicBoolean> allowAll) {
+            this.allowAll = allowAll;
+            permissions = new Permissions();
+            permissions.add(new LoggingPermission("control", null));
+            permissions.add(new FilePermission(PREFIX+".lck", "read,write,delete"));
+            permissions.add(new FilePermission(PREFIX, "read,write"));
+
+            // these are used for configuring the test itself...
+            allPermissions = new Permissions();
+            allPermissions.add(new java.security.AllPermission());
+
+        }
+
+        @Override
+        public boolean implies(ProtectionDomain domain, Permission permission) {
+            if (allowAll.get().get()) return allPermissions.implies(permission);
+            return permissions.implies(permission);
+        }
+
+        @Override
+        public PermissionCollection getPermissions(CodeSource codesource) {
+            return new PermissionsBuilder().addAll(allowAll.get().get()
+                    ? allPermissions : permissions).toPermissions();
+        }
+
+        @Override
+        public PermissionCollection getPermissions(ProtectionDomain domain) {
+            return new PermissionsBuilder().addAll(allowAll.get().get()
+                    ? allPermissions : permissions).toPermissions();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigWithInputStreamTest.java	Mon Oct 12 14:41:36 2015 -0700
@@ -0,0 +1,685 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+import java.util.logging.LoggingPermission;
+
+/**
+ * @test
+ * @bug 8033661
+ * @summary tests LogManager.updateConfiguration(InputStream, Function) method
+ * @run main/othervm SimpleUpdateConfigWithInputStreamTest UNSECURE
+ * @run main/othervm SimpleUpdateConfigWithInputStreamTest SECURE
+ * @author danielfuchs
+ */
+public class SimpleUpdateConfigWithInputStreamTest {
+
+    /**
+     * We will test updateConfiguration in
+     * two configurations:
+     * UNSECURE: No security manager.
+     * SECURE: With the security manager present - and the required
+     *         permissions granted.
+     */
+    public static enum TestCase {
+        UNSECURE, SECURE;
+        public void execute(Runnable run) {
+            System.out.println("Running test case: " + name());
+            try {
+               Configure.setUp(this);
+               Configure.doPrivileged(run, SimplePolicy.allowControl);
+            } finally {
+               Configure.doPrivileged(() -> {
+                   try {
+                       setSystemProperty("java.util.logging.config.file", null);
+                       LogManager.getLogManager().readConfiguration();
+                       System.gc();
+                   } catch (Exception x) {
+                       throw new RuntimeException(x);
+                   }
+               }, SimplePolicy.allowAll);
+            }
+        }
+    }
+
+    public static class MyHandler extends Handler {
+        static final AtomicLong seq = new AtomicLong();
+        long count = seq.incrementAndGet();
+
+        @Override
+        public void publish(LogRecord record) {
+        }
+
+        @Override
+        public void flush() {
+        }
+
+        @Override
+        public void close() throws SecurityException {
+        }
+
+        @Override
+        public String toString() {
+            return super.toString() + "("+count+")";
+        }
+
+    }
+
+    static String storePropertyToFile(String name, Properties props)
+        throws Exception {
+        return Configure.callPrivileged(() -> {
+            String scratch = System.getProperty("user.dir", ".");
+            Path p = Paths.get(scratch, name);
+            try (FileOutputStream fos = new FileOutputStream(p.toFile())) {
+                props.store(fos, name);
+            }
+            return p.toString();
+        }, SimplePolicy.allowAll);
+    }
+
+    static void setSystemProperty(String name, String value)
+        throws Exception {
+        Configure.doPrivileged(() -> {
+            if (value == null)
+                System.clearProperty(name);
+            else
+                System.setProperty(name, value);
+        }, SimplePolicy.allowAll);
+    }
+
+    static String trim(String value) {
+        return value == null ? null : value.trim();
+    }
+
+
+    /**
+     * Tests one of the configuration defined above.
+     * <p>
+     * This is the main test method (the rest is infrastructure).
+     */
+    static void testUpdateConfiguration() {
+        try {
+            // manager initialized with default configuration.
+            LogManager manager = LogManager.getLogManager();
+
+            // Test default configuration. It should not have
+            // any value for "com.foo.level" and "com.foo.handlers"
+            assertEquals(null, manager.getProperty("com.foo.level"),
+                "com.foo.level in default configuration");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in default configuration");
+
+            // Create a logging configuration file that contains
+            // com.foo.level=FINEST
+            // and set "java.util.logging.config.file" to this file.
+            Properties props = new Properties();
+            props.setProperty("com.foo.level", "FINEST");
+
+            // Update configuration with props
+            // then test that the new configuration has
+            // com.foo.level=FINEST
+            // and nothing for com.foo.handlers
+            Configure.updateConfigurationWith(props, null);
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level in " + props);
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in " + props);
+
+            // call updateConfiguration with an empty stream.
+            // check that the new configuration no longer has
+            // any value for com.foo.level, and still no value
+            // for com.foo.handlers
+            Configure.updateConfigurationWith(new Properties(), null);
+            assertEquals(null, manager.getProperty("com.foo.level"),
+                    "com.foo.level in default configuration");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in default configuration");
+
+            // creates the com.foo logger, check it has
+            // the default config: no level, and no handlers
+            final Logger logger = Logger.getLogger("com.foo");
+            assertEquals(null, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertDeepEquals(new Handler[0], logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+
+            // call updateConfiguration with 'props'
+            // check that the configuration has
+            // com.foo.level=FINEST
+            // and nothing for com.foo.handlers
+            // check that the logger has now a FINEST level and still
+            // no handlers
+            Configure.updateConfigurationWith(props, null);
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level in " + props);
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertDeepEquals(new Handler[0], logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in " + props);
+
+            // Calls updateConfiguration with a lambda whose effect should
+            // be to set the FINER level on the "com.foo" logger.
+            // Check that the new configuration has
+            // com.foo.level=FINER
+            // and nothing for com.foo.handlers
+            // check that the logger has now a FINER level and still
+            // no handlers
+            Configure.updateConfigurationWith(props,
+                    (k) -> ("com.foo.level".equals(k) ? (o, n) -> "FINER" : (o, n) -> n));
+            assertEquals("FINER", manager.getProperty("com.foo.level"),
+                "com.foo.level set to FINER by updateConfiguration");
+            assertEquals(Level.FINER, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertDeepEquals(new Handler[0], logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in " + props);
+
+            // Calls updateConfiguration with a lambda whose effect is a noop.
+            // This should not change the configuration, so
+            // check that the new configuration still has
+            // com.foo.level=FINER
+            // and nothing for com.foo.handlers
+            // check that the logger still has FINER level and still
+            // no handlers
+            Configure.updateConfigurationWith(props,
+                    (k) -> ((o, n) -> o));
+            assertEquals("FINER", manager.getProperty("com.foo.level"),
+                "com.foo.level preserved by updateConfiguration");
+            assertEquals(Level.FINER, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertDeepEquals(new Handler[0], logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in " + props);
+
+            // Calls updateConfiguration with a lambda whose effect is to
+            // take all values from the new configuration.
+            // This should update the configuration to what is in props, so
+            // check that the new configuration has
+            // com.foo.level=FINEST
+            // and nothing for com.foo.handlers
+            // check that the logger now has FINEST level and still
+            // no handlers
+            Configure.updateConfigurationWith(props,
+                    (k) -> ((o, n) -> n));
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertDeepEquals(new Handler[0], logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in " + props);
+
+            // now set a handler on the com.foo logger.
+            MyHandler h = new MyHandler();
+            logger.addHandler(h);
+            assertDeepEquals(new Handler[] {h}, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+
+            // Calls updateConfiguration with a lambda whose effect should
+            // be to set the FINER level on the "com.foo" logger, and
+            // take the value from props for everything else.
+            // Check that the new configuration has
+            // com.foo.level=FINER
+            // and nothing for com.foo.handlers
+            // check that the logger has now a FINER level, but that its
+            // handlers are still present and have not been reset
+            // since neither the old nor new configuration defined them.
+            Configure.updateConfigurationWith(props,
+                    (k) -> ("com.foo.level".equals(k) ? (o, n) -> "FINER" : (o, n) -> n));
+            assertEquals("FINER", manager.getProperty("com.foo.level"),
+                "com.foo.level set to FINER by updateConfiguration");
+            assertEquals(Level.FINER, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertDeepEquals(new Handler[] {h}, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in " + props);
+
+            // now add some configuration for com.foo.handlers
+            props.setProperty("com.foo.handlers", MyHandler.class.getName());
+
+            // we didn't call updateConfiguration, so just changing the
+            // content of props should have had no effect.
+            assertEquals("FINER", manager.getProperty("com.foo.level"),
+                "com.foo.level set to FINER by updateConfiguration");
+            assertEquals(Level.FINER, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(null,
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+            assertDeepEquals(new Handler[] {h}, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+
+            // Calls updateConfiguration with a lambda whose effect is a noop.
+            // This should not change the current configuration, so
+            // check that the new configuration still has
+            // com.foo.level=FINER
+            // and nothing for com.foo.handlers
+            // check that the logger still has FINER level and still
+            // has its handlers and that they haven't been reset.
+            Configure.updateConfigurationWith(props, (k) -> ((o, n) -> o));
+            assertEquals("FINER", manager.getProperty("com.foo.level"),
+                "com.foo.level set to FINER by updateConfiguration");
+            assertEquals(Level.FINER, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(null,
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+            assertDeepEquals(new Handler[] {h}, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+
+            // Calls updateConfiguration with a lambda whose effect is to
+            // take all values from the new configuration.
+            // This should update the configuration to what is in props, so
+            // check that the new configuration has
+            // com.foo.level=FINEST
+            // com.foo.handlers=SimpleUpdateConfigWithInputStreamTest$MyHandler
+            // check that the logger now has FINEST level
+            // and a new handler instance, since the old config
+            // had no handlers for com.foo and the new config has one.
+            Configure.updateConfigurationWith(props, (k) -> ((o, n) -> n));
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(MyHandler.class.getName(),
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+            Handler[] loggerHandlers = logger.getHandlers().clone();
+            assertEquals(1, loggerHandlers.length,
+                    "Logger.getLogger(\"com.foo\").getHandlers().length");
+            assertEquals(MyHandler.class, loggerHandlers[0].getClass(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()[0].getClass()");
+            assertEquals(h.count + 1, ((MyHandler)logger.getHandlers()[0]).count,
+                    "Logger.getLogger(\"com.foo\").getHandlers()[0].count");
+
+            // Calls updateConfiguration with a lambda whose effect is a noop.
+            // This should not change the current configuration, so
+            // check that the new configuration still has
+            // com.foo.level=FINEST
+            // com.foo.handlers=SimpleUpdateConfigWithInputStreamTest$MyHandler
+            // check that the logger still has FINEST level and still
+            // has its handlers and that they haven't been reset.
+            Configure.updateConfigurationWith(props, (k) -> ((o, n) -> o));
+            assertDeepEquals(loggerHandlers, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(MyHandler.class.getName(),
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+
+            // Calls updateConfiguration with a lambda whose effect is to
+            // take all values from the new configuration.
+            // Because the content of the props hasn't changed, then
+            // it should also be a noop.
+            // check that the new configuration still has
+            // com.foo.level=FINEST
+            // com.foo.handlers=SimpleUpdateConfigWithInputStreamTest$MyHandler
+            // check that the logger still has FINEST level and still
+            // has its handlers and that they haven't been reset.
+            Configure.updateConfigurationWith(props, (k) -> ((o, n) -> n));
+            assertDeepEquals(loggerHandlers, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(MyHandler.class.getName(),
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+
+            // Calls updateConfiguration with a null lambda, whose effect is to
+            // take all values from the new configuration.
+            // Because the content of the props hasn't changed, then
+            // it should also be a noop.
+            // check that the new configuration still has
+            // com.foo.level=FINEST
+            // com.foo.handlers=SimpleUpdateConfigWithInputStreamTest$MyHandler
+            // check that the logger still has FINEST level and still
+            // has its handlers and that they haven't been reset.
+            Configure.updateConfigurationWith(props, (k) -> ((o, n) -> n));
+            assertDeepEquals(loggerHandlers, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(MyHandler.class.getName(),
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+
+            // now remove com.foo.handlers=SimpleUpdateConfigWithInputStreamTest$MyHandler
+            // from the configuration file.
+            props.remove("com.foo.handlers");
+
+            // Calls updateConfiguration with a lambda whose effect is a noop.
+            // This should not change the current configuration, so
+            // check that the new configuration still has
+            // com.foo.level=FINEST
+            // com.foo.handlers=SimpleUpdateConfigWithInputStreamTest$MyHandler
+            // check that the logger still has FINEST level and still
+            // has its handlers and that they haven't been reset.
+            Configure.updateConfigurationWith(props, (k) -> ((o, n) -> o));
+            assertDeepEquals(loggerHandlers, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(MyHandler.class.getName(),
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+
+            // Calls updateConfiguration with a lambda whose effect is to
+            // take all values from the new configuration.
+            // This should update the configuration to what is in props, so
+            // check that the new configuration has
+            // com.foo.level=FINEST
+            // and nothing for com.foo.handlers
+            // check that the logger still has FINEST level
+            // and no handlers, since the old config
+            // had an handler for com.foo and the new config doesn't.
+            Configure.updateConfigurationWith(props, (k) -> ((o, n) -> n));
+            assertDeepEquals(new Handler[0], logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(null,
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+
+
+        } catch (RuntimeException | Error r) {
+            throw r;
+        } catch (Exception x) {
+            throw new RuntimeException(x);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (args == null || args.length == 0) {
+            args = new String[] { "UNSECURE", "SECURE" };
+        }
+        for (String test : args) {
+            TestCase.valueOf(test).execute(SimpleUpdateConfigWithInputStreamTest::testUpdateConfiguration);
+        }
+    }
+
+    static class Configure {
+        static Policy policy = null;
+        static void setUp(TestCase test) {
+            switch (test) {
+                case SECURE:
+                    if (policy == null && System.getSecurityManager() != null) {
+                        throw new IllegalStateException("SecurityManager already set");
+                    } else if (policy == null) {
+                        policy = new SimplePolicy(TestCase.SECURE);
+                        Policy.setPolicy(policy);
+                        System.setSecurityManager(new SecurityManager());
+                    }
+                    if (System.getSecurityManager() == null) {
+                        throw new IllegalStateException("No SecurityManager.");
+                    }
+                    if (policy == null) {
+                        throw new IllegalStateException("policy not configured");
+                    }
+                    break;
+                case UNSECURE:
+                    if (System.getSecurityManager() != null) {
+                        throw new IllegalStateException("SecurityManager already set");
+                    }
+                    break;
+                default:
+                    throw new InternalError("No such testcase: " + test);
+            }
+        }
+
+        static void updateConfigurationWith(Properties propertyFile,
+                Function<String,BiFunction<String,String,String>> remapper) {
+            try {
+                ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+                propertyFile.store(bytes, propertyFile.getProperty("test.name"));
+                ByteArrayInputStream bais = new ByteArrayInputStream(bytes.toByteArray());
+                LogManager.getLogManager().updateConfiguration(bais, remapper);
+            } catch (IOException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+
+        static void doPrivileged(Runnable run, ThreadLocal<AtomicBoolean> granter) {
+            final boolean old = granter.get().getAndSet(true);
+            try {
+                run.run();
+            } finally {
+                granter.get().set(old);
+            }
+        }
+        static <T> T callPrivileged(Callable<T> call,
+                ThreadLocal<AtomicBoolean> granter) throws Exception {
+            final boolean old = granter.get().getAndSet(true);
+            try {
+                return call.call();
+            } finally {
+                granter.get().set(old);
+            }
+        }
+    }
+
+    static final class TestAssertException extends RuntimeException {
+        TestAssertException(String msg) {
+            super(msg);
+        }
+    }
+
+    private static void assertEquals(long expected, long received, String msg) {
+        if (expected != received) {
+            throw new TestAssertException("Unexpected result for " + msg
+                    + ".\n\texpected: " + expected
+                    +  "\n\tactual:   " + received);
+        } else {
+            System.out.println("Got expected " + msg + ": " + received);
+        }
+    }
+
+    private static void assertEquals(String expected, String received, String msg) {
+        if (!Objects.equals(expected, received)) {
+            throw new TestAssertException("Unexpected result for " + msg
+                    + ".\n\texpected: " + expected
+                    +  "\n\tactual:   " + received);
+        } else {
+            System.out.println("Got expected " + msg + ": " + received);
+        }
+    }
+
+    private static void assertEquals(Object expected, Object received, String msg) {
+        if (!Objects.equals(expected, received)) {
+            throw new TestAssertException("Unexpected result for " + msg
+                    + ".\n\texpected: " + expected
+                    +  "\n\tactual:   " + received);
+        } else {
+            System.out.println("Got expected " + msg + ": " + received);
+        }
+    }
+
+    public static String deepToString(Object o) {
+        if (o == null) {
+            return "null";
+        } else if (o.getClass().isArray()) {
+            String s;
+            if (o instanceof Object[])
+                s = Arrays.deepToString((Object[]) o);
+            else if (o instanceof byte[])
+                s = Arrays.toString((byte[]) o);
+            else if (o instanceof short[])
+                s = Arrays.toString((short[]) o);
+            else if (o instanceof int[])
+                s = Arrays.toString((int[]) o);
+            else if (o instanceof long[])
+                s = Arrays.toString((long[]) o);
+            else if (o instanceof char[])
+                s = Arrays.toString((char[]) o);
+            else if (o instanceof float[])
+                s = Arrays.toString((float[]) o);
+            else if (o instanceof double[])
+                s = Arrays.toString((double[]) o);
+            else if (o instanceof boolean[])
+                s = Arrays.toString((boolean[]) o);
+            else
+                s = o.toString();
+            return s;
+        } else {
+            return o.toString();
+        }
+    }
+
+    private static void assertDeepEquals(Object expected, Object received, String msg) {
+        if (!Objects.deepEquals(expected, received)) {
+            throw new TestAssertException("Unexpected result for " + msg
+                    + ".\n\texpected: " + deepToString(expected)
+                    +  "\n\tactual:   " + deepToString(received));
+        } else {
+            System.out.println("Got expected " + msg + ": " + deepToString(received));
+        }
+    }
+
+    final static class PermissionsBuilder {
+        final Permissions perms;
+        public PermissionsBuilder() {
+            this(new Permissions());
+        }
+        public PermissionsBuilder(Permissions perms) {
+            this.perms = perms;
+        }
+        public PermissionsBuilder add(Permission p) {
+            perms.add(p);
+            return this;
+        }
+        public PermissionsBuilder addAll(PermissionCollection col) {
+            if (col != null) {
+                for (Enumeration<Permission> e = col.elements(); e.hasMoreElements(); ) {
+                    perms.add(e.nextElement());
+                }
+            }
+            return this;
+        }
+        public Permissions toPermissions() {
+            final PermissionsBuilder builder = new PermissionsBuilder();
+            builder.addAll(perms);
+            return builder.perms;
+        }
+    }
+
+    public static class SimplePolicy extends Policy {
+
+        final Permissions basic;
+        final Permissions control;
+        final Permissions all;
+        public final static ThreadLocal<AtomicBoolean> allowAll =
+                new ThreadLocal<AtomicBoolean>() {
+            @Override
+            protected AtomicBoolean initialValue() {
+                return new AtomicBoolean();
+            }
+        };
+        public final static ThreadLocal<AtomicBoolean> allowControl =
+                new ThreadLocal<AtomicBoolean>() {
+            @Override
+            protected AtomicBoolean initialValue() {
+                return new AtomicBoolean();
+            }
+        };
+        public SimplePolicy(TestCase test) {
+            basic = new Permissions();
+            control = new Permissions();
+            control.add(new LoggingPermission("control", null));
+
+            // these are used for configuring the test itself...
+            all = new Permissions();
+            all.add(new java.security.AllPermission());
+
+        }
+
+        @Override
+        public boolean implies(ProtectionDomain domain, Permission permission) {
+            return getPermissions(domain).implies(permission);
+        }
+
+        public PermissionCollection permissions() {
+            PermissionsBuilder builder = new PermissionsBuilder();
+            if (allowAll.get().get()) {
+                builder.addAll(all);
+            } else {
+                builder.addAll(basic);
+                if (allowControl.get().get()) {
+                    builder.addAll(control);
+                }
+            }
+            return builder.toPermissions();
+        }
+
+        @Override
+        public PermissionCollection getPermissions(CodeSource codesource) {
+            return permissions();
+        }
+
+        @Override
+        public PermissionCollection getPermissions(ProtectionDomain domain) {
+            return permissions();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigurationTest.java	Mon Oct 12 14:41:36 2015 -0700
@@ -0,0 +1,720 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileOutputStream;
+import java.io.FilePermission;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.PropertyPermission;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+import java.util.logging.LoggingPermission;
+
+/**
+ * @test
+ * @bug 8033661
+ * @summary tests LogManager.updateConfiguration(Function) method
+ * @run main/othervm SimpleUpdateConfigurationTest UNSECURE
+ * @run main/othervm SimpleUpdateConfigurationTest SECURE
+ * @author danielfuchs
+ */
+public class SimpleUpdateConfigurationTest {
+
+    /**
+     * We will test updateConfiguration in
+     * two configurations:
+     * UNSECURE: No security manager.
+     * SECURE: With the security manager present - and the required
+     *         permissions granted.
+     */
+    public static enum TestCase {
+        UNSECURE, SECURE;
+        public void execute(Runnable run) {
+            System.out.println("Running test case: " + name());
+            try {
+               Configure.setUp(this);
+               Configure.doPrivileged(run, SimplePolicy.allowControl);
+            } finally {
+               Configure.doPrivileged(() -> {
+                   try {
+                       setSystemProperty("java.util.logging.config.file", null);
+                       LogManager.getLogManager().readConfiguration();
+                       System.gc();
+                   } catch (Exception x) {
+                       throw new RuntimeException(x);
+                   }
+               }, SimplePolicy.allowAll);
+            }
+        }
+    }
+
+    public static class MyHandler extends Handler {
+        static final AtomicLong seq = new AtomicLong();
+        long count = seq.incrementAndGet();
+
+        @Override
+        public void publish(LogRecord record) {
+        }
+
+        @Override
+        public void flush() {
+        }
+
+        @Override
+        public void close() throws SecurityException {
+        }
+
+        @Override
+        public String toString() {
+            return super.toString() + "("+count+")";
+        }
+
+    }
+
+    static String storePropertyToFile(String name, Properties props)
+        throws Exception {
+        return Configure.callPrivileged(() -> {
+            String scratch = System.getProperty("user.dir", ".");
+            Path p = Paths.get(scratch, name);
+            try (FileOutputStream fos = new FileOutputStream(p.toFile())) {
+                props.store(fos, name);
+            }
+            return p.toString();
+        }, SimplePolicy.allowAll);
+    }
+
+    static void setSystemProperty(String name, String value)
+        throws Exception {
+        Configure.doPrivileged(() -> {
+            if (value == null)
+                System.clearProperty(name);
+            else
+                System.setProperty(name, value);
+        }, SimplePolicy.allowAll);
+    }
+
+    static String trim(String value) {
+        return value == null ? null : value.trim();
+    }
+
+
+    /**
+     * Tests one of the configuration defined above.
+     * <p>
+     * This is the main test method (the rest is infrastructure).
+     */
+    static void testUpdateConfiguration() {
+        String configFile = null;
+        try {
+            // manager initialized with default configuration.
+            LogManager manager = LogManager.getLogManager();
+
+            // Test default configuration. It should not have
+            // any value for "com.foo.level" and "com.foo.handlers"
+            assertEquals(null, manager.getProperty("com.foo.level"),
+                "com.foo.level in default configuration");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in default configuration");
+
+            // Create a logging configuration file that contains
+            // com.foo.level=FINEST
+            // and set "java.util.logging.config.file" to this file.
+            Properties props = new Properties();
+            props.setProperty("com.foo.level", "FINEST");
+            configFile = storePropertyToFile("config1", props);
+            setSystemProperty("java.util.logging.config.file", configFile);
+
+            // Update configuration with configFile
+            // then test that the new configuration has
+            // com.foo.level=FINEST
+            // and nothing for com.foo.handlers
+            manager.updateConfiguration(null);
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level in " + configFile);
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in " + configFile);
+
+            // clear ("java.util.logging.config.file" system property,
+            // and call updateConfiguration again.
+            // check that the new configuration no longer has
+            // any value for com.foo.level, and still no value
+            // for com.foo.handlers
+            setSystemProperty("java.util.logging.config.file", null);
+            manager.updateConfiguration(null);
+            assertEquals(null, manager.getProperty("com.foo.level"),
+                    "com.foo.level in default configuration");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in default configuration");
+
+            // creates the com.foo logger, check it has
+            // the default config: no level, and no handlers
+            final Logger logger = Logger.getLogger("com.foo");
+            assertEquals(null, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertDeepEquals(new Handler[0], logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+
+            // set "java.util.logging.config.file" to configFile and
+            // call updateConfiguration.
+            // check that the configuration has
+            // com.foo.level=FINEST
+            // and nothing for com.foo.handlers
+            // check that the logger has now a FINEST level and still
+            // no handlers
+            setSystemProperty("java.util.logging.config.file", configFile);
+            manager.updateConfiguration(null);
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level in " + configFile);
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertDeepEquals(new Handler[0], logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in " + configFile);
+
+            // Calls updateConfiguration with a lambda whose effect should
+            // be to set the FINER level on the "com.foo" logger.
+            // Check that the new configuration has
+            // com.foo.level=FINER
+            // and nothing for com.foo.handlers
+            // check that the logger has now a FINER level and still
+            // no handlers
+            manager.updateConfiguration(
+                    (k) -> ("com.foo.level".equals(k) ? (o, n) -> "FINER" : (o, n) -> n));
+            assertEquals("FINER", manager.getProperty("com.foo.level"),
+                "com.foo.level set to FINER by updateConfiguration");
+            assertEquals(Level.FINER, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertDeepEquals(new Handler[0], logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in " + configFile);
+
+            // Calls updateConfiguration with a lambda whose effect is a noop.
+            // This should not change the configuration, so
+            // check that the new configuration still has
+            // com.foo.level=FINER
+            // and nothing for com.foo.handlers
+            // check that the logger still has FINER level and still
+            // no handlers
+            manager.updateConfiguration(
+                    (k) -> ((o, n) -> o));
+            assertEquals("FINER", manager.getProperty("com.foo.level"),
+                "com.foo.level preserved by updateConfiguration");
+            assertEquals(Level.FINER, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertDeepEquals(new Handler[0], logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in " + configFile);
+
+            // Calls updateConfiguration with a lambda whose effect is to
+            // take all values from the new configuration.
+            // This should update the configuration to what is in configFile, so
+            // check that the new configuration has
+            // com.foo.level=FINEST
+            // and nothing for com.foo.handlers
+            // check that the logger now has FINEST level and still
+            // no handlers
+            manager.updateConfiguration(
+                    (k) -> ((o, n) -> n));
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertDeepEquals(new Handler[0], logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in " + configFile);
+
+            // now set a handler on the com.foo logger.
+            MyHandler h = new MyHandler();
+            logger.addHandler(h);
+            assertDeepEquals(new Handler[] {h}, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+
+            // Calls updateConfiguration with a lambda whose effect should
+            // be to set the FINER level on the "com.foo" logger, and
+            // take the value from configFile for everything else.
+            // Check that the new configuration has
+            // com.foo.level=FINER
+            // and nothing for com.foo.handlers
+            // check that the logger has now a FINER level, but that its
+            // handlers are still present and have not been reset
+            // since neither the old nor new configuration defined them.
+            manager.updateConfiguration(
+                    (k) -> ("com.foo.level".equals(k) ? (o, n) -> "FINER" : (o, n) -> n));
+            assertEquals("FINER", manager.getProperty("com.foo.level"),
+                "com.foo.level set to FINER by updateConfiguration");
+            assertEquals(Level.FINER, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertDeepEquals(new Handler[] {h}, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals(null, manager.getProperty("com.foo.handlers"),
+                "com.foo.handlers in " + configFile);
+
+            // now add some configuration for com.foo.handlers in the
+            // configuration file.
+            props.setProperty("com.foo.handlers", MyHandler.class.getName());
+            storePropertyToFile("config1", props);
+
+            // we didn't call updateConfiguration, so just changing the
+            // content of the file should have had no no effect yet.
+            assertEquals("FINER", manager.getProperty("com.foo.level"),
+                "com.foo.level set to FINER by updateConfiguration");
+            assertEquals(Level.FINER, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(null,
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+            assertDeepEquals(new Handler[] {h}, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+
+            // Calls updateConfiguration with a lambda whose effect is a noop.
+            // This should not change the current configuration, so
+            // check that the new configuration still has
+            // com.foo.level=FINER
+            // and nothing for com.foo.handlers
+            // check that the logger still has FINER level and still
+            // has its handlers and that they haven't been reset.
+            manager.updateConfiguration((k) -> ((o, n) -> o));
+            assertEquals("FINER", manager.getProperty("com.foo.level"),
+                "com.foo.level set to FINER by updateConfiguration");
+            assertEquals(Level.FINER, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(null,
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+            assertDeepEquals(new Handler[] {h}, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+
+            // Calls updateConfiguration with a lambda whose effect is to
+            // take all values from the new configuration.
+            // This should update the configuration to what is in configFile, so
+            // check that the new configuration has
+            // com.foo.level=FINEST
+            // com.foo.handlers=SimpleUpdateConfigurationTest$MyHandler
+            // check that the logger now has FINEST level
+            // and a new handler instance, since the old config
+            // had no handlers for com.foo and the new config has one.
+            manager.updateConfiguration((k) -> ((o, n) -> n));
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(MyHandler.class.getName(),
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+            Handler[] loggerHandlers = logger.getHandlers().clone();
+            assertEquals(1, loggerHandlers.length,
+                    "Logger.getLogger(\"com.foo\").getHandlers().length");
+            assertEquals(MyHandler.class, loggerHandlers[0].getClass(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()[0].getClass()");
+            assertEquals(h.count + 1, ((MyHandler)logger.getHandlers()[0]).count,
+                    "Logger.getLogger(\"com.foo\").getHandlers()[0].count");
+
+            // Calls updateConfiguration with a lambda whose effect is a noop.
+            // This should not change the current configuration, so
+            // check that the new configuration still has
+            // com.foo.level=FINEST
+            // com.foo.handlers=SimpleUpdateConfigurationTest$MyHandler
+            // check that the logger still has FINEST level and still
+            // has its handlers and that they haven't been reset.
+            manager.updateConfiguration((k) -> ((o, n) -> o));
+            assertDeepEquals(loggerHandlers, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(MyHandler.class.getName(),
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+
+            // Calls updateConfiguration with a lambda whose effect is to
+            // take all values from the new configuration.
+            // Because the content of the configFile hasn't changed, then
+            // it should also be a noop.
+            // check that the new configuration still has
+            // com.foo.level=FINEST
+            // com.foo.handlers=SimpleUpdateConfigurationTest$MyHandler
+            // check that the logger still has FINEST level and still
+            // has its handlers and that they haven't been reset.
+            manager.updateConfiguration((k) -> ((o, n) -> n));
+            assertDeepEquals(loggerHandlers, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(MyHandler.class.getName(),
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+
+            // Calls updateConfiguration with a null lambda, whose effect is to
+            // take all values from the new configuration.
+            // Because the content of the configFile hasn't changed, then
+            // it should also be a noop.
+            // check that the new configuration still has
+            // com.foo.level=FINEST
+            // com.foo.handlers=SimpleUpdateConfigurationTest$MyHandler
+            // check that the logger still has FINEST level and still
+            // has its handlers and that they haven't been reset.
+            manager.updateConfiguration((k) -> ((o, n) -> n));
+            assertDeepEquals(loggerHandlers, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(MyHandler.class.getName(),
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+
+            // no remove com.foo.handlers=SimpleUpdateConfigurationTest$MyHandler
+            // from the configuration file.
+            props.remove("com.foo.handlers");
+            storePropertyToFile("config1", props);
+
+            // Calls updateConfiguration with a lambda whose effect is a noop.
+            // This should not change the current configuration, so
+            // check that the new configuration still has
+            // com.foo.level=FINEST
+            // com.foo.handlers=SimpleUpdateConfigurationTest$MyHandler
+            // check that the logger still has FINEST level and still
+            // has its handlers and that they haven't been reset.
+            manager.updateConfiguration((k) -> ((o, n) -> o));
+            assertDeepEquals(loggerHandlers, logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(MyHandler.class.getName(),
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+
+            // Calls updateConfiguration with a lambda whose effect is to
+            // take all values from the new configuration.
+            // This should update the configuration to what is in configFile, so
+            // check that the new configuration has
+            // com.foo.level=FINEST
+            // and nothing for com.foo.handlers
+            // check that the logger still has FINEST level
+            // and no handlers, since the old config
+            // had an handler for com.foo and the new config doesn't.
+            manager.updateConfiguration((k) -> ((o, n) -> n));
+            assertDeepEquals(new Handler[0], logger.getHandlers(),
+                    "Logger.getLogger(\"com.foo\").getHandlers()");
+            assertEquals("FINEST", manager.getProperty("com.foo.level"),
+                "com.foo.level updated by updateConfiguration");
+            assertEquals(Level.FINEST, logger.getLevel(),
+                "Logger.getLogger(\"com.foo\").getLevel()");
+            assertEquals(null,
+                    manager.getProperty("com.foo.handlers"),
+                    "manager.getProperty(\"com.foo.handlers\")");
+
+
+        } catch (RuntimeException | Error r) {
+            throw r;
+        } catch (Exception x) {
+            throw new RuntimeException(x);
+        } finally {
+            if (configFile != null) {
+                // cleanup
+                final String file = configFile;
+                Configure.doPrivileged(() -> {
+                    try {
+                        Files.delete(Paths.get(file));
+                    } catch (RuntimeException | Error r) {
+                        throw r;
+                    } catch (Exception x) {
+                        throw new RuntimeException(x);
+                    }
+                }, SimplePolicy.allowAll);
+            }
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (args == null || args.length == 0) {
+            args = new String[] { "UNSECURE", "SECURE" };
+        }
+        for (String test : args) {
+            TestCase.valueOf(test).execute(SimpleUpdateConfigurationTest::testUpdateConfiguration);
+        }
+    }
+
+    static class Configure {
+        static Policy policy = null;
+        static void setUp(TestCase test) {
+            switch (test) {
+                case SECURE:
+                    if (policy == null && System.getSecurityManager() != null) {
+                        throw new IllegalStateException("SecurityManager already set");
+                    } else if (policy == null) {
+                        policy = new SimplePolicy(TestCase.SECURE);
+                        Policy.setPolicy(policy);
+                        System.setSecurityManager(new SecurityManager());
+                    }
+                    if (System.getSecurityManager() == null) {
+                        throw new IllegalStateException("No SecurityManager.");
+                    }
+                    if (policy == null) {
+                        throw new IllegalStateException("policy not configured");
+                    }
+                    break;
+                case UNSECURE:
+                    if (System.getSecurityManager() != null) {
+                        throw new IllegalStateException("SecurityManager already set");
+                    }
+                    break;
+                default:
+                    throw new InternalError("No such testcase: " + test);
+            }
+        }
+
+        static void updateConfigurationWith(Properties propertyFile,
+                Function<String,BiFunction<String,String,String>> remapper) {
+            try {
+                ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+                propertyFile.store(bytes, propertyFile.getProperty("test.name"));
+                ByteArrayInputStream bais = new ByteArrayInputStream(bytes.toByteArray());
+                LogManager.getLogManager().updateConfiguration(bais, remapper);
+            } catch (IOException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+
+        static void doPrivileged(Runnable run, ThreadLocal<AtomicBoolean> granter) {
+            final boolean old = granter.get().getAndSet(true);
+            try {
+                run.run();
+            } finally {
+                granter.get().set(old);
+            }
+        }
+        static <T> T callPrivileged(Callable<T> call,
+                ThreadLocal<AtomicBoolean> granter) throws Exception {
+            final boolean old = granter.get().getAndSet(true);
+            try {
+                return call.call();
+            } finally {
+                granter.get().set(old);
+            }
+        }
+    }
+
+    static final class TestAssertException extends RuntimeException {
+        TestAssertException(String msg) {
+            super(msg);
+        }
+    }
+
+    private static void assertEquals(long expected, long received, String msg) {
+        if (expected != received) {
+            throw new TestAssertException("Unexpected result for " + msg
+                    + ".\n\texpected: " + expected
+                    +  "\n\tactual:   " + received);
+        } else {
+            System.out.println("Got expected " + msg + ": " + received);
+        }
+    }
+
+    private static void assertEquals(String expected, String received, String msg) {
+        if (!Objects.equals(expected, received)) {
+            throw new TestAssertException("Unexpected result for " + msg
+                    + ".\n\texpected: " + expected
+                    +  "\n\tactual:   " + received);
+        } else {
+            System.out.println("Got expected " + msg + ": " + received);
+        }
+    }
+
+    private static void assertEquals(Object expected, Object received, String msg) {
+        if (!Objects.equals(expected, received)) {
+            throw new TestAssertException("Unexpected result for " + msg
+                    + ".\n\texpected: " + expected
+                    +  "\n\tactual:   " + received);
+        } else {
+            System.out.println("Got expected " + msg + ": " + received);
+        }
+    }
+
+    public static String deepToString(Object o) {
+        if (o == null) {
+            return "null";
+        } else if (o.getClass().isArray()) {
+            String s;
+            if (o instanceof Object[])
+                s = Arrays.deepToString((Object[]) o);
+            else if (o instanceof byte[])
+                s = Arrays.toString((byte[]) o);
+            else if (o instanceof short[])
+                s = Arrays.toString((short[]) o);
+            else if (o instanceof int[])
+                s = Arrays.toString((int[]) o);
+            else if (o instanceof long[])
+                s = Arrays.toString((long[]) o);
+            else if (o instanceof char[])
+                s = Arrays.toString((char[]) o);
+            else if (o instanceof float[])
+                s = Arrays.toString((float[]) o);
+            else if (o instanceof double[])
+                s = Arrays.toString((double[]) o);
+            else if (o instanceof boolean[])
+                s = Arrays.toString((boolean[]) o);
+            else
+                s = o.toString();
+            return s;
+        } else {
+            return o.toString();
+        }
+    }
+
+    private static void assertDeepEquals(Object expected, Object received, String msg) {
+        if (!Objects.deepEquals(expected, received)) {
+            throw new TestAssertException("Unexpected result for " + msg
+                    + ".\n\texpected: " + deepToString(expected)
+                    +  "\n\tactual:   " + deepToString(received));
+        } else {
+            System.out.println("Got expected " + msg + ": " + deepToString(received));
+        }
+    }
+
+    final static class PermissionsBuilder {
+        final Permissions perms;
+        public PermissionsBuilder() {
+            this(new Permissions());
+        }
+        public PermissionsBuilder(Permissions perms) {
+            this.perms = perms;
+        }
+        public PermissionsBuilder add(Permission p) {
+            perms.add(p);
+            return this;
+        }
+        public PermissionsBuilder addAll(PermissionCollection col) {
+            if (col != null) {
+                for (Enumeration<Permission> e = col.elements(); e.hasMoreElements(); ) {
+                    perms.add(e.nextElement());
+                }
+            }
+            return this;
+        }
+        public Permissions toPermissions() {
+            final PermissionsBuilder builder = new PermissionsBuilder();
+            builder.addAll(perms);
+            return builder.perms;
+        }
+    }
+
+    public static class SimplePolicy extends Policy {
+
+        final Permissions basic;
+        final Permissions control;
+        final Permissions all;
+        public final static ThreadLocal<AtomicBoolean> allowAll =
+                new ThreadLocal<AtomicBoolean>() {
+            @Override
+            protected AtomicBoolean initialValue() {
+                return new AtomicBoolean();
+            }
+        };
+        public final static ThreadLocal<AtomicBoolean> allowControl =
+                new ThreadLocal<AtomicBoolean>() {
+            @Override
+            protected AtomicBoolean initialValue() {
+                return new AtomicBoolean();
+            }
+        };
+        public SimplePolicy(TestCase test) {
+            basic = new Permissions();
+            control = new Permissions();
+            control.add(new LoggingPermission("control", null));
+
+            // These permissions are required to call updateConfiguration(Function)
+            control.add(new PropertyPermission("java.util.logging.config.file", "read"));
+            control.add(new PropertyPermission("java.home", "read"));
+            control.add(new FilePermission(
+                    Paths.get(System.getProperty("user.dir", "."),"-").toString(), "read"));
+            control.add(new FilePermission(
+                    Paths.get(System.getProperty("java.home"),"conf","-").toString(), "read"));
+
+            // these are used for configuring the test itself...
+            all = new Permissions();
+            all.add(new java.security.AllPermission());
+
+        }
+
+        @Override
+        public boolean implies(ProtectionDomain domain, Permission permission) {
+            return getPermissions(domain).implies(permission);
+        }
+
+        public PermissionCollection permissions() {
+            PermissionsBuilder builder = new PermissionsBuilder();
+            if (allowAll.get().get()) {
+                builder.addAll(all);
+            } else {
+                builder.addAll(basic);
+                if (allowControl.get().get()) {
+                    builder.addAll(control);
+                }
+            }
+            return builder.toPermissions();
+        }
+
+        @Override
+        public PermissionCollection getPermissions(CodeSource codesource) {
+            return permissions();
+        }
+
+        @Override
+        public PermissionCollection getPermissions(ProtectionDomain domain) {
+            return permissions();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/logging/LogManager/Configuration/updateConfiguration/UpdateConfigurationTest.java	Mon Oct 12 14:41:36 2015 -0700
@@ -0,0 +1,608 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FilePermission;
+import java.io.IOException;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Field;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.logging.FileHandler;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import java.util.logging.LoggingPermission;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * @test
+ * @bug 8033661
+ * @summary tests LogManager.updateConfiguration(bin)
+ * @run main/othervm UpdateConfigurationTest UNSECURE
+ * @run main/othervm UpdateConfigurationTest SECURE
+ * @author danielfuchs
+ */
+public class UpdateConfigurationTest {
+
+    /**
+     * We will test the handling of abstract logger nodes with file handlers in
+     * two configurations:
+     * UNSECURE: No security manager.
+     * SECURE: With the security manager present - and the required
+     *         permissions granted.
+     */
+    public static enum TestCase {
+        UNSECURE, SECURE;
+        public void run(Properties propertyFile, boolean last) throws Exception {
+            System.out.println("Running test case: " + name());
+            Configure.setUp(this);
+            test(this.name() + " " + propertyFile.getProperty("test.name"),
+                    propertyFile, last);
+        }
+    }
+
+
+    private static final String PREFIX =
+            "FileHandler-" + UUID.randomUUID() + ".log";
+    private static final String userDir = System.getProperty("user.dir", ".");
+    private static final boolean userDirWritable = Files.isWritable(Paths.get(userDir));
+
+    static enum ConfigMode { APPEND, REPLACE, DEFAULT;
+        boolean append() { return this == APPEND; }
+        Function<String, BiFunction<String,String,String>> remapper() {
+            switch(this) {
+                case APPEND:
+                    return (k) -> ((o,n) -> (n == null ? o : n));
+                case REPLACE:
+                    return (k) -> ((o,n) -> n);
+            }
+            return null;
+        }
+    }
+
+    private static final List<Properties> properties;
+    static {
+        // The test will be run with each of the configurations below.
+        // The 'child' logger is forgotten after each test
+
+        Properties props1 = new Properties();
+        props1.setProperty("test.name", "props1");
+        props1.setProperty("test.config.mode", ConfigMode.REPLACE.name());
+        props1.setProperty(FileHandler.class.getName() + ".pattern", PREFIX);
+        props1.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE));
+        props1.setProperty(FileHandler.class.getName() + ".level", "ALL");
+        props1.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter");
+        props1.setProperty("com.foo.handlers", FileHandler.class.getName());
+        props1.setProperty("com.bar.level", "FINEST");
+
+        Properties props2 = new Properties();
+        props2.setProperty("test.name", "props2");
+        props2.setProperty("test.config.mode", ConfigMode.DEFAULT.name());
+        props2.setProperty(FileHandler.class.getName() + ".pattern", PREFIX);
+        props2.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE));
+        props2.setProperty(FileHandler.class.getName() + ".level", "ALL");
+        props2.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter");
+        props2.setProperty("com.foo.handlers", FileHandler.class.getName());
+        props2.setProperty("com.foo.handlers.ensureCloseOnReset", "true");
+        props2.setProperty("com.level", "FINE");
+
+        Properties props3 = new Properties();
+        props3.setProperty("test.name", "props3");
+        props3.setProperty("test.config.mode", ConfigMode.APPEND.name());
+        props3.setProperty(FileHandler.class.getName() + ".pattern", PREFIX);
+        props3.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE));
+        props3.setProperty(FileHandler.class.getName() + ".level", "ALL");
+        props3.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter");
+        props3.setProperty("com.foo.handlers", ""); // specify "" to override the value in the previous conf
+        props3.setProperty("com.foo.handlers.ensureCloseOnReset", "false");
+        props3.setProperty("com.bar.level", "FINER");
+
+
+        properties = Collections.unmodifiableList(Arrays.asList(
+                    props1, props2, props3, props1));
+    }
+
+    static Properties previous;
+    static Properties current;
+    static final Field propsField;
+    static {
+        LogManager manager = LogManager.getLogManager();
+        try {
+            propsField = LogManager.class.getDeclaredField("props");
+            propsField.setAccessible(true);
+            previous = current = (Properties) propsField.get(manager);
+        } catch (NoSuchFieldException | IllegalAccessException ex) {
+            throw new ExceptionInInitializerError(ex);
+        }
+    }
+
+    static Properties getProperties() {
+        try {
+            return (Properties) propsField.get(LogManager.getLogManager());
+        } catch (IllegalAccessException x) {
+            throw new RuntimeException(x);
+        }
+    }
+
+    static String trim(String value) {
+        return value == null ? null : value.trim();
+    }
+
+
+    /**
+     * Tests one of the configuration defined above.
+     * <p>
+     * This is the main test method (the rest is infrastructure).
+     * <p>
+     * Creates a child of the com.foo logger (com.foo.child), resets
+     * the configuration, and verifies that com.foo has no handler.
+     * Then reapplies the configuration and verifies that the handler
+     * for com.foo has been reestablished, depending on whether
+     * java.util.logging.LogManager.reconfigureHandlers is present and
+     * true.
+     * <p>
+     * Finally releases the logger com.foo.child, so that com.foo can
+     * be garbage collected, and the next configuration can be
+     * tested.
+     */
+    static void test(ConfigMode mode, String name, Properties props, boolean last)
+            throws Exception {
+
+        // Then create a child of the com.foo logger.
+        Logger fooChild = Logger.getLogger("com.foo.child");
+        fooChild.info("hello world");
+        Logger barChild = Logger.getLogger("com.bar.child");
+        barChild.info("hello world");
+
+        ReferenceQueue<Logger> queue = new ReferenceQueue();
+        WeakReference<Logger> fooRef = new WeakReference<>(Logger.getLogger("com.foo"), queue);
+        if (fooRef.get() != fooChild.getParent()) {
+            throw new RuntimeException("Unexpected parent logger: "
+                    + fooChild.getParent() +"\n\texpected: " + fooRef.get());
+        }
+        WeakReference<Logger> barRef = new WeakReference<>(Logger.getLogger("com.bar"), queue);
+        if (barRef.get() != barChild.getParent()) {
+            throw new RuntimeException("Unexpected parent logger: "
+                    + barChild.getParent() +"\n\texpected: " + barRef.get());
+        }
+        Reference<? extends Logger> ref2;
+        int max = 3;
+        barChild = null;
+        while ((ref2 = queue.poll()) == null) {
+            System.gc();
+            Thread.sleep(100);
+            if (--max == 0) break;
+        }
+
+        Throwable failed = null;
+        try {
+            if (ref2 != null) {
+                String refName = ref2 == fooRef ? "fooRef" : ref2 == barRef ? "barRef" : "unknown";
+                if (ref2 != barRef) {
+                    throw new RuntimeException("Unexpected logger reference cleared: " + refName);
+                } else {
+                    System.out.println("Reference " + refName + " cleared as expected");
+                }
+            } else if (ref2 == null) {
+                throw new RuntimeException("Expected 'barRef' to be cleared");
+            }
+            // Now lets try to  check that ref2 has expected handlers, and
+            // attempt to configure again.
+            String p = current.getProperty("com.foo.handlers", "").trim();
+            assertEquals(p.isEmpty() ? 0 : 1, fooChild.getParent().getHandlers().length,
+                    "["+name+"] fooChild.getParent().getHandlers().length");
+            Configure.doPrivileged(() -> Configure.updateConfigurationWith(props, mode.remapper()));
+            String p2 = previous.getProperty("com.foo.handlers", "").trim();
+            assertEquals(p, p2, "["+name+"] com.foo.handlers");
+            String n = trim(props.getProperty("com.foo.handlers", null));
+            boolean hasHandlers = mode.append()
+                    ? (n == null ? !p.isEmpty() : !n.isEmpty())
+                    : n != null && !n.isEmpty();
+            assertEquals( hasHandlers ? 1 : 0,
+                    fooChild.getParent().getHandlers().length,
+                    "["+name+"] fooChild.getParent().getHandlers().length"
+                    + "[p=\""+p+"\", n=" + (n==null?null:"\""+n+"\"") + "]");
+
+            checkProperties(mode, previous, current, props);
+
+        } catch (Throwable t) {
+            failed = t;
+        } finally {
+            if (last || failed != null) {
+                final Throwable suppressed = failed;
+                Configure.doPrivileged(LogManager.getLogManager()::reset);
+                Configure.doPrivileged(() -> {
+                    try {
+                        StringBuilder builder = new StringBuilder();
+                        Files.list(Paths.get(userDir))
+                            .filter((f) -> f.toString().contains(PREFIX))
+                            .filter((f) -> f.toString().endsWith(".lck"))
+                            .forEach((f) -> {
+                                    builder.append(f.toString()).append('\n');
+                            });
+                        if (!builder.toString().isEmpty()) {
+                            throw new RuntimeException("Lock files not cleaned:\n"
+                                    + builder.toString());
+                        }
+                    } catch(RuntimeException | Error x) {
+                        if (suppressed != null) x.addSuppressed(suppressed);
+                        throw x;
+                    } catch(Exception x) {
+                        if (suppressed != null) x.addSuppressed(suppressed);
+                        throw new RuntimeException(x);
+                    }
+                });
+
+                // Now we need to forget the child, so that loggers are released,
+                // and so that we can run the test with the next configuration...
+
+                fooChild = null;
+                System.out.println("Setting fooChild to: " + fooChild);
+                while ((ref2 = queue.poll()) == null) {
+                    System.gc();
+                    Thread.sleep(1000);
+                }
+                if (ref2 != fooRef) {
+                    throw new RuntimeException("Unexpected reference: "
+                            + ref2 +"\n\texpected: " + fooRef);
+                }
+                if (ref2.get() != null) {
+                    throw new RuntimeException("Referent not cleared: " + ref2.get());
+                }
+                System.out.println("Got fooRef after reset(), fooChild is " + fooChild);
+
+            }
+        }
+        if (failed != null) {
+            // should rarely happen...
+            throw new RuntimeException(failed);
+        }
+
+    }
+
+    private static void checkProperties(ConfigMode mode,
+            Properties previous, Properties current, Properties props) {
+        Set<String> set = new HashSet<>();
+
+        // Check that all property names from 'props' are in current.
+        set.addAll(props.stringPropertyNames());
+        set.removeAll(current.keySet());
+        if (!set.isEmpty()) {
+            throw new RuntimeException("Missing properties in current: " + set);
+        }
+        set.clear();
+        set.addAll(current.stringPropertyNames());
+        set.removeAll(previous.keySet());
+        set.removeAll(props.keySet());
+        if (!set.isEmpty()) {
+            throw new RuntimeException("Superfluous properties in current: " + set);
+        }
+        set.clear();
+        Stream<String> allnames =
+                Stream.concat(
+                    Stream.concat(previous.stringPropertyNames().stream(),
+                                  props.stringPropertyNames().stream()),
+                    current.stringPropertyNames().stream())
+                        .collect(Collectors.toCollection(TreeSet::new))
+                        .stream();
+        if (mode.append()) {
+            // Check that all previous property names are in current.
+            set.addAll(previous.stringPropertyNames());
+            set.removeAll(current.keySet());
+            if (!set.isEmpty()) {
+                throw new RuntimeException("Missing properties in current: " + set
+                    + "\n\tprevious: " + previous
+                    + "\n\tcurrent:  " + current
+                    + "\n\tprops:    " + props);
+
+            }
+            allnames.forEach((k) -> {
+                    String p = previous.getProperty(k, "").trim();
+                    String n = current.getProperty(k, "").trim();
+                    if (props.containsKey(k)) {
+                        assertEquals(props.getProperty(k), n, k);
+                    } else {
+                        assertEquals(p, n, k);
+                    }
+                });
+        } else {
+            // Check that only properties from 'props' are in current.
+            set.addAll(current.stringPropertyNames());
+            set.removeAll(props.keySet());
+            if (!set.isEmpty()) {
+                throw new RuntimeException("Superfluous properties in current: " + set);
+            }
+            allnames.forEach((k) -> {
+                    String p = previous.getProperty(k, "");
+                    String n = current.getProperty(k, "");
+                    if (props.containsKey(k)) {
+                        assertEquals(props.getProperty(k), n, k);
+                    } else {
+                        assertEquals("", n, k);
+                    }
+                });
+        }
+
+    }
+
+    public static void main(String... args) throws Exception {
+
+
+        if (args == null || args.length == 0) {
+            args = new String[] {
+                TestCase.UNSECURE.name(),
+                TestCase.SECURE.name(),
+            };
+        }
+
+        try {
+            for (String testName : args) {
+                TestCase test = TestCase.valueOf(testName);
+                for (int i=0; i<properties.size();i++) {
+                    Properties propertyFile = properties.get(i);
+                    test.run(propertyFile, i == properties.size() - 1);
+                }
+            }
+        } finally {
+            if (userDirWritable) {
+                Configure.doPrivileged(() -> {
+                    // cleanup - delete files that have been created
+                    try {
+                        Files.list(Paths.get(userDir))
+                            .filter((f) -> f.toString().contains(PREFIX))
+                            .forEach((f) -> {
+                                try {
+                                    System.out.println("deleting " + f);
+                                    Files.delete(f);
+                                } catch(Throwable t) {
+                                    System.err.println("Failed to delete " + f + ": " + t);
+                                }
+                            });
+                    } catch(Throwable t) {
+                        System.err.println("Cleanup failed to list files: " + t);
+                        t.printStackTrace();
+                    }
+                });
+            }
+        }
+    }
+
+    static class Configure {
+        static Policy policy = null;
+        static final ThreadLocal<AtomicBoolean> allowAll = new ThreadLocal<AtomicBoolean>() {
+            @Override
+            protected AtomicBoolean initialValue() {
+                return  new AtomicBoolean(false);
+            }
+        };
+        static void setUp(TestCase test) {
+            switch (test) {
+                case SECURE:
+                    if (policy == null && System.getSecurityManager() != null) {
+                        throw new IllegalStateException("SecurityManager already set");
+                    } else if (policy == null) {
+                        policy = new SimplePolicy(TestCase.SECURE, allowAll);
+                        Policy.setPolicy(policy);
+                        System.setSecurityManager(new SecurityManager());
+                    }
+                    if (System.getSecurityManager() == null) {
+                        throw new IllegalStateException("No SecurityManager.");
+                    }
+                    if (policy == null) {
+                        throw new IllegalStateException("policy not configured");
+                    }
+                    break;
+                case UNSECURE:
+                    if (System.getSecurityManager() != null) {
+                        throw new IllegalStateException("SecurityManager already set");
+                    }
+                    break;
+                default:
+                    new InternalError("No such testcase: " + test);
+            }
+        }
+
+        static void updateConfigurationWith(Properties propertyFile,
+                Function<String,BiFunction<String,String,String>> remapper) {
+            try {
+                ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+                propertyFile.store(bytes, propertyFile.getProperty("test.name"));
+                ByteArrayInputStream bais = new ByteArrayInputStream(bytes.toByteArray());
+                LogManager.getLogManager().updateConfiguration(bais, remapper);
+            } catch (IOException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+
+        static void doPrivileged(Runnable run) {
+            final boolean old = allowAll.get().getAndSet(true);
+            try {
+                Properties before = getProperties();
+                try {
+                    run.run();
+                } finally {
+                    Properties after = getProperties();
+                    if (before != after) {
+                        previous = before;
+                        current = after;
+                    }
+                }
+            } finally {
+                allowAll.get().set(old);
+            }
+        }
+        static <T> T callPrivileged(Callable<T> call) throws Exception {
+            final boolean old = allowAll.get().getAndSet(true);
+            try {
+                Properties before = getProperties();
+                try {
+                    return call.call();
+                } finally {
+                    Properties after = getProperties();
+                    if (before != after) {
+                        previous = before;
+                        current = after;
+                    }
+                }
+            } finally {
+                allowAll.get().set(old);
+            }
+        }
+    }
+
+    @FunctionalInterface
+    public static interface FileHandlerSupplier {
+        public FileHandler test() throws Exception;
+    }
+
+    static final class TestAssertException extends RuntimeException {
+        TestAssertException(String msg) {
+            super(msg);
+        }
+    }
+
+    private static void assertEquals(long expected, long received, String msg) {
+        if (expected != received) {
+            throw new TestAssertException("Unexpected result for " + msg
+                    + ".\n\texpected: " + expected
+                    +  "\n\tactual:   " + received);
+        } else {
+            System.out.println("Got expected " + msg + ": " + received);
+        }
+    }
+
+    private static void assertEquals(String expected, String received, String msg) {
+        if (!Objects.equals(expected, received)) {
+            throw new TestAssertException("Unexpected result for " + msg
+                    + ".\n\texpected: " + expected
+                    +  "\n\tactual:   " + received);
+        } else {
+            System.out.println("Got expected " + msg + ": " + received);
+        }
+    }
+
+
+    public static void test(String name, Properties props, boolean last) throws Exception {
+        ConfigMode configMode = ConfigMode.valueOf(props.getProperty("test.config.mode"));
+        System.out.println("\nTesting: " + name + " mode=" + configMode);
+        if (!userDirWritable) {
+            throw new RuntimeException("Not writable: "+userDir);
+        }
+        switch(configMode) {
+            case REPLACE:
+            case APPEND:
+            case DEFAULT:
+                test(configMode, name, props, last); break;
+            default:
+                throw new RuntimeException("Unknwown mode: " + configMode);
+        }
+    }
+
+    final static class PermissionsBuilder {
+        final Permissions perms;
+        public PermissionsBuilder() {
+            this(new Permissions());
+        }
+        public PermissionsBuilder(Permissions perms) {
+            this.perms = perms;
+        }
+        public PermissionsBuilder add(Permission p) {
+            perms.add(p);
+            return this;
+        }
+        public PermissionsBuilder addAll(PermissionCollection col) {
+            if (col != null) {
+                for (Enumeration<Permission> e = col.elements(); e.hasMoreElements(); ) {
+                    perms.add(e.nextElement());
+                }
+            }
+            return this;
+        }
+        public Permissions toPermissions() {
+            final PermissionsBuilder builder = new PermissionsBuilder();
+            builder.addAll(perms);
+            return builder.perms;
+        }
+    }
+
+    public static class SimplePolicy extends Policy {
+
+        final Permissions permissions;
+        final Permissions allPermissions;
+        final ThreadLocal<AtomicBoolean> allowAll; // actually: this should be in a thread locale
+        public SimplePolicy(TestCase test, ThreadLocal<AtomicBoolean> allowAll) {
+            this.allowAll = allowAll;
+            permissions = new Permissions();
+            permissions.add(new LoggingPermission("control", null));
+            permissions.add(new FilePermission(PREFIX+".lck", "read,write,delete"));
+            permissions.add(new FilePermission(PREFIX, "read,write"));
+
+            // these are used for configuring the test itself...
+            allPermissions = new Permissions();
+            allPermissions.add(new java.security.AllPermission());
+
+        }
+
+        @Override
+        public boolean implies(ProtectionDomain domain, Permission permission) {
+            if (allowAll.get().get()) return allPermissions.implies(permission);
+            return permissions.implies(permission);
+        }
+
+        @Override
+        public PermissionCollection getPermissions(CodeSource codesource) {
+            return new PermissionsBuilder().addAll(allowAll.get().get()
+                    ? allPermissions : permissions).toPermissions();
+        }
+
+        @Override
+        public PermissionCollection getPermissions(ProtectionDomain domain) {
+            return new PermissionsBuilder().addAll(allowAll.get().get()
+                    ? allPermissions : permissions).toPermissions();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/pkcs11/Provider/LoginISE.java	Mon Oct 12 14:41:36 2015 -0700
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.security.*;
+import javax.security.auth.callback.*;
+
+/**
+ * @test
+ * @bug 8130648
+ * @summary make sure IllegalStateException is thrown for uninitialized
+ * SunPKCS11 provider instance
+ */
+public class LoginISE {
+
+    public static void main(String[] args) throws Exception {
+
+        Provider p = Security.getProvider("SunPKCS11");
+        if (p == null) {
+            System.out.println("No un-initialized PKCS11 provider available; skip");
+            return;
+        }
+        if (!(p instanceof AuthProvider)) {
+            throw new RuntimeException("Error: expect AuthProvider!");
+        }
+        AuthProvider ap = (AuthProvider) p;
+        if (ap.isConfigured()) {
+            throw new RuntimeException("Fail: isConfigured() should return false");
+        }
+        try {
+            ap.login(null, null);
+            throw new RuntimeException("Fail: expected ISE not thrown!");
+        } catch (IllegalStateException ise) {
+            System.out.println("Expected ISE thrown for login call");
+        }
+        try {
+            ap.logout();
+            throw new RuntimeException("Fail: expected ISE not thrown!");
+        } catch (IllegalStateException ise) {
+            System.out.println("Expected ISE thrown for logout call");
+        }
+        try {
+            ap.setCallbackHandler(new PasswordCallbackHandler());
+            throw new RuntimeException("Fail: expected ISE not thrown!");
+        } catch (IllegalStateException ise) {
+            System.out.println("Expected ISE thrown for logout call");
+        }
+
+        System.out.println("Test Passed");
+    }
+
+    public static class PasswordCallbackHandler implements CallbackHandler {
+        public void handle(Callback[] callbacks)
+                throws IOException, UnsupportedCallbackException {
+        }
+    }
+}
--- a/test/sun/security/provider/PolicyFile/CombinedPerms.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/test/sun/security/provider/PolicyFile/CombinedPerms.java	Mon Oct 12 14:41:36 2015 -0700
@@ -39,7 +39,7 @@
 
         String host = "localhost";
 
-        URL u = new URL("file:/home/duke");
+        URL u = new URL("file:/tmp/duke");
         CodeSource cs =
             new CodeSource(u, (java.security.cert.Certificate[]) null);
         Permissions p = new Permissions();
--- a/test/sun/security/provider/PolicyFile/CombinedPerms.policy	Mon Oct 12 16:26:58 2015 +0300
+++ b/test/sun/security/provider/PolicyFile/CombinedPerms.policy	Mon Oct 12 14:41:36 2015 -0700
@@ -1,3 +1,3 @@
-grant codebase "file:/home/duke" {
+grant codebase "file:/tmp/duke" {
     permission java.net.SocketPermission "localhost", "accept";
 };
--- a/test/sun/security/tools/jarsigner/TimestampCheck.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/test/sun/security/tools/jarsigner/TimestampCheck.java	Mon Oct 12 14:41:36 2015 -0700
@@ -40,7 +40,6 @@
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 
-import sun.misc.IOUtils;
 import sun.security.pkcs.ContentInfo;
 import sun.security.pkcs.PKCS7;
 import sun.security.pkcs.PKCS9Attribute;
@@ -343,7 +342,7 @@
         try (JarFile jf = new JarFile(file)) {
             JarEntry je = jf.getJarEntry("META-INF/OLD.RSA");
             try (InputStream is = jf.getInputStream(je)) {
-                byte[] content = IOUtils.readFully(is, -1, true);
+                byte[] content = is.readAllBytes();
                 PKCS7 p7 = new PKCS7(content);
                 SignerInfo[] si = p7.getSignerInfos();
                 if (si == null || si.length == 0) {
--- a/test/sun/security/util/DerValue/BadValue.java	Mon Oct 12 16:26:58 2015 +0300
+++ b/test/sun/security/util/DerValue/BadValue.java	Mon Oct 12 14:41:36 2015 -0700
@@ -25,13 +25,11 @@
  * @test
  * @bug 6864911
  * @summary ASN.1/DER input stream parser needs more work
- * @modules java.base/sun.misc
- *          java.base/sun.security.util
+ * @modules java.base/sun.security.util
  */
 
 import java.io.*;
 import sun.security.util.*;
-import sun.misc.IOUtils;
 
 public class BadValue {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/util/resources/TimeZone/Bug8139107.java	Mon Oct 12 14:41:36 2015 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8139107
+ * @summary Test that date parsing with DateTimeFormatter pattern
+ *   that contains timezone field doesn't trigger NPE. All supported
+ *   locales are tested.
+ * @run testng/othervm -Djava.locale.providers=JRE,SPI Bug8139107
+ */
+import java.time.format.DateTimeFormatter;
+import java.util.Locale;
+import org.testng.annotations.Test;
+
+public class Bug8139107 {
+
+    @Test
+    public void testSupportedLocales() {
+        for (Locale loc:Locale.getAvailableLocales()) {
+            testLocale(loc);
+        }
+    }
+
+    //Test one locale
+    void testLocale(Locale tl) {
+        System.out.println("Locale:" + tl);
+        DateTimeFormatter inputDateTimeFormat = DateTimeFormatter
+                .ofPattern(pattern)
+                .withLocale(tl);
+        System.out.println("Parse result: " + inputDateTimeFormat.parse(inputDate));
+    }
+
+    // Input date time string with short time zone name
+    static final String inputDate = "06-10-2015 18:58:04 MSK";
+    // Pattern with time zone field
+    static final String pattern = "dd-MM-yyyy HH:mm:ss z";
+}
+