changeset 16021:3bf26b1c7c7e

Merge
author prr
date Thu, 27 Oct 2016 09:42:08 -0700
parents 807349334f32 ee20b74f21f3
children 6e8788feb253
files src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java src/java.base/share/classes/sun/util/locale/provider/DictionaryBasedBreakIterator.java src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java src/java.base/windows/native/libnet/icmp.h test/sun/net/www/protocol/https/HttpsClient/OriginServer.java test/sun/reflect/ReflectionFactory/NewConstructorForSerialization.java test/sun/security/tools/jarsigner/ts.sh
diffstat 185 files changed, 6235 insertions(+), 4093 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Oct 27 09:38:46 2016 -0700
+++ b/.hgtags	Thu Oct 27 09:42:08 2016 -0700
@@ -383,3 +383,4 @@
 665096863382bf23ce891307cf2a7511e77c1c88 jdk-9+138
 5518ac2f2ead5e594bd983f2047178136aafdfd0 jdk-9+139
 e93b7ea559759f036c9f69fd2ddaf47bb4e98385 jdk-9+140
+8d752af5f61d41f226adf2cda72a20faa9ad620a jdk-9+141
--- a/make/gendata/GendataBreakIterator.gmk	Thu Oct 27 09:38:46 2016 -0700
+++ b/make/gendata/GendataBreakIterator.gmk	Thu Oct 27 09:42:08 2016 -0700
@@ -55,7 +55,6 @@
 $(eval $(call SetupJavaCompilation,BUILD_BREAKITERATOR_LD, \
     SETUP := GENERATE_OLDBYTECODE, \
     SRC := $(JDK_TOPDIR)/src/jdk.localedata/share/classes, \
-    INCLUDES := $(TEXT_PKG_LD), \
     INCLUDE_FILES := \
         $(TEXT_PKG_LD)/BreakIteratorRules_th.java \
         $(TEXT_PKG_LD)/BreakIteratorInfo_th.java, \
--- a/src/java.base/share/classes/java/io/FileInputStream.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/java/io/FileInputStream.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 package java.io;
 
 import java.nio.channels.FileChannel;
-import java.util.concurrent.atomic.AtomicBoolean;
 import sun.nio.ch.FileChannelImpl;
 
 
@@ -60,7 +59,9 @@
 
     private volatile FileChannel channel;
 
-    private final AtomicBoolean closed = new AtomicBoolean(false);
+    private final Object closeLock = new Object();
+
+    private volatile boolean closed;
 
     /**
      * Creates a <code>FileInputStream</code> by
@@ -313,14 +314,21 @@
      * @spec JSR-51
      */
     public void close() throws IOException {
-        if (!closed.compareAndSet(false, true)) {
-            // if compareAndSet() returns false closed was already true
+        if (closed) {
             return;
         }
+        synchronized (closeLock) {
+            if (closed) {
+                return;
+            }
+            closed = true;
+        }
 
         FileChannel fc = channel;
         if (fc != null) {
-           fc.close();
+            // possible race with getChannel(), benign since
+            // FileChannel.close is final and idempotent
+            fc.close();
         }
 
         fd.closeAll(new Closeable() {
@@ -370,8 +378,10 @@
                 fc = this.channel;
                 if (fc == null) {
                     this.channel = fc = FileChannelImpl.open(fd, path, true, false, this);
-                    if (closed.get()) {
+                    if (closed) {
                         try {
+                            // possible race with close(), benign since
+                            // FileChannel.close is final and idempotent
                             fc.close();
                         } catch (IOException ioe) {
                             throw new InternalError(ioe); // should not happen
--- a/src/java.base/share/classes/java/io/FileOutputStream.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/java/io/FileOutputStream.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 package java.io;
 
 import java.nio.channels.FileChannel;
-import java.util.concurrent.atomic.AtomicBoolean;
 import jdk.internal.misc.SharedSecrets;
 import jdk.internal.misc.JavaIOFileDescriptorAccess;
 import sun.nio.ch.FileChannelImpl;
@@ -77,7 +76,9 @@
      */
     private final String path;
 
-    private final AtomicBoolean closed = new AtomicBoolean(false);
+    private final Object closeLock = new Object();
+
+    private volatile boolean closed;
 
     /**
      * Creates a file output stream to write to the file with the
@@ -341,14 +342,21 @@
      * @spec JSR-51
      */
     public void close() throws IOException {
-        if (!closed.compareAndSet(false, true)) {
-            // if compareAndSet() returns false closed was already true
+        if (closed) {
             return;
         }
+        synchronized (closeLock) {
+            if (closed) {
+                return;
+            }
+            closed = true;
+        }
 
         FileChannel fc = channel;
         if (fc != null) {
-           fc.close();
+            // possible race with getChannel(), benign since
+            // FileChannel.close is final and idempotent
+            fc.close();
         }
 
         fd.closeAll(new Closeable() {
@@ -399,8 +407,10 @@
                 fc = this.channel;
                 if (fc == null) {
                     this.channel = fc = FileChannelImpl.open(fd, path, false, true, this);
-                    if (closed.get()) {
+                    if (closed) {
                         try {
+                            // possible race with close(), benign since
+                            // FileChannel.close is final and idempotent
                             fc.close();
                         } catch (IOException ioe) {
                             throw new InternalError(ioe); // should not happen
--- a/src/java.base/share/classes/java/io/ObjectStreamClass.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/java/io/ObjectStreamClass.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1413,27 +1413,7 @@
      * returned constructor (if any).
      */
     private static Constructor<?> getSerializableConstructor(Class<?> cl) {
-        Class<?> initCl = cl;
-        while (Serializable.class.isAssignableFrom(initCl)) {
-            if ((initCl = initCl.getSuperclass()) == null) {
-                return null;
-            }
-        }
-        try {
-            Constructor<?> cons = initCl.getDeclaredConstructor((Class<?>[]) null);
-            int mods = cons.getModifiers();
-            if ((mods & Modifier.PRIVATE) != 0 ||
-                ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) == 0 &&
-                 !packageEquals(cl, initCl)))
-            {
-                return null;
-            }
-            cons = reflFactory.newConstructorForSerialization(cl, cons);
-            cons.setAccessible(true);
-            return cons;
-        } catch (NoSuchMethodException ex) {
-            return null;
-        }
+        return reflFactory.newConstructorForSerialization(cl);
     }
 
     /**
--- a/src/java.base/share/classes/java/lang/ClassLoader.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/java/lang/ClassLoader.java	Thu Oct 27 09:42:08 2016 -0700
@@ -104,9 +104,9 @@
  * class or resource itself.
  *
  * <p> Class loaders that support concurrent loading of classes are known as
- * <em>parallel capable</em> class loaders and are required to register
- * themselves at their class initialization time by invoking the
- * {@link
+ * <em>{@linkplain #isParallelCapable() parallel capable}</em> class loaders and
+ * are required to register themselves at their class initialization time by
+ * invoking the {@link
  * #registerAsParallelCapable <tt>ClassLoader.registerAsParallelCapable</tt>}
  * method. Note that the <tt>ClassLoader</tt> class is registered as parallel
  * capable by default. However, its subclasses still need to register themselves
@@ -1437,7 +1437,7 @@
     }
 
     /**
-     * Registers the caller as parallel capable.
+     * Registers the caller as {@linkplain #isParallelCapable() parallel capable}.
      * The registration succeeds if and only if all of the following
      * conditions are met:
      * <ol>
@@ -1448,8 +1448,10 @@
      * <p>Note that once a class loader is registered as parallel capable, there
      * is no way to change it back.</p>
      *
-     * @return  true if the caller is successfully registered as
-     *          parallel capable and false if otherwise.
+     * @return  {@code true} if the caller is successfully registered as
+     *          parallel capable and {@code false} if otherwise.
+     *
+     * @see #isParallelCapable()
      *
      * @since   1.7
      */
@@ -1461,6 +1463,22 @@
     }
 
     /**
+     * Returns {@code true} if this class loader is
+     * {@linkplain #registerAsParallelCapable parallel capable}, otherwise
+     * {@code false}.
+     *
+     * @return  {@code true} if this class loader is parallel capable,
+     *          otherwise {@code false}.
+     *
+     * @see #registerAsParallelCapable()
+     *
+     * @since   9
+     */
+    public final boolean isParallelCapable() {
+        return ParallelLoaders.isRegistered(this.getClass());
+    }
+
+    /**
      * Find a resource of the specified name from the search path used to load
      * classes.  This method locates the resource through the system class
      * loader (see {@link #getSystemClassLoader()}).
--- a/src/java.base/share/classes/java/net/InetAddress.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/java/net/InetAddress.java	Thu Oct 27 09:42:08 2016 -0700
@@ -201,13 +201,13 @@
      * Specify the address family: Internet Protocol, Version 4
      * @since 1.4
      */
-    static final int IPv4 = 1;
+    @Native static final int IPv4 = 1;
 
     /**
      * Specify the address family: Internet Protocol, Version 6
      * @since 1.4
      */
-    static final int IPv6 = 2;
+    @Native static final int IPv6 = 2;
 
     /* Specify address family preference */
     static transient final int preferIPv6Address;
@@ -321,6 +321,13 @@
                     public String getOriginalHostName(InetAddress ia) {
                         return ia.holder.getOriginalHostName();
                     }
+
+                    public InetAddress getByName(String hostName,
+                                                 InetAddress hostAddress)
+                            throws UnknownHostException
+                    {
+                        return InetAddress.getByName(hostName, hostAddress);
+                    }
                 }
         );
         init();
--- a/src/java.base/share/classes/java/net/URLClassLoader.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/java/net/URLClassLoader.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,6 +51,8 @@
 
 import jdk.internal.loader.Resource;
 import jdk.internal.loader.URLClassPath;
+import jdk.internal.misc.JavaNetURLClassLoaderAccess;
+import jdk.internal.misc.SharedSecrets;
 import jdk.internal.perf.PerfCounter;
 import sun.net.www.ParseUtil;
 import sun.security.util.SecurityConstants;
@@ -765,6 +767,14 @@
     }
 
     static {
+        SharedSecrets.setJavaNetURLClassLoaderAccess(
+            new JavaNetURLClassLoaderAccess() {
+                @Override
+                public AccessControlContext getAccessControlContext(URLClassLoader u) {
+                    return u.acc;
+                }
+            }
+        );
         ClassLoader.registerAsParallelCapable();
     }
 }
--- a/src/java.base/share/classes/java/security/ProtectionDomain.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/java/security/ProtectionDomain.java	Thu Oct 27 09:42:08 2016 -0700
@@ -89,6 +89,11 @@
                 AccessController.getContext(), context);
         }
 
+        @Override
+        public ProtectionDomain[] getProtectDomains(AccessControlContext context) {
+            return context.getContext();
+        }
+
         private static AccessControlContext getCombinedACC(
             AccessControlContext context, AccessControlContext stack) {
             AccessControlContext acc =
--- a/src/java.base/share/classes/java/time/chrono/HijrahDate.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/java/time/chrono/HijrahDate.java	Thu Oct 27 09:42:08 2016 -0700
@@ -368,7 +368,7 @@
         if (field instanceof ChronoField) {
             switch ((ChronoField) field) {
                 case DAY_OF_WEEK: return getDayOfWeek();
-                case ALIGNED_DAY_OF_WEEK_IN_MONTH: return ((getDayOfWeek() - 1) % 7) + 1;
+                case ALIGNED_DAY_OF_WEEK_IN_MONTH: return ((dayOfMonth - 1) % 7) + 1;
                 case ALIGNED_DAY_OF_WEEK_IN_YEAR: return ((getDayOfYear() - 1) % 7) + 1;
                 case DAY_OF_MONTH: return this.dayOfMonth;
                 case DAY_OF_YEAR: return this.getDayOfYear();
--- a/src/java.base/share/classes/java/time/format/DateTimeTextProvider.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/java/time/format/DateTimeTextProvider.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -349,25 +349,40 @@
 
         if (field == MONTH_OF_YEAR) {
             for (TextStyle textStyle : TextStyle.values()) {
-                Map<String, Integer> displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames(
-                        "gregory", Calendar.MONTH, textStyle.toCalendarStyle(), locale);
                 Map<Long, String> map = new HashMap<>();
-                if (displayNames != null) {
-                    for (Entry<String, Integer> entry : displayNames.entrySet()) {
-                        map.put((long) (entry.getValue() + 1), entry.getKey());
-                    }
-
-                } else {
-                    // Narrow names may have duplicated names, such as "J" for January, Jun, July.
-                    // Get names one by one in that case.
+                // Narrow names may have duplicated names, such as "J" for January, June, July.
+                // Get names one by one in that case.
+                if ((textStyle.equals(TextStyle.NARROW) ||
+                        textStyle.equals(TextStyle.NARROW_STANDALONE))) {
                     for (int month = Calendar.JANUARY; month <= Calendar.DECEMBER; month++) {
                         String name;
                         name = CalendarDataUtility.retrieveJavaTimeFieldValueName(
-                                "gregory", Calendar.MONTH, month, textStyle.toCalendarStyle(), locale);
+                                "gregory", Calendar.MONTH,
+                                month, textStyle.toCalendarStyle(), locale);
                         if (name == null) {
                             break;
                         }
-                        map.put((long) (month + 1), name);
+                        map.put((month + 1L), name);
+                    }
+                } else {
+                    Map<String, Integer> displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames(
+                            "gregory", Calendar.MONTH, textStyle.toCalendarStyle(), locale);
+                    if (displayNames != null) {
+                        for (Entry<String, Integer> entry : displayNames.entrySet()) {
+                            map.put((long)(entry.getValue() + 1), entry.getKey());
+                        }
+                    } else {
+                        // Although probability is very less, but if other styles have duplicate names.
+                        // Get names one by one in that case.
+                        for (int month = Calendar.JANUARY; month <= Calendar.DECEMBER; month++) {
+                            String name;
+                            name = CalendarDataUtility.retrieveJavaTimeFieldValueName(
+                                    "gregory", Calendar.MONTH, month, textStyle.toCalendarStyle(), locale);
+                            if (name == null) {
+                                break;
+                            }
+                            map.put((month + 1L), name);
+                        }
                     }
                 }
                 if (!map.isEmpty()) {
@@ -379,26 +394,41 @@
 
         if (field == DAY_OF_WEEK) {
             for (TextStyle textStyle : TextStyle.values()) {
-                Map<String, Integer> displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames(
-                        "gregory", Calendar.DAY_OF_WEEK, textStyle.toCalendarStyle(), locale);
                 Map<Long, String> map = new HashMap<>();
-                if (displayNames != null) {
-                    for (Entry<String, Integer> entry : displayNames.entrySet()) {
-                        map.put((long)toWeekDay(entry.getValue()), entry.getKey());
-                    }
-
-                } else {
-                    // Narrow names may have duplicated names, such as "S" for Sunday and Saturday.
-                    // Get names one by one in that case.
+                // Narrow names may have duplicated names, such as "S" for Sunday and Saturday.
+                // Get names one by one in that case.
+                if ((textStyle.equals(TextStyle.NARROW) ||
+                        textStyle.equals(TextStyle.NARROW_STANDALONE))) {
                     for (int wday = Calendar.SUNDAY; wday <= Calendar.SATURDAY; wday++) {
                         String name;
                         name = CalendarDataUtility.retrieveJavaTimeFieldValueName(
-                            "gregory", Calendar.DAY_OF_WEEK, wday, textStyle.toCalendarStyle(), locale);
+                                "gregory", Calendar.DAY_OF_WEEK,
+                                wday, textStyle.toCalendarStyle(), locale);
                         if (name == null) {
                             break;
                         }
                         map.put((long)toWeekDay(wday), name);
                     }
+                } else {
+                    Map<String, Integer> displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames(
+                            "gregory", Calendar.DAY_OF_WEEK, textStyle.toCalendarStyle(), locale);
+                    if (displayNames != null) {
+                        for (Entry<String, Integer> entry : displayNames.entrySet()) {
+                            map.put((long)toWeekDay(entry.getValue()), entry.getKey());
+                        }
+                    } else {
+                        // Although probability is very less, but if other styles have duplicate names.
+                        // Get names one by one in that case.
+                        for (int wday = Calendar.SUNDAY; wday <= Calendar.SATURDAY; wday++) {
+                            String name;
+                            name = CalendarDataUtility.retrieveJavaTimeFieldValueName(
+                                    "gregory", Calendar.DAY_OF_WEEK, wday, textStyle.toCalendarStyle(), locale);
+                            if (name == null) {
+                                break;
+                            }
+                            map.put((long)toWeekDay(wday), name);
+                        }
+                    }
                 }
                 if (!map.isEmpty()) {
                     styleMap.put(textStyle, map);
--- a/src/java.base/share/classes/java/util/Optional.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/java/util/Optional.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -236,7 +236,7 @@
      *         present, otherwise an empty {@code Optional}
      * @throws NullPointerException if the mapping function is {@code null}
      */
-    public<U> Optional<U> map(Function<? super T, ? extends U> mapper) {
+    public <U> Optional<U> map(Function<? super T, ? extends U> mapper) {
         Objects.requireNonNull(mapper);
         if (!isPresent()) {
             return empty();
@@ -264,12 +264,14 @@
      * @throws NullPointerException if the mapping function is {@code null} or
      *         returns a {@code null} result
      */
-    public<U> Optional<U> flatMap(Function<? super T, Optional<U>> mapper) {
+    public <U> Optional<U> flatMap(Function<? super T, ? extends Optional<? extends U>> mapper) {
         Objects.requireNonNull(mapper);
         if (!isPresent()) {
             return empty();
         } else {
-            return Objects.requireNonNull(mapper.apply(value));
+            @SuppressWarnings("unchecked")
+            Optional<U> r = (Optional<U>) mapper.apply(value);
+            return Objects.requireNonNull(r);
         }
     }
 
@@ -286,12 +288,14 @@
      *         produces a {@code null} result
      * @since 9
      */
-    public Optional<T> or(Supplier<Optional<T>> supplier) {
+    public Optional<T> or(Supplier<? extends Optional<? extends T>> supplier) {
         Objects.requireNonNull(supplier);
         if (isPresent()) {
             return this;
         } else {
-            return Objects.requireNonNull(supplier.get());
+            @SuppressWarnings("unchecked")
+            Optional<T> r = (Optional<T>) supplier.get();
+            return Objects.requireNonNull(r);
         }
     }
 
--- a/src/java.base/share/classes/java/util/PropertyResourceBundle.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/java/util/PropertyResourceBundle.java	Thu Oct 27 09:42:08 2016 -0700
@@ -63,7 +63,7 @@
  * files containing the resource data.  <code>ResourceBundle.getBundle</code>
  * will automatically look for the appropriate properties file and create a
  * <code>PropertyResourceBundle</code> that refers to it. See
- * {@link ResourceBundle#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader) ResourceBundle.getBundle}
+ * {@link ResourceBundle#getBundle(String, Locale, ClassLoader) ResourceBundle.getBundle}
  * for a complete description of the search and instantiation strategy.
  *
  * <p>
@@ -105,19 +105,14 @@
  * </pre>
  * </blockquote>
  *
- * <p>
- * The implementation of a {@code PropertyResourceBundle} subclass must be
- * thread-safe if it's simultaneously used by multiple threads. The default
- * implementations of the non-abstract methods in this class are thread-safe.
- *
- * <p>
- * <strong>Note:</strong> PropertyResourceBundle can be constructed either
- * from an InputStream or a Reader, which represents a property file.
- * Constructing a PropertyResourceBundle instance from an InputStream requires
- * that the input stream be encoded in UTF-8. By default, if a
+ * @apiNote
+ * {@code PropertyResourceBundle} can be constructed either
+ * from an {@code InputStream} or a {@code Reader}, which represents a property file.
+ * Constructing a {@code PropertyResourceBundle} instance from an {@code InputStream}
+ * requires that the input stream be encoded in {@code UTF-8}. By default, if a
  * {@link java.nio.charset.MalformedInputException} or an
  * {@link java.nio.charset.UnmappableCharacterException} occurs on reading the
- * input stream, then the PropertyResourceBundle instance resets to the state
+ * input stream, then the {@code PropertyResourceBundle} instance resets to the state
  * before the exception, re-reads the input stream in {@code ISO-8859-1}, and
  * continues reading. If the system property
  * {@code java.util.PropertyResourceBundle.encoding} is set to either
@@ -126,8 +121,15 @@
  * If "ISO-8859-1" is specified, characters that cannot be represented in
  * ISO-8859-1 encoding must be represented by Unicode Escapes as defined in section
  * 3.3 of <cite>The Java&trade; Language Specification</cite>
- * whereas the other constructor which takes a Reader does not have that limitation.
+ * whereas the other constructor which takes a {@code Reader} does not have that limitation.
  * Other encoding values are ignored for this system property.
+ * The system property is read and evaluated when initializing this class.
+ * Changing or removing the property has no effect after the initialization.
+ *
+ * @implSpec
+ * The implementation of a {@code PropertyResourceBundle} subclass must be
+ * thread-safe if it's simultaneously used by multiple threads. The default
+ * implementations of the non-abstract methods in this class are thread-safe.
  *
  * @see ResourceBundle
  * @see ListResourceBundle
@@ -144,16 +146,18 @@
 
     /**
      * Creates a property resource bundle from an {@link java.io.InputStream
-    * InputStream}. This constructor reads the property file in UTF-8 by default.
-    * If a {@link java.nio.charset.MalformedInputException} or an
-    * {@link java.nio.charset.UnmappableCharacterException} occurs on reading the
-    * input stream, then the PropertyResourceBundle instance resets to the state
-    * before the exception, re-reads the input stream in {@code ISO-8859-1} and
-    * continues reading. If the system property
-    * {@code java.util.PropertyResourceBundle.encoding} is set to either
-    * "ISO-8859-1" or "UTF-8", the input stream is solely read in that encoding,
-    * and throws the exception if it encounters an invalid sequence. Other
-    * encoding values are ignored for this system property.
+     * InputStream}. This constructor reads the property file in UTF-8 by default.
+     * If a {@link java.nio.charset.MalformedInputException} or an
+     * {@link java.nio.charset.UnmappableCharacterException} occurs on reading the
+     * input stream, then the PropertyResourceBundle instance resets to the state
+     * before the exception, re-reads the input stream in {@code ISO-8859-1} and
+     * continues reading. If the system property
+     * {@code java.util.PropertyResourceBundle.encoding} is set to either
+     * "ISO-8859-1" or "UTF-8", the input stream is solely read in that encoding,
+     * and throws the exception if it encounters an invalid sequence. Other
+     * encoding values are ignored for this system property.
+     * The system property is read and evaluated when initializing this class.
+     * Changing or removing the property has no effect after the initialization.
      *
      * @param stream an InputStream that represents a property file
      *        to read from.
--- a/src/java.base/share/classes/jdk/internal/misc/JavaNetInetAddressAccess.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/jdk/internal/misc/JavaNetInetAddressAccess.java	Thu Oct 27 09:42:08 2016 -0700
@@ -26,6 +26,7 @@
 package jdk.internal.misc;
 
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 
 public interface JavaNetInetAddressAccess {
     /**
@@ -33,4 +34,13 @@
      * the given InetAddress object.
      */
     String getOriginalHostName(InetAddress ia);
+
+    /**
+     * Get the InetAddress of the provided host. If an InetAddress is provided
+     * then it will be the default address returned for all calls to either
+     * form of getByName. This is required to maintain consistency when
+     * caching addresses and hostnames.
+     */
+    InetAddress getByName(String hostName, InetAddress hostAddress)
+            throws UnknownHostException;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/jdk/internal/misc/JavaNetURLClassLoaderAccess.java	Thu Oct 27 09:42:08 2016 -0700
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  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 jdk.internal.misc;
+
+import java.net.URLClassLoader;
+import java.security.AccessControlContext;
+
+public interface JavaNetURLClassLoaderAccess {
+    AccessControlContext getAccessControlContext(URLClassLoader u);;
+}
--- a/src/java.base/share/classes/jdk/internal/misc/JavaSecurityAccess.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/jdk/internal/misc/JavaSecurityAccess.java	Thu Oct 27 09:42:08 2016 -0700
@@ -27,6 +27,7 @@
 
 import java.security.AccessControlContext;
 import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
 
 public interface JavaSecurityAccess {
 
@@ -37,4 +38,5 @@
     <T> T doIntersectionPrivilege(PrivilegedAction<T> action,
                                   AccessControlContext context);
 
+    ProtectionDomain[] getProtectDomains(AccessControlContext context);
 }
--- a/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java	Thu Oct 27 09:42:08 2016 -0700
@@ -57,6 +57,7 @@
     private static JavaNetHttpCookieAccess javaNetHttpCookieAccess;
     private static JavaNetSocketAccess javaNetSocketAccess;
     private static JavaNetUriAccess javaNetUriAccess;
+    private static JavaNetURLClassLoaderAccess javaNetURLClassLoaderAccess;
     private static JavaNioAccess javaNioAccess;
     private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
     private static JavaIOFilePermissionAccess javaIOFilePermissionAccess;
@@ -144,6 +145,16 @@
         return javaNetUriAccess;
     }
 
+    public static void setJavaNetURLClassLoaderAccess(JavaNetURLClassLoaderAccess jnua) {
+        javaNetURLClassLoaderAccess = jnua;
+    }
+
+    public static JavaNetURLClassLoaderAccess getJavaNetURLClassLoaderAccess() {
+        if (javaNetURLClassLoaderAccess == null)
+            unsafe.ensureClassInitialized(java.net.URLClassLoader.class);
+        return javaNetURLClassLoaderAccess;
+    }
+
     public static void setJavaNetInetAddressAccess(JavaNetInetAddressAccess jna) {
         javaNetInetAddressAccess = jna;
     }
--- a/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,25 @@
 
 package jdk.internal.reflect;
 
+import java.io.Externalizable;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.io.OptionalDataException;
+import java.io.Serializable;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
 import java.lang.reflect.Field;
 import java.lang.reflect.Executable;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Modifier;
 import java.security.Permission;
 import java.security.PrivilegedAction;
+import java.util.Objects;
 import java.util.Properties;
+
 import sun.reflect.misc.ReflectUtil;
 import sun.security.action.GetPropertyAction;
 
@@ -57,6 +68,9 @@
     // Provides access to package-private mechanisms in java.lang.reflect
     private static volatile LangReflectAccess langReflectAccess;
 
+    /* Method for static class initializer <clinit>, or null */
+    private static volatile Method hasStaticInitializerMethod;
+
     //
     // "Inflation" mechanism. Loading bytecodes to implement
     // Method.invoke() and Constructor.newInstance() currently costs
@@ -337,16 +351,41 @@
     //
     //
 
-    public Constructor<?> newConstructorForSerialization
-        (Class<?> classToInstantiate, Constructor<?> constructorToCall)
-    {
-        // Fast path
-        if (constructorToCall.getDeclaringClass() == classToInstantiate) {
-            return constructorToCall;
+    public final Constructor<?> newConstructorForExternalization(Class<?> cl) {
+        if (!Externalizable.class.isAssignableFrom(cl)) {
+            return null;
+        }
+        try {
+            Constructor<?> cons = cl.getConstructor();
+            cons.setAccessible(true);
+            return cons;
+        } catch (NoSuchMethodException ex) {
+            return null;
+        }
+    }
+
+    public final Constructor<?> newConstructorForSerialization(Class<?> cl) {
+        Class<?> initCl = cl;
+        while (Serializable.class.isAssignableFrom(initCl)) {
+            if ((initCl = initCl.getSuperclass()) == null) {
+                return null;
+            }
+        }
+        Constructor<?> constructorToCall;
+        try {
+            constructorToCall = initCl.getDeclaredConstructor();
+            int mods = constructorToCall.getModifiers();
+            if ((mods & Modifier.PRIVATE) != 0 ||
+                    ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) == 0 &&
+                            !packageEquals(cl, initCl))) {
+                return null;
+            }
+        } catch (NoSuchMethodException ex) {
+            return null;
         }
 
         ConstructorAccessor acc = new MethodAccessorGenerator().
-            generateSerializationConstructor(classToInstantiate,
+            generateSerializationConstructor(cl,
                                              constructorToCall.getParameterTypes(),
                                              constructorToCall.getExceptionTypes(),
                                              constructorToCall.getModifiers(),
@@ -364,9 +403,151 @@
                                           langReflectAccess().
                                           getConstructorParameterAnnotations(constructorToCall));
         setConstructorAccessor(c, acc);
+        c.setAccessible(true);
         return c;
     }
 
+    public final MethodHandle readObjectForSerialization(Class<?> cl) {
+        return findReadWriteObjectForSerialization(cl, "readObject", ObjectInputStream.class);
+    }
+
+    public final MethodHandle readObjectNoDataForSerialization(Class<?> cl) {
+        return findReadWriteObjectForSerialization(cl, "readObjectNoData", ObjectInputStream.class);
+    }
+
+    public final MethodHandle writeObjectForSerialization(Class<?> cl) {
+        return findReadWriteObjectForSerialization(cl, "writeObject", ObjectOutputStream.class);
+    }
+
+    private final MethodHandle findReadWriteObjectForSerialization(Class<?> cl,
+                                                                   String methodName,
+                                                                   Class<?> streamClass) {
+        if (!Serializable.class.isAssignableFrom(cl)) {
+            return null;
+        }
+
+        try {
+            Method meth = cl.getDeclaredMethod(methodName, streamClass);
+            int mods = meth.getModifiers();
+            if (meth.getReturnType() != Void.TYPE ||
+                    Modifier.isStatic(mods) ||
+                    !Modifier.isPrivate(mods)) {
+                return null;
+            }
+            meth.setAccessible(true);
+            return MethodHandles.lookup().unreflect(meth);
+        } catch (NoSuchMethodException ex) {
+            return null;
+        } catch (IllegalAccessException ex1) {
+            throw new InternalError("Error", ex1);
+        }
+    }
+
+    /**
+     * Returns a MethodHandle for {@code writeReplace} on the serializable class
+     * or null if no match found.
+     * @param cl a serializable class
+     * @returnss the {@code writeReplace} MethodHandle or {@code null} if not found
+     */
+    public final MethodHandle writeReplaceForSerialization(Class<?> cl) {
+        return getReplaceResolveForSerialization(cl, "writeReplace");
+    }
+
+    /**
+     * Returns a MethodHandle for {@code readResolve} on the serializable class
+     * or null if no match found.
+     * @param cl a serializable class
+     * @returns the {@code writeReplace} MethodHandle or {@code null} if not found
+     */
+    public final MethodHandle readResolveForSerialization(Class<?> cl) {
+        return getReplaceResolveForSerialization(cl, "readResolve");
+    }
+
+    /**
+     * Lookup readResolve or writeReplace on a class with specified
+     * signature constraints.
+     * @param cl a serializable class
+     * @param methodName the method name to find
+     * @returns a MethodHandle for the method or {@code null} if not found or
+     *       has the wrong signature.
+     */
+    private MethodHandle getReplaceResolveForSerialization(Class<?> cl,
+                                                           String methodName) {
+        if (!Serializable.class.isAssignableFrom(cl)) {
+            return null;
+        }
+
+        Class<?> defCl = cl;
+        while (defCl != null) {
+            try {
+                Method m = defCl.getDeclaredMethod(methodName);
+                if (m.getReturnType() != Object.class) {
+                    return null;
+                }
+                int mods = m.getModifiers();
+                if (Modifier.isStatic(mods) | Modifier.isAbstract(mods)) {
+                    return null;
+                } else if (Modifier.isPublic(mods) | Modifier.isProtected(mods)) {
+                    // fall through
+                } else if (Modifier.isPrivate(mods) && (cl != defCl)) {
+                    return null;
+                } else if (!packageEquals(cl, defCl)) {
+                    return null;
+                }
+                try {
+                    // Normal return
+                    m.setAccessible(true);
+                    return MethodHandles.lookup().unreflect(m);
+                } catch (IllegalAccessException ex0) {
+                    // setAccessible should prevent IAE
+                    throw new InternalError("Error", ex0);
+                }
+            } catch (NoSuchMethodException ex) {
+                defCl = defCl.getSuperclass();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Returns true if the given class defines a static initializer method,
+     * false otherwise.
+     */
+    public final boolean hasStaticInitializerForSerialization(Class<?> cl) {
+        Method m = hasStaticInitializerMethod;
+        if (m == null) {
+            try {
+                m = ObjectStreamClass.class.getDeclaredMethod("hasStaticInitializer",
+                        new Class<?>[]{Class.class});
+                m.setAccessible(true);
+                hasStaticInitializerMethod = m;
+            } catch (NoSuchMethodException ex) {
+                throw new InternalError("No such method hasStaticInitializer on "
+                        + ObjectStreamClass.class, ex);
+            }
+        }
+        try {
+            return (Boolean) m.invoke(null, cl);
+        } catch (InvocationTargetException | IllegalAccessException ex) {
+            throw new InternalError("Exception invoking hasStaticInitializer", ex);
+        }
+    }
+
+    /**
+     * Return the accessible constructor for OptionalDataException signaling eof.
+     * @returns the eof constructor for OptionalDataException
+     */
+    public final Constructor<OptionalDataException> newOptionalDataExceptionForSerialization() {
+        try {
+            Constructor<OptionalDataException> boolCtor =
+                    OptionalDataException.class.getDeclaredConstructor(Boolean.TYPE);
+            boolCtor.setAccessible(true);
+            return boolCtor;
+        } catch (NoSuchMethodException ex) {
+            throw new InternalError("Constructor not found", ex);
+        }
+    }
+
     //--------------------------------------------------------------------------
     //
     // Internals only below this point
@@ -426,4 +607,17 @@
         }
         return langReflectAccess;
     }
+
+    /**
+     * Returns true if classes are defined in the classloader and same package, false
+     * otherwise.
+     * @param cl1 a class
+     * @param cl2 another class
+     * @returns true if the two classes are in the same classloader and package
+     */
+    private static boolean packageEquals(Class<?> cl1, Class<?> cl2) {
+        return cl1.getClassLoader() == cl2.getClassLoader() &&
+                Objects.equals(cl1.getPackage(), cl2.getPackage());
+    }
+
 }
--- a/src/java.base/share/classes/module-info.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/module-info.java	Thu Oct 27 09:42:08 2016 -0700
@@ -240,8 +240,7 @@
         java.xml.ws;
     exports sun.security.action to
         java.desktop,
-        java.security.jgss,
-        jdk.crypto.pkcs11;
+        java.security.jgss;
     exports sun.security.internal.interfaces to
         jdk.crypto.pkcs11;
     exports sun.security.internal.spec to
@@ -267,6 +266,8 @@
         jdk.crypto.pkcs11;
     exports sun.security.ssl to
         java.security.jgss;
+    exports sun.security.timestamp to
+        jdk.jartool;
     exports sun.security.tools to
         jdk.jartool;
     exports sun.security.util to
--- a/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java	Thu Oct 27 09:42:08 2016 -0700
@@ -498,6 +498,23 @@
         return unauthenticatedAttributes;
     }
 
+    /**
+     * Returns the timestamp PKCS7 data unverified.
+     * @return a PKCS7 object
+     */
+    public PKCS7 getTsToken() throws IOException {
+        if (unauthenticatedAttributes == null) {
+            return null;
+        }
+        PKCS9Attribute tsTokenAttr =
+                unauthenticatedAttributes.getAttribute(
+                        PKCS9Attribute.SIGNATURE_TIMESTAMP_TOKEN_OID);
+        if (tsTokenAttr == null) {
+            return null;
+        }
+        return new PKCS7((byte[])tsTokenAttr.getValue());
+    }
+
     /*
      * Extracts a timestamp from a PKCS7 SignerInfo.
      *
@@ -525,19 +542,12 @@
         if (timestamp != null || !hasTimestamp)
             return timestamp;
 
-        if (unauthenticatedAttributes == null) {
-            hasTimestamp = false;
-            return null;
-        }
-        PKCS9Attribute tsTokenAttr =
-            unauthenticatedAttributes.getAttribute(
-                PKCS9Attribute.SIGNATURE_TIMESTAMP_TOKEN_OID);
-        if (tsTokenAttr == null) {
+        PKCS7 tsToken = getTsToken();
+        if (tsToken == null) {
             hasTimestamp = false;
             return null;
         }
 
-        PKCS7 tsToken = new PKCS7((byte[])tsTokenAttr.getValue());
         // Extract the content (an encoded timestamp token info)
         byte[] encTsTokenInfo = tsToken.getContentInfo().getData();
         // Extract the signer (the Timestamping Authority)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/sun/text/BreakDictionary.java	Thu Oct 27 09:42:08 2016 -0700
@@ -0,0 +1,306 @@
+/*
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ *
+ * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1996 - 2002 - All Rights Reserved
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ */
+package sun.text;
+
+import java.nio.BufferUnderflowException;
+import java.nio.ByteBuffer;
+import java.util.MissingResourceException;
+import sun.text.CompactByteArray;
+import sun.text.SupplementaryCharacterData;
+
+/**
+ * This is the class that represents the list of known words used by
+ * DictionaryBasedBreakIterator.  The conceptual data structure used
+ * here is a trie: there is a node hanging off the root node for every
+ * letter that can start a word.  Each of these nodes has a node hanging
+ * off of it for every letter that can be the second letter of a word
+ * if this node is the first letter, and so on.  The trie is represented
+ * as a two-dimensional array that can be treated as a table of state
+ * transitions.  Indexes are used to compress this array, taking
+ * advantage of the fact that this array will always be very sparse.
+ */
+class BreakDictionary {
+
+    //=========================================================================
+    // data members
+    //=========================================================================
+
+    /**
+      * The version of the dictionary that was read in.
+      */
+    private static int supportedVersion = 1;
+
+    /**
+     * Maps from characters to column numbers.  The main use of this is to
+     * avoid making room in the array for empty columns.
+     */
+    private CompactByteArray columnMap = null;
+    private SupplementaryCharacterData supplementaryCharColumnMap = null;
+
+    /**
+     * The number of actual columns in the table
+     */
+    private int numCols;
+
+    /**
+     * Columns are organized into groups of 32.  This says how many
+     * column groups.  (We could calculate this, but we store the
+     * value to avoid having to repeatedly calculate it.)
+     */
+    private int numColGroups;
+
+    /**
+     * The actual compressed state table.  Each conceptual row represents
+     * a state, and the cells in it contain the row numbers of the states
+     * to transition to for each possible letter.  0 is used to indicate
+     * an illegal combination of letters (i.e., the error state).  The
+     * table is compressed by eliminating all the unpopulated (i.e., zero)
+     * cells.  Multiple conceptual rows can then be doubled up in a single
+     * physical row by sliding them up and possibly shifting them to one
+     * side or the other so the populated cells don't collide.  Indexes
+     * are used to identify unpopulated cells and to locate populated cells.
+     */
+    private short[] table = null;
+
+    /**
+     * This index maps logical row numbers to physical row numbers
+     */
+    private short[] rowIndex = null;
+
+    /**
+     * A bitmap is used to tell which cells in the comceptual table are
+     * populated.  This array contains all the unique bit combinations
+     * in that bitmap.  If the table is more than 32 columns wide,
+     * successive entries in this array are used for a single row.
+     */
+    private int[] rowIndexFlags = null;
+
+    /**
+     * This index maps from a logical row number into the bitmap table above.
+     * (This keeps us from storing duplicate bitmap combinations.)  Since there
+     * are a lot of rows with only one populated cell, instead of wasting space
+     * in the bitmap table, we just store a negative number in this index for
+     * rows with one populated cell.  The absolute value of that number is
+     * the column number of the populated cell.
+     */
+    private short[] rowIndexFlagsIndex = null;
+
+    /**
+     * For each logical row, this index contains a constant that is added to
+     * the logical column number to get the physical column number
+     */
+    private byte[] rowIndexShifts = null;
+
+    //=========================================================================
+    // deserialization
+    //=========================================================================
+
+    BreakDictionary(String dictionaryName, byte[] dictionaryData) {
+        try {
+            setupDictionary(dictionaryName, dictionaryData);
+        } catch (BufferUnderflowException bue) {
+            MissingResourceException e;
+            e = new MissingResourceException("Corrupted dictionary data",
+                                             dictionaryName, "");
+            e.initCause(bue);
+            throw e;
+        }
+    }
+
+    private void setupDictionary(String dictionaryName, byte[] dictionaryData) {
+        ByteBuffer bb = ByteBuffer.wrap(dictionaryData);
+
+        // check version
+        int version = bb.getInt();
+        if (version != supportedVersion) {
+            throw new MissingResourceException("Dictionary version(" + version + ") is unsupported",
+                                               dictionaryName, "");
+        }
+
+        // Check data size
+        int len = bb.getInt();
+        if (bb.position() + len != bb.limit()) {
+            throw new MissingResourceException("Dictionary size is wrong: " + bb.limit(),
+                                               dictionaryName, "");
+        }
+
+        // read in the column map for BMP characteres (this is serialized in
+        // its internal form: an index array followed by a data array)
+        len = bb.getInt();
+        short[] temp = new short[len];
+        for (int i = 0; i < len; i++) {
+            temp[i] = bb.getShort();
+        }
+        len = bb.getInt();
+        byte[] temp2 = new byte[len];
+        bb.get(temp2);
+        columnMap = new CompactByteArray(temp, temp2);
+
+        // read in numCols and numColGroups
+        numCols = bb.getInt();
+        numColGroups = bb.getInt();
+
+        // read in the row-number index
+        len = bb.getInt();
+        rowIndex = new short[len];
+        for (int i = 0; i < len; i++) {
+            rowIndex[i] = bb.getShort();
+        }
+
+        // load in the populated-cells bitmap: index first, then bitmap list
+        len = bb.getInt();
+        rowIndexFlagsIndex = new short[len];
+        for (int i = 0; i < len; i++) {
+            rowIndexFlagsIndex[i] = bb.getShort();
+        }
+        len = bb.getInt();
+        rowIndexFlags = new int[len];
+        for (int i = 0; i < len; i++) {
+            rowIndexFlags[i] = bb.getInt();
+        }
+
+        // load in the row-shift index
+        len = bb.getInt();
+        rowIndexShifts = new byte[len];
+        bb.get(rowIndexShifts);
+
+        // load in the actual state table
+        len = bb.getInt();
+        table = new short[len];
+        for (int i = 0; i < len; i++) {
+            table[i] = bb.getShort();
+        }
+
+        // finally, prepare the column map for supplementary characters
+        len = bb.getInt();
+        int[] temp3 = new int[len];
+        for (int i = 0; i < len; i++) {
+            temp3[i] = bb.getInt();
+        }
+        assert bb.position() == bb.limit();
+
+        supplementaryCharColumnMap = new SupplementaryCharacterData(temp3);
+    }
+
+    //=========================================================================
+    // access to the words
+    //=========================================================================
+
+    /**
+     * Uses the column map to map the character to a column number, then
+     * passes the row and column number to getNextState()
+     * @param row The current state
+     * @param ch The character whose column we're interested in
+     * @return The new state to transition to
+     */
+    public final short getNextStateFromCharacter(int row, int ch) {
+        int col;
+        if (ch < Character.MIN_SUPPLEMENTARY_CODE_POINT) {
+            col = columnMap.elementAt((char)ch);
+        } else {
+            col = supplementaryCharColumnMap.getValue(ch);
+        }
+        return getNextState(row, col);
+    }
+
+    /**
+     * Returns the value in the cell with the specified (logical) row and
+     * column numbers.  In DictionaryBasedBreakIterator, the row number is
+     * a state number, the column number is an input, and the return value
+     * is the row number of the new state to transition to.  (0 is the
+     * "error" state, and -1 is the "end of word" state in a dictionary)
+     * @param row The row number of the current state
+     * @param col The column number of the input character (0 means "not a
+     * dictionary character")
+     * @return The row number of the new state to transition to
+     */
+    public final short getNextState(int row, int col) {
+        if (cellIsPopulated(row, col)) {
+            // we map from logical to physical row number by looking up the
+            // mapping in rowIndex; we map from logical column number to
+            // physical column number by looking up a shift value for this
+            // logical row and offsetting the logical column number by
+            // the shift amount.  Then we can use internalAt() to actually
+            // get the value out of the table.
+            return internalAt(rowIndex[row], col + rowIndexShifts[row]);
+        }
+        else {
+            return 0;
+        }
+    }
+
+    /**
+     * Given (logical) row and column numbers, returns true if the
+     * cell in that position is populated
+     */
+    private boolean cellIsPopulated(int row, int col) {
+        // look up the entry in the bitmap index for the specified row.
+        // If it's a negative number, it's the column number of the only
+        // populated cell in the row
+        if (rowIndexFlagsIndex[row] < 0) {
+            return col == -rowIndexFlagsIndex[row];
+        }
+
+        // if it's a positive number, it's the offset of an entry in the bitmap
+        // list.  If the table is more than 32 columns wide, the bitmap is stored
+        // successive entries in the bitmap list, so we have to divide the column
+        // number by 32 and offset the number we got out of the index by the result.
+        // Once we have the appropriate piece of the bitmap, test the appropriate
+        // bit and return the result.
+        else {
+            int flags = rowIndexFlags[rowIndexFlagsIndex[row] + (col >> 5)];
+            return (flags & (1 << (col & 0x1f))) != 0;
+        }
+    }
+
+    /**
+     * Implementation of getNextState() when we know the specified cell is
+     * populated.
+     * @param row The PHYSICAL row number of the cell
+     * @param col The PHYSICAL column number of the cell
+     * @return The value stored in the cell
+     */
+    private short internalAt(int row, int col) {
+        // the table is a one-dimensional array, so this just does the math necessary
+        // to treat it as a two-dimensional array (we don't just use a two-dimensional
+        // array because two-dimensional arrays are inefficient in Java)
+        return table[row * numCols + col];
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/sun/text/DictionaryBasedBreakIterator.java	Thu Oct 27 09:42:08 2016 -0700
@@ -0,0 +1,526 @@
+/*
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ *
+ * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1996 - 2002 - All Rights Reserved
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ */
+
+package sun.text;
+
+import java.text.CharacterIterator;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+/**
+ * A subclass of RuleBasedBreakIterator that adds the ability to use a dictionary
+ * to further subdivide ranges of text beyond what is possible using just the
+ * state-table-based algorithm.  This is necessary, for example, to handle
+ * word and line breaking in Thai, which doesn't use spaces between words.  The
+ * state-table-based algorithm used by RuleBasedBreakIterator is used to divide
+ * up text as far as possible, and then contiguous ranges of letters are
+ * repeatedly compared against a list of known words (i.e., the dictionary)
+ * to divide them up into words.
+ *
+ * DictionaryBasedBreakIterator uses the same rule language as RuleBasedBreakIterator,
+ * but adds one more special substitution name: &lt;dictionary&gt;.  This substitution
+ * name is used to identify characters in words in the dictionary.  The idea is that
+ * if the iterator passes over a chunk of text that includes two or more characters
+ * in a row that are included in &lt;dictionary&gt;, it goes back through that range and
+ * derives additional break positions (if possible) using the dictionary.
+ *
+ * DictionaryBasedBreakIterator is also constructed with the filename of a dictionary
+ * file.  It follows a prescribed search path to locate the dictionary (right now,
+ * it looks for it in /com/ibm/text/resources in each directory in the classpath,
+ * and won't find it in JAR files, but this location is likely to change).  The
+ * dictionary file is in a serialized binary format.  We have a very primitive (and
+ * slow) BuildDictionaryFile utility for creating dictionary files, but aren't
+ * currently making it public.  Contact us for help.
+ */
+public class DictionaryBasedBreakIterator extends RuleBasedBreakIterator {
+
+    /**
+     * a list of known words that is used to divide up contiguous ranges of letters,
+     * stored in a compressed, indexed, format that offers fast access
+     */
+    private BreakDictionary dictionary;
+
+    /**
+     * a list of flags indicating which character categories are contained in
+     * the dictionary file (this is used to determine which ranges of characters
+     * to apply the dictionary to)
+     */
+    private boolean[] categoryFlags;
+
+    /**
+     * a temporary hiding place for the number of dictionary characters in the
+     * last range passed over by next()
+     */
+    private int dictionaryCharCount;
+
+    /**
+     * when a range of characters is divided up using the dictionary, the break
+     * positions that are discovered are stored here, preventing us from having
+     * to use either the dictionary or the state table again until the iterator
+     * leaves this range of text
+     */
+    private int[] cachedBreakPositions;
+
+    /**
+     * if cachedBreakPositions is not null, this indicates which item in the
+     * cache the current iteration position refers to
+     */
+    private int positionInCache;
+
+    /**
+     * Constructs a DictionaryBasedBreakIterator.
+     *
+     * @param ruleFile       the name of the rule data file
+     * @param ruleData       the rule data loaded from the rule data file
+     * @param dictionaryFile the name of the dictionary file
+     * @param dictionartData the dictionary data loaded from the dictionary file
+     * @throws MissingResourceException if rule data or dictionary initialization failed
+     */
+    public DictionaryBasedBreakIterator(String ruleFile, byte[] ruleData,
+                                        String dictionaryFile, byte[] dictionaryData) {
+        super(ruleFile, ruleData);
+        byte[] tmp = super.getAdditionalData();
+        if (tmp != null) {
+            prepareCategoryFlags(tmp);
+            super.setAdditionalData(null);
+        }
+        dictionary = new BreakDictionary(dictionaryFile, dictionaryData);
+    }
+
+    private void prepareCategoryFlags(byte[] data) {
+        categoryFlags = new boolean[data.length];
+        for (int i = 0; i < data.length; i++) {
+            categoryFlags[i] = (data[i] == (byte)1) ? true : false;
+        }
+    }
+
+    @Override
+    public void setText(CharacterIterator newText) {
+        super.setText(newText);
+        cachedBreakPositions = null;
+        dictionaryCharCount = 0;
+        positionInCache = 0;
+    }
+
+    /**
+     * Sets the current iteration position to the beginning of the text.
+     * (i.e., the CharacterIterator's starting offset).
+     * @return The offset of the beginning of the text.
+     */
+    @Override
+    public int first() {
+        cachedBreakPositions = null;
+        dictionaryCharCount = 0;
+        positionInCache = 0;
+        return super.first();
+    }
+
+    /**
+     * Sets the current iteration position to the end of the text.
+     * (i.e., the CharacterIterator's ending offset).
+     * @return The text's past-the-end offset.
+     */
+    @Override
+    public int last() {
+        cachedBreakPositions = null;
+        dictionaryCharCount = 0;
+        positionInCache = 0;
+        return super.last();
+    }
+
+    /**
+     * Advances the iterator one step backwards.
+     * @return The position of the last boundary position before the
+     * current iteration position
+     */
+    @Override
+    public int previous() {
+        CharacterIterator text = getText();
+
+        // if we have cached break positions and we're still in the range
+        // covered by them, just move one step backward in the cache
+        if (cachedBreakPositions != null && positionInCache > 0) {
+            --positionInCache;
+            text.setIndex(cachedBreakPositions[positionInCache]);
+            return cachedBreakPositions[positionInCache];
+        }
+
+        // otherwise, dump the cache and use the inherited previous() method to move
+        // backward.  This may fill up the cache with new break positions, in which
+        // case we have to mark our position in the cache
+        else {
+            cachedBreakPositions = null;
+            int result = super.previous();
+            if (cachedBreakPositions != null) {
+                positionInCache = cachedBreakPositions.length - 2;
+            }
+            return result;
+        }
+    }
+
+    /**
+     * Sets the current iteration position to the last boundary position
+     * before the specified position.
+     * @param offset The position to begin searching from
+     * @return The position of the last boundary before "offset"
+     */
+    @Override
+    public int preceding(int offset) {
+        CharacterIterator text = getText();
+        checkOffset(offset, text);
+
+        // if we have no cached break positions, or "offset" is outside the
+        // range covered by the cache, we can just call the inherited routine
+        // (which will eventually call other routines in this class that may
+        // refresh the cache)
+        if (cachedBreakPositions == null || offset <= cachedBreakPositions[0] ||
+                offset > cachedBreakPositions[cachedBreakPositions.length - 1]) {
+            cachedBreakPositions = null;
+            return super.preceding(offset);
+        }
+
+        // on the other hand, if "offset" is within the range covered by the cache,
+        // then all we have to do is search the cache for the last break position
+        // before "offset"
+        else {
+            positionInCache = 0;
+            while (positionInCache < cachedBreakPositions.length
+                   && offset > cachedBreakPositions[positionInCache]) {
+                ++positionInCache;
+            }
+            --positionInCache;
+            text.setIndex(cachedBreakPositions[positionInCache]);
+            return text.getIndex();
+        }
+    }
+
+    /**
+     * Sets the current iteration position to the first boundary position after
+     * the specified position.
+     * @param offset The position to begin searching forward from
+     * @return The position of the first boundary after "offset"
+     */
+    @Override
+    public int following(int offset) {
+        CharacterIterator text = getText();
+        checkOffset(offset, text);
+
+        // if we have no cached break positions, or if "offset" is outside the
+        // range covered by the cache, then dump the cache and call our
+        // inherited following() method.  This will call other methods in this
+        // class that may refresh the cache.
+        if (cachedBreakPositions == null || offset < cachedBreakPositions[0] ||
+                offset >= cachedBreakPositions[cachedBreakPositions.length - 1]) {
+            cachedBreakPositions = null;
+            return super.following(offset);
+        }
+
+        // on the other hand, if "offset" is within the range covered by the
+        // cache, then just search the cache for the first break position
+        // after "offset"
+        else {
+            positionInCache = 0;
+            while (positionInCache < cachedBreakPositions.length
+                   && offset >= cachedBreakPositions[positionInCache]) {
+                ++positionInCache;
+            }
+            text.setIndex(cachedBreakPositions[positionInCache]);
+            return text.getIndex();
+        }
+    }
+
+    /**
+     * This is the implementation function for next().
+     */
+    @Override
+    protected int handleNext() {
+        CharacterIterator text = getText();
+
+        // if there are no cached break positions, or if we've just moved
+        // off the end of the range covered by the cache, we have to dump
+        // and possibly regenerate the cache
+        if (cachedBreakPositions == null ||
+            positionInCache == cachedBreakPositions.length - 1) {
+
+            // start by using the inherited handleNext() to find a tentative return
+            // value.   dictionaryCharCount tells us how many dictionary characters
+            // we passed over on our way to the tentative return value
+            int startPos = text.getIndex();
+            dictionaryCharCount = 0;
+            int result = super.handleNext();
+
+            // if we passed over more than one dictionary character, then we use
+            // divideUpDictionaryRange() to regenerate the cached break positions
+            // for the new range
+            if (dictionaryCharCount > 1 && result - startPos > 1) {
+                divideUpDictionaryRange(startPos, result);
+            }
+
+            // otherwise, the value we got back from the inherited fuction
+            // is our return value, and we can dump the cache
+            else {
+                cachedBreakPositions = null;
+                return result;
+            }
+        }
+
+        // if the cache of break positions has been regenerated (or existed all
+        // along), then just advance to the next break position in the cache
+        // and return it
+        if (cachedBreakPositions != null) {
+            ++positionInCache;
+            text.setIndex(cachedBreakPositions[positionInCache]);
+            return cachedBreakPositions[positionInCache];
+        }
+        return -9999;   // SHOULD NEVER GET HERE!
+    }
+
+    /**
+     * Looks up a character category for a character.
+     */
+    @Override
+    protected int lookupCategory(int c) {
+        // this override of lookupCategory() exists only to keep track of whether we've
+        // passed over any dictionary characters.  It calls the inherited lookupCategory()
+        // to do the real work, and then checks whether its return value is one of the
+        // categories represented in the dictionary.  If it is, bump the dictionary-
+        // character count.
+        int result = super.lookupCategory(c);
+        if (result != RuleBasedBreakIterator.IGNORE && categoryFlags[result]) {
+            ++dictionaryCharCount;
+        }
+        return result;
+    }
+
+    /**
+     * This is the function that actually implements the dictionary-based
+     * algorithm.  Given the endpoints of a range of text, it uses the
+     * dictionary to determine the positions of any boundaries in this
+     * range.  It stores all the boundary positions it discovers in
+     * cachedBreakPositions so that we only have to do this work once
+     * for each time we enter the range.
+     */
+    @SuppressWarnings("unchecked")
+    private void divideUpDictionaryRange(int startPos, int endPos) {
+        CharacterIterator text = getText();
+
+        // the range we're dividing may begin or end with non-dictionary characters
+        // (i.e., for line breaking, we may have leading or trailing punctuation
+        // that needs to be kept with the word).  Seek from the beginning of the
+        // range to the first dictionary character
+        text.setIndex(startPos);
+        int c = getCurrent();
+        int category = lookupCategory(c);
+        while (category == IGNORE || !categoryFlags[category]) {
+            c = getNext();
+            category = lookupCategory(c);
+        }
+
+        // initialize.  We maintain two stacks: currentBreakPositions contains
+        // the list of break positions that will be returned if we successfully
+        // finish traversing the whole range now.  possibleBreakPositions lists
+        // all other possible word ends we've passed along the way.  (Whenever
+        // we reach an error [a sequence of characters that can't begin any word
+        // in the dictionary], we back up, possibly delete some breaks from
+        // currentBreakPositions, move a break from possibleBreakPositions
+        // to currentBreakPositions, and start over from there.  This process
+        // continues in this way until we either successfully make it all the way
+        // across the range, or exhaust all of our combinations of break
+        // positions.)
+        Stack<Integer> currentBreakPositions = new Stack<>();
+        Stack<Integer> possibleBreakPositions = new Stack<>();
+        List<Integer> wrongBreakPositions = new ArrayList<>();
+
+        // the dictionary is implemented as a trie, which is treated as a state
+        // machine.  -1 represents the end of a legal word.  Every word in the
+        // dictionary is represented by a path from the root node to -1.  A path
+        // that ends in state 0 is an illegal combination of characters.
+        int state = 0;
+
+        // these two variables are used for error handling.  We keep track of the
+        // farthest we've gotten through the range being divided, and the combination
+        // of breaks that got us that far.  If we use up all possible break
+        // combinations, the text contains an error or a word that's not in the
+        // dictionary.  In this case, we "bless" the break positions that got us the
+        // farthest as real break positions, and then start over from scratch with
+        // the character where the error occurred.
+        int farthestEndPoint = text.getIndex();
+        Stack<Integer> bestBreakPositions = null;
+
+        // initialize (we always exit the loop with a break statement)
+        c = getCurrent();
+        while (true) {
+
+            // if we can transition to state "-1" from our current state, we're
+            // on the last character of a legal word.  Push that position onto
+            // the possible-break-positions stack
+            if (dictionary.getNextState(state, 0) == -1) {
+                possibleBreakPositions.push(text.getIndex());
+            }
+
+            // look up the new state to transition to in the dictionary
+            state = dictionary.getNextStateFromCharacter(state, c);
+
+            // if the character we're sitting on causes us to transition to
+            // the "end of word" state, then it was a non-dictionary character
+            // and we've successfully traversed the whole range.  Drop out
+            // of the loop.
+            if (state == -1) {
+                currentBreakPositions.push(text.getIndex());
+                break;
+            }
+
+            // if the character we're sitting on causes us to transition to
+            // the error state, or if we've gone off the end of the range
+            // without transitioning to the "end of word" state, we've hit
+            // an error...
+            else if (state == 0 || text.getIndex() >= endPos) {
+
+                // if this is the farthest we've gotten, take note of it in
+                // case there's an error in the text
+                if (text.getIndex() > farthestEndPoint) {
+                    farthestEndPoint = text.getIndex();
+
+                    @SuppressWarnings("unchecked")
+                    Stack<Integer> currentBreakPositionsCopy = (Stack<Integer>) currentBreakPositions.clone();
+
+                    bestBreakPositions = currentBreakPositionsCopy;
+                }
+
+                // wrongBreakPositions is a list of all break positions
+                // we've tried starting that didn't allow us to traverse
+                // all the way through the text.  Every time we pop a
+                // break position off of currentBreakPositions, we put it
+                // into wrongBreakPositions to avoid trying it again later.
+                // If we make it to this spot, we're either going to back
+                // up to a break in possibleBreakPositions and try starting
+                // over from there, or we've exhausted all possible break
+                // positions and are going to do the fallback procedure.
+                // This loop prevents us from messing with anything in
+                // possibleBreakPositions that didn't work as a starting
+                // point the last time we tried it (this is to prevent a bunch of
+                // repetitive checks from slowing down some extreme cases)
+                while (!possibleBreakPositions.isEmpty()
+                        && wrongBreakPositions.contains(possibleBreakPositions.peek())) {
+                    possibleBreakPositions.pop();
+                }
+
+                // if we've used up all possible break-position combinations, there's
+                // an error or an unknown word in the text.  In this case, we start
+                // over, treating the farthest character we've reached as the beginning
+                // of the range, and "blessing" the break positions that got us that
+                // far as real break positions
+                if (possibleBreakPositions.isEmpty()) {
+                    if (bestBreakPositions != null) {
+                        currentBreakPositions = bestBreakPositions;
+                        if (farthestEndPoint < endPos) {
+                            text.setIndex(farthestEndPoint + 1);
+                        }
+                        else {
+                            break;
+                        }
+                    }
+                    else {
+                        if ((currentBreakPositions.size() == 0 ||
+                             currentBreakPositions.peek().intValue() != text.getIndex())
+                            && text.getIndex() != startPos) {
+                            currentBreakPositions.push(text.getIndex());
+                        }
+                        getNext();
+                        currentBreakPositions.push(text.getIndex());
+                    }
+                }
+
+                // if we still have more break positions we can try, then promote the
+                // last break in possibleBreakPositions into currentBreakPositions,
+                // and get rid of all entries in currentBreakPositions that come after
+                // it.  Then back up to that position and start over from there (i.e.,
+                // treat that position as the beginning of a new word)
+                else {
+                    Integer temp = possibleBreakPositions.pop();
+                    Integer temp2 = null;
+                    while (!currentBreakPositions.isEmpty() && temp.intValue() <
+                           currentBreakPositions.peek().intValue()) {
+                        temp2 = currentBreakPositions.pop();
+                        wrongBreakPositions.add(temp2);
+                    }
+                    currentBreakPositions.push(temp);
+                    text.setIndex(currentBreakPositions.peek().intValue());
+                }
+
+                // re-sync "c" for the next go-round, and drop out of the loop if
+                // we've made it off the end of the range
+                c = getCurrent();
+                if (text.getIndex() >= endPos) {
+                    break;
+                }
+            }
+
+            // if we didn't hit any exceptional conditions on this last iteration,
+            // just advance to the next character and loop
+            else {
+                c = getNext();
+            }
+        }
+
+        // dump the last break position in the list, and replace it with the actual
+        // end of the range (which may be the same character, or may be further on
+        // because the range actually ended with non-dictionary characters we want to
+        // keep with the word)
+        if (!currentBreakPositions.isEmpty()) {
+            currentBreakPositions.pop();
+        }
+        currentBreakPositions.push(endPos);
+
+        // create a regular array to hold the break positions and copy
+        // the break positions from the stack to the array (in addition,
+        // our starting position goes into this array as a break position).
+        // This array becomes the cache of break positions used by next()
+        // and previous(), so this is where we actually refresh the cache.
+        cachedBreakPositions = new int[currentBreakPositions.size() + 1];
+        cachedBreakPositions[0] = startPos;
+
+        for (int i = 0; i < currentBreakPositions.size(); i++) {
+            cachedBreakPositions[i + 1] = currentBreakPositions.elementAt(i).intValue();
+        }
+        positionInCache = 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/sun/text/RuleBasedBreakIterator.java	Thu Oct 27 09:42:08 2016 -0700
@@ -0,0 +1,1144 @@
+/*
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ *
+ * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1996 - 2002 - All Rights Reserved
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ */
+
+package sun.text;
+
+import java.nio.BufferUnderflowException;
+import java.nio.ByteBuffer;
+import java.text.BreakIterator;
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+import java.util.MissingResourceException;
+import sun.text.CompactByteArray;
+import sun.text.SupplementaryCharacterData;
+
+/**
+ * <p>A subclass of BreakIterator whose behavior is specified using a list of rules.</p>
+ *
+ * <p>There are two kinds of rules, which are separated by semicolons: <i>substitutions</i>
+ * and <i>regular expressions.</i></p>
+ *
+ * <p>A substitution rule defines a name that can be used in place of an expression. It
+ * consists of a name, which is a string of characters contained in angle brackets, an equals
+ * sign, and an expression. (There can be no whitespace on either side of the equals sign.)
+ * To keep its syntactic meaning intact, the expression must be enclosed in parentheses or
+ * square brackets. A substitution is visible after its definition, and is filled in using
+ * simple textual substitution. Substitution definitions can contain other substitutions, as
+ * long as those substitutions have been defined first. Substitutions are generally used to
+ * make the regular expressions (which can get quite complex) shorted and easier to read.
+ * They typically define either character categories or commonly-used subexpressions.</p>
+ *
+ * <p>There is one special substitution.&nbsp; If the description defines a substitution
+ * called &quot;&lt;ignore&gt;&quot;, the expression must be a [] expression, and the
+ * expression defines a set of characters (the &quot;<em>ignore characters</em>&quot;) that
+ * will be transparent to the BreakIterator.&nbsp; A sequence of characters will break the
+ * same way it would if any ignore characters it contains are taken out.&nbsp; Break
+ * positions never occur befoer ignore characters.</p>
+ *
+ * <p>A regular expression uses a subset of the normal Unix regular-expression syntax, and
+ * defines a sequence of characters to be kept together. With one significant exception, the
+ * iterator uses a longest-possible-match algorithm when matching text to regular
+ * expressions. The iterator also treats descriptions containing multiple regular expressions
+ * as if they were ORed together (i.e., as if they were separated by |).</p>
+ *
+ * <p>The special characters recognized by the regular-expression parser are as follows:</p>
+ *
+ * <blockquote>
+ *   <table border="1" width="100%">
+ *     <tr>
+ *       <td width="6%">*</td>
+ *       <td width="94%">Specifies that the expression preceding the asterisk may occur any number
+ *       of times (including not at all).</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%">{}</td>
+ *       <td width="94%">Encloses a sequence of characters that is optional.</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%">()</td>
+ *       <td width="94%">Encloses a sequence of characters.&nbsp; If followed by *, the sequence
+ *       repeats.&nbsp; Otherwise, the parentheses are just a grouping device and a way to delimit
+ *       the ends of expressions containing |.</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%">|</td>
+ *       <td width="94%">Separates two alternative sequences of characters.&nbsp; Either one
+ *       sequence or the other, but not both, matches this expression.&nbsp; The | character can
+ *       only occur inside ().</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%">.</td>
+ *       <td width="94%">Matches any character.</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%">*?</td>
+ *       <td width="94%">Specifies a non-greedy asterisk.&nbsp; *? works the same way as *, except
+ *       when there is overlap between the last group of characters in the expression preceding the
+ *       * and the first group of characters following the *.&nbsp; When there is this kind of
+ *       overlap, * will match the longest sequence of characters that match the expression before
+ *       the *, and *? will match the shortest sequence of characters matching the expression
+ *       before the *?.&nbsp; For example, if you have &quot;xxyxyyyxyxyxxyxyxyy&quot; in the text,
+ *       &quot;x[xy]*x&quot; will match through to the last x (i.e., &quot;<strong>xxyxyyyxyxyxxyxyx</strong>yy&quot;,
+ *       but &quot;x[xy]*?x&quot; will only match the first two xes (&quot;<strong>xx</strong>yxyyyxyxyxxyxyxyy&quot;).</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%">[]</td>
+ *       <td width="94%">Specifies a group of alternative characters.&nbsp; A [] expression will
+ *       match any single character that is specified in the [] expression.&nbsp; For more on the
+ *       syntax of [] expressions, see below.</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%">/</td>
+ *       <td width="94%">Specifies where the break position should go if text matches this
+ *       expression.&nbsp; (e.g., &quot;[a-z]&#42;/[:Zs:]*[1-0]&quot; will match if the iterator sees a run
+ *       of letters, followed by a run of whitespace, followed by a digit, but the break position
+ *       will actually go before the whitespace).&nbsp; Expressions that don't contain / put the
+ *       break position at the end of the matching text.</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%">\</td>
+ *       <td width="94%">Escape character.&nbsp; The \ itself is ignored, but causes the next
+ *       character to be treated as literal character.&nbsp; This has no effect for many
+ *       characters, but for the characters listed above, this deprives them of their special
+ *       meaning.&nbsp; (There are no special escape sequences for Unicode characters, or tabs and
+ *       newlines; these are all handled by a higher-level protocol.&nbsp; In a Java string,
+ *       &quot;\n&quot; will be converted to a literal newline character by the time the
+ *       regular-expression parser sees it.&nbsp; Of course, this means that \ sequences that are
+ *       visible to the regexp parser must be written as \\ when inside a Java string.)&nbsp; All
+ *       characters in the ASCII range except for letters, digits, and control characters are
+ *       reserved characters to the parser and must be preceded by \ even if they currently don't
+ *       mean anything.</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%">!</td>
+ *       <td width="94%">If ! appears at the beginning of a regular expression, it tells the regexp
+ *       parser that this expression specifies the backwards-iteration behavior of the iterator,
+ *       and not its normal iteration behavior.&nbsp; This is generally only used in situations
+ *       where the automatically-generated backwards-iteration brhavior doesn't produce
+ *       satisfactory results and must be supplemented with extra client-specified rules.</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%"><em>(all others)</em></td>
+ *       <td width="94%">All other characters are treated as literal characters, which must match
+ *       the corresponding character(s) in the text exactly.</td>
+ *     </tr>
+ *   </table>
+ * </blockquote>
+ *
+ * <p>Within a [] expression, a number of other special characters can be used to specify
+ * groups of characters:</p>
+ *
+ * <blockquote>
+ *   <table border="1" width="100%">
+ *     <tr>
+ *       <td width="6%">-</td>
+ *       <td width="94%">Specifies a range of matching characters.&nbsp; For example
+ *       &quot;[a-p]&quot; matches all lowercase Latin letters from a to p (inclusive).&nbsp; The -
+ *       sign specifies ranges of continuous Unicode numeric values, not ranges of characters in a
+ *       language's alphabetical order: &quot;[a-z]&quot; doesn't include capital letters, nor does
+ *       it include accented letters such as a-umlaut.</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%">::</td>
+ *       <td width="94%">A pair of colons containing a one- or two-letter code matches all
+ *       characters in the corresponding Unicode category.&nbsp; The two-letter codes are the same
+ *       as the two-letter codes in the Unicode database (for example, &quot;[:Sc::Sm:]&quot;
+ *       matches all currency symbols and all math symbols).&nbsp; Specifying a one-letter code is
+ *       the same as specifying all two-letter codes that begin with that letter (for example,
+ *       &quot;[:L:]&quot; matches all letters, and is equivalent to
+ *       &quot;[:Lu::Ll::Lo::Lm::Lt:]&quot;).&nbsp; Anything other than a valid two-letter Unicode
+ *       category code or a single letter that begins a Unicode category code is illegal within
+ *       colons.</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%">[]</td>
+ *       <td width="94%">[] expressions can nest.&nbsp; This has no effect, except when used in
+ *       conjunction with the ^ token.</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%">^</td>
+ *       <td width="94%">Excludes the character (or the characters in the [] expression) following
+ *       it from the group of characters.&nbsp; For example, &quot;[a-z^p]&quot; matches all Latin
+ *       lowercase letters except p.&nbsp; &quot;[:L:^[&#92;u4e00-&#92;u9fff]]&quot; matches all letters
+ *       except the Han ideographs.</td>
+ *     </tr>
+ *     <tr>
+ *       <td width="6%"><em>(all others)</em></td>
+ *       <td width="94%">All other characters are treated as literal characters.&nbsp; (For
+ *       example, &quot;[aeiou]&quot; specifies just the letters a, e, i, o, and u.)</td>
+ *     </tr>
+ *   </table>
+ * </blockquote>
+ *
+ * <p>For a more complete explanation, see <a
+ * href="http://www.ibm.com/java/education/boundaries/boundaries.html">http://www.ibm.com/java/education/boundaries/boundaries.html</a>.
+ * &nbsp; For examples, see the resource data (which is annotated).</p>
+ *
+ * @author Richard Gillam
+ */
+public class RuleBasedBreakIterator extends BreakIterator {
+
+    /**
+     * A token used as a character-category value to identify ignore characters
+     */
+    protected static final byte IGNORE = -1;
+
+    /**
+     * The state number of the starting state
+     */
+    private static final short START_STATE = 1;
+
+    /**
+     * The state-transition value indicating "stop"
+     */
+    private static final short STOP_STATE = 0;
+
+    /**
+     * Magic number for the BreakIterator data file format.
+     */
+    static final byte[] LABEL = {
+        (byte)'B', (byte)'I', (byte)'d', (byte)'a', (byte)'t', (byte)'a',
+        (byte)'\0'
+    };
+    static final int    LABEL_LENGTH = LABEL.length;
+
+    /**
+     * Version number of the dictionary that was read in.
+     */
+    static final byte supportedVersion = 1;
+
+    /**
+     * An array length of indices for BMP characters
+     */
+    private static final int BMP_INDICES_LENGTH = 512;
+
+    /**
+     * Tables that indexes from character values to character category numbers
+     */
+    private CompactByteArray charCategoryTable = null;
+    private SupplementaryCharacterData supplementaryCharCategoryTable = null;
+
+    /**
+     * The table of state transitions used for forward iteration
+     */
+    private short[] stateTable = null;
+
+    /**
+     * The table of state transitions used to sync up the iterator with the
+     * text in backwards and random-access iteration
+     */
+    private short[] backwardsStateTable = null;
+
+    /**
+     * A list of flags indicating which states in the state table are accepting
+     * ("end") states
+     */
+    private boolean[] endStates = null;
+
+    /**
+     * A list of flags indicating which states in the state table are
+     * lookahead states (states which turn lookahead on and off)
+     */
+    private boolean[] lookaheadStates = null;
+
+    /**
+     * A table for additional data. May be used by a subclass of
+     * RuleBasedBreakIterator.
+     */
+    private byte[] additionalData = null;
+
+    /**
+     * The number of character categories (and, thus, the number of columns in
+     * the state tables)
+     */
+    private int numCategories;
+
+    /**
+     * The character iterator through which this BreakIterator accesses the text
+     */
+    private CharacterIterator text = null;
+
+    /**
+     * A CRC32 value of all data in datafile
+     */
+    private long checksum;
+
+    //=======================================================================
+    // constructors
+    //=======================================================================
+
+    /**
+     * Constructs a RuleBasedBreakIterator using the given rule data.
+     *
+     * @throws MissingResourceException if the rule data is invalid or corrupted
+     */
+    public RuleBasedBreakIterator(String ruleFile, byte[] ruleData) {
+        ByteBuffer bb = ByteBuffer.wrap(ruleData);
+        try {
+            validateRuleData(ruleFile, bb);
+            setupTables(ruleFile, bb);
+        } catch (BufferUnderflowException bue) {
+            MissingResourceException e;
+            e = new MissingResourceException("Corrupted rule data file", ruleFile, "");
+            e.initCause(bue);
+            throw e;
+        }
+    }
+
+    /**
+     * Initializes the fields with the given rule data.
+     * The data format is as follows:
+     * <pre>
+     *   BreakIteratorData {
+     *       u1           magic[7];
+     *       u1           version;
+     *       u4           totalDataSize;
+     *       header_info  header;
+     *       body         value;
+     *   }
+     * </pre>
+     * <code>totalDataSize</code> is the summation of the size of
+     * <code>header_info</code> and <code>body</code> in byte count.
+     * <p>
+     * In <code>header</code>, each field except for checksum implies the
+     * length of each field. Since <code>BMPdataLength</code> is a fixed-length
+     *  data(512 entries), its length isn't included in <code>header</code>.
+     * <code>checksum</code> is a CRC32 value of all in <code>body</code>.
+     * <pre>
+     *   header_info {
+     *       u4           stateTableLength;
+     *       u4           backwardsStateTableLength;
+     *       u4           endStatesLength;
+     *       u4           lookaheadStatesLength;
+     *       u4           BMPdataLength;
+     *       u4           nonBMPdataLength;
+     *       u4           additionalDataLength;
+     *       u8           checksum;
+     *   }
+     * </pre>
+     * <p>
+     *
+     * Finally, <code>BMPindices</code> and <code>BMPdata</code> are set to
+     * <code>charCategoryTable</code>. <code>nonBMPdata</code> is set to
+     * <code>supplementaryCharCategoryTable</code>.
+     * <pre>
+     *   body {
+     *       u2           stateTable[stateTableLength];
+     *       u2           backwardsStateTable[backwardsStateTableLength];
+     *       u1           endStates[endStatesLength];
+     *       u1           lookaheadStates[lookaheadStatesLength];
+     *       u2           BMPindices[512];
+     *       u1           BMPdata[BMPdataLength];
+     *       u4           nonBMPdata[numNonBMPdataLength];
+     *       u1           additionalData[additionalDataLength];
+     *   }
+     * </pre>
+     *
+     * @throws BufferUnderflowException if the end-of-data is reached before
+     *                                  setting up all the tables
+     */
+    private void setupTables(String ruleFile, ByteBuffer bb) {
+        /* Read header_info. */
+        int stateTableLength = bb.getInt();
+        int backwardsStateTableLength = bb.getInt();
+        int endStatesLength = bb.getInt();
+        int lookaheadStatesLength = bb.getInt();
+        int BMPdataLength = bb.getInt();
+        int nonBMPdataLength = bb.getInt();
+        int additionalDataLength = bb.getInt();
+        checksum = bb.getLong();
+
+        /* Read stateTable[numCategories * numRows] */
+        stateTable = new short[stateTableLength];
+        for (int i = 0; i < stateTableLength; i++) {
+            stateTable[i] = bb.getShort();
+        }
+
+        /* Read backwardsStateTable[numCategories * numRows] */
+        backwardsStateTable = new short[backwardsStateTableLength];
+        for (int i = 0; i < backwardsStateTableLength; i++) {
+            backwardsStateTable[i] = bb.getShort();
+        }
+
+        /* Read endStates[numRows] */
+        endStates = new boolean[endStatesLength];
+        for (int i = 0; i < endStatesLength; i++) {
+            endStates[i] = bb.get() == 1;
+        }
+
+        /* Read lookaheadStates[numRows] */
+        lookaheadStates = new boolean[lookaheadStatesLength];
+        for (int i = 0; i < lookaheadStatesLength; i++) {
+            lookaheadStates[i] = bb.get() == 1;
+        }
+
+        /* Read a category table and indices for BMP characters. */
+        short[] temp1 = new short[BMP_INDICES_LENGTH];  // BMPindices
+        for (int i = 0; i < BMP_INDICES_LENGTH; i++) {
+            temp1[i] = bb.getShort();
+        }
+        byte[] temp2 = new byte[BMPdataLength];  // BMPdata
+        bb.get(temp2);
+        charCategoryTable = new CompactByteArray(temp1, temp2);
+
+        /* Read a category table for non-BMP characters. */
+        int[] temp3 = new int[nonBMPdataLength];
+        for (int i = 0; i < nonBMPdataLength; i++) {
+            temp3[i] = bb.getInt();
+        }
+        supplementaryCharCategoryTable = new SupplementaryCharacterData(temp3);
+
+        /* Read additional data */
+        if (additionalDataLength > 0) {
+            additionalData = new byte[additionalDataLength];
+            bb.get(additionalData);
+        }
+        assert bb.position() == bb.limit();
+
+        /* Set numCategories */
+        numCategories = stateTable.length / endStates.length;
+    }
+
+    /**
+     * Validates the magic number, version, and the length of the given data.
+     *
+     * @throws BufferUnderflowException if the end-of-data is reached while
+     *                                  validating data
+     * @throws MissingResourceException if valification failed
+     */
+    void validateRuleData(String ruleFile, ByteBuffer bb) {
+        /* Verify the magic number. */
+        for (int i = 0; i < LABEL_LENGTH; i++) {
+            if (bb.get() != LABEL[i]) {
+                throw new MissingResourceException("Wrong magic number",
+                                                   ruleFile, "");
+            }
+        }
+
+        /* Verify the version number. */
+        byte version = bb.get();
+        if (version != supportedVersion) {
+            throw new MissingResourceException("Unsupported version(" + version + ")",
+                                               ruleFile, "");
+        }
+
+        // Check the length of the rest of data
+        int len = bb.getInt();
+        if (bb.position() + len != bb.limit()) {
+            throw new MissingResourceException("Wrong data length",
+                                               ruleFile, "");
+        }
+    }
+
+    byte[] getAdditionalData() {
+        return additionalData;
+    }
+
+    void setAdditionalData(byte[] b) {
+        additionalData = b;
+    }
+
+    //=======================================================================
+    // boilerplate
+    //=======================================================================
+    /**
+     * Clones this iterator.
+     * @return A newly-constructed RuleBasedBreakIterator with the same
+     * behavior as this one.
+     */
+    @Override
+    public Object clone() {
+        RuleBasedBreakIterator result = (RuleBasedBreakIterator) super.clone();
+        if (text != null) {
+            result.text = (CharacterIterator) text.clone();
+        }
+        return result;
+    }
+
+    /**
+     * Returns true if both BreakIterators are of the same class, have the same
+     * rules, and iterate over the same text.
+     */
+    @Override
+    public boolean equals(Object that) {
+        try {
+            if (that == null) {
+                return false;
+            }
+
+            RuleBasedBreakIterator other = (RuleBasedBreakIterator) that;
+            if (checksum != other.checksum) {
+                return false;
+            }
+            if (text == null) {
+                return other.text == null;
+            } else {
+                return text.equals(other.text);
+            }
+        }
+        catch(ClassCastException e) {
+            return false;
+        }
+    }
+
+    /**
+     * Returns text
+     */
+    @Override
+    public String toString() {
+        return "[checksum=0x" + Long.toHexString(checksum) + ']';
+    }
+
+    /**
+     * Compute a hashcode for this BreakIterator
+     * @return A hash code
+     */
+    @Override
+    public int hashCode() {
+        return (int)checksum;
+    }
+
+    //=======================================================================
+    // BreakIterator overrides
+    //=======================================================================
+
+    /**
+     * Sets the current iteration position to the beginning of the text.
+     * (i.e., the CharacterIterator's starting offset).
+     * @return The offset of the beginning of the text.
+     */
+    @Override
+    public int first() {
+        CharacterIterator t = getText();
+
+        t.first();
+        return t.getIndex();
+    }
+
+    /**
+     * Sets the current iteration position to the end of the text.
+     * (i.e., the CharacterIterator's ending offset).
+     * @return The text's past-the-end offset.
+     */
+    @Override
+    public int last() {
+        CharacterIterator t = getText();
+
+        // I'm not sure why, but t.last() returns the offset of the last character,
+        // rather than the past-the-end offset
+        t.setIndex(t.getEndIndex());
+        return t.getIndex();
+    }
+
+    /**
+     * Advances the iterator either forward or backward the specified number of steps.
+     * Negative values move backward, and positive values move forward.  This is
+     * equivalent to repeatedly calling next() or previous().
+     * @param n The number of steps to move.  The sign indicates the direction
+     * (negative is backwards, and positive is forwards).
+     * @return The character offset of the boundary position n boundaries away from
+     * the current one.
+     */
+    @Override
+    public int next(int n) {
+        int result = current();
+        while (n > 0) {
+            result = handleNext();
+            --n;
+        }
+        while (n < 0) {
+            result = previous();
+            ++n;
+        }
+        return result;
+    }
+
+    /**
+     * Advances the iterator to the next boundary position.
+     * @return The position of the first boundary after this one.
+     */
+    @Override
+    public int next() {
+        return handleNext();
+    }
+
+    private int cachedLastKnownBreak = BreakIterator.DONE;
+
+    /**
+     * Advances the iterator backwards, to the last boundary preceding this one.
+     * @return The position of the last boundary position preceding this one.
+     */
+    @Override
+    public int previous() {
+        // if we're already sitting at the beginning of the text, return DONE
+        CharacterIterator text = getText();
+        if (current() == text.getBeginIndex()) {
+            return BreakIterator.DONE;
+        }
+
+        // set things up.  handlePrevious() will back us up to some valid
+        // break position before the current position (we back our internal
+        // iterator up one step to prevent handlePrevious() from returning
+        // the current position), but not necessarily the last one before
+        // where we started
+        int start = current();
+        int lastResult = cachedLastKnownBreak;
+        if (lastResult >= start || lastResult <= BreakIterator.DONE) {
+            getPrevious();
+            lastResult = handlePrevious();
+        } else {
+            //it might be better to check if handlePrevious() give us closer
+            //safe value but handlePrevious() is slow too
+            //So, this has to be done carefully
+            text.setIndex(lastResult);
+        }
+        int result = lastResult;
+
+        // iterate forward from the known break position until we pass our
+        // starting point.  The last break position before the starting
+        // point is our return value
+        while (result != BreakIterator.DONE && result < start) {
+            lastResult = result;
+            result = handleNext();
+        }
+
+        // set the current iteration position to be the last break position
+        // before where we started, and then return that value
+        text.setIndex(lastResult);
+        cachedLastKnownBreak = lastResult;
+        return lastResult;
+    }
+
+    /**
+     * Returns previous character
+     */
+    private int getPrevious() {
+        char c2 = text.previous();
+        if (Character.isLowSurrogate(c2) &&
+            text.getIndex() > text.getBeginIndex()) {
+            char c1 = text.previous();
+            if (Character.isHighSurrogate(c1)) {
+                return Character.toCodePoint(c1, c2);
+            } else {
+                text.next();
+            }
+        }
+        return (int)c2;
+    }
+
+    /**
+     * Returns current character
+     */
+    int getCurrent() {
+        char c1 = text.current();
+        if (Character.isHighSurrogate(c1) &&
+            text.getIndex() < text.getEndIndex()) {
+            char c2 = text.next();
+            text.previous();
+            if (Character.isLowSurrogate(c2)) {
+                return Character.toCodePoint(c1, c2);
+            }
+        }
+        return (int)c1;
+    }
+
+    /**
+     * Returns the count of next character.
+     */
+    private int getCurrentCodePointCount() {
+        char c1 = text.current();
+        if (Character.isHighSurrogate(c1) &&
+            text.getIndex() < text.getEndIndex()) {
+            char c2 = text.next();
+            text.previous();
+            if (Character.isLowSurrogate(c2)) {
+                return 2;
+            }
+        }
+        return 1;
+    }
+
+    /**
+     * Returns next character
+     */
+    int getNext() {
+        int index = text.getIndex();
+        int endIndex = text.getEndIndex();
+        if (index == endIndex ||
+            (index += getCurrentCodePointCount()) >= endIndex) {
+            return CharacterIterator.DONE;
+        }
+        text.setIndex(index);
+        return getCurrent();
+    }
+
+    /**
+     * Returns the position of next character.
+     */
+    private int getNextIndex() {
+        int index = text.getIndex() + getCurrentCodePointCount();
+        int endIndex = text.getEndIndex();
+        if (index > endIndex) {
+            return endIndex;
+        } else {
+            return index;
+        }
+    }
+
+    /**
+     * Throw IllegalArgumentException unless begin <= offset < end.
+     */
+    protected static final void checkOffset(int offset, CharacterIterator text) {
+        if (offset < text.getBeginIndex() || offset > text.getEndIndex()) {
+            throw new IllegalArgumentException("offset out of bounds");
+        }
+    }
+
+    /**
+     * Sets the iterator to refer to the first boundary position following
+     * the specified position.
+     * @offset The position from which to begin searching for a break position.
+     * @return The position of the first break after the current position.
+     */
+    @Override
+    public int following(int offset) {
+
+        CharacterIterator text = getText();
+        checkOffset(offset, text);
+
+        // Set our internal iteration position (temporarily)
+        // to the position passed in.  If this is the _beginning_ position,
+        // then we can just use next() to get our return value
+        text.setIndex(offset);
+        if (offset == text.getBeginIndex()) {
+            cachedLastKnownBreak = handleNext();
+            return cachedLastKnownBreak;
+        }
+
+        // otherwise, we have to sync up first.  Use handlePrevious() to back
+        // us up to a known break position before the specified position (if
+        // we can determine that the specified position is a break position,
+        // we don't back up at all).  This may or may not be the last break
+        // position at or before our starting position.  Advance forward
+        // from here until we've passed the starting position.  The position
+        // we stop on will be the first break position after the specified one.
+        int result = cachedLastKnownBreak;
+        if (result >= offset || result <= BreakIterator.DONE) {
+            result = handlePrevious();
+        } else {
+            //it might be better to check if handlePrevious() give us closer
+            //safe value but handlePrevious() is slow too
+            //So, this has to be done carefully
+            text.setIndex(result);
+        }
+        while (result != BreakIterator.DONE && result <= offset) {
+            result = handleNext();
+        }
+        cachedLastKnownBreak = result;
+        return result;
+    }
+
+    /**
+     * Sets the iterator to refer to the last boundary position before the
+     * specified position.
+     * @offset The position to begin searching for a break from.
+     * @return The position of the last boundary before the starting position.
+     */
+    @Override
+    public int preceding(int offset) {
+        // if we start by updating the current iteration position to the
+        // position specified by the caller, we can just use previous()
+        // to carry out this operation
+        CharacterIterator text = getText();
+        checkOffset(offset, text);
+        text.setIndex(offset);
+        return previous();
+    }
+
+    /**
+     * Returns true if the specified position is a boundary position.  As a side
+     * effect, leaves the iterator pointing to the first boundary position at
+     * or after "offset".
+     * @param offset the offset to check.
+     * @return True if "offset" is a boundary position.
+     */
+    @Override
+    public boolean isBoundary(int offset) {
+        CharacterIterator text = getText();
+        checkOffset(offset, text);
+        if (offset == text.getBeginIndex()) {
+            return true;
+        }
+
+        // to check whether this is a boundary, we can use following() on the
+        // position before the specified one and return true if the position we
+        // get back is the one the user specified
+        else {
+            return following(offset - 1) == offset;
+        }
+    }
+
+    /**
+     * Returns the current iteration position.
+     * @return The current iteration position.
+     */
+    @Override
+    public int current() {
+        return getText().getIndex();
+    }
+
+    /**
+     * Return a CharacterIterator over the text being analyzed.  This version
+     * of this method returns the actual CharacterIterator we're using internally.
+     * Changing the state of this iterator can have undefined consequences.  If
+     * you need to change it, clone it first.
+     * @return An iterator over the text being analyzed.
+     */
+    @Override
+    public CharacterIterator getText() {
+        // The iterator is initialized pointing to no text at all, so if this
+        // function is called while we're in that state, we have to fudge an
+        // iterator to return.
+        if (text == null) {
+            text = new StringCharacterIterator("");
+        }
+        return text;
+    }
+
+    /**
+     * Set the iterator to analyze a new piece of text.  This function resets
+     * the current iteration position to the beginning of the text.
+     * @param newText An iterator over the text to analyze.
+     */
+    @Override
+    public void setText(CharacterIterator newText) {
+        // Test iterator to see if we need to wrap it in a SafeCharIterator.
+        // The correct behavior for CharacterIterators is to allow the
+        // position to be set to the endpoint of the iterator.  Many
+        // CharacterIterators do not uphold this, so this is a workaround
+        // to permit them to use this class.
+        int end = newText.getEndIndex();
+        boolean goodIterator;
+        try {
+            newText.setIndex(end);  // some buggy iterators throw an exception here
+            goodIterator = newText.getIndex() == end;
+        }
+        catch(IllegalArgumentException e) {
+            goodIterator = false;
+        }
+
+        if (goodIterator) {
+            text = newText;
+        }
+        else {
+            text = new SafeCharIterator(newText);
+        }
+        text.first();
+
+        cachedLastKnownBreak = BreakIterator.DONE;
+    }
+
+
+    //=======================================================================
+    // implementation
+    //=======================================================================
+
+    /**
+     * This method is the actual implementation of the next() method.  All iteration
+     * vectors through here.  This method initializes the state machine to state 1
+     * and advances through the text character by character until we reach the end
+     * of the text or the state machine transitions to state 0.  We update our return
+     * value every time the state machine passes through a possible end state.
+     */
+    protected int handleNext() {
+        // if we're already at the end of the text, return DONE.
+        CharacterIterator text = getText();
+        if (text.getIndex() == text.getEndIndex()) {
+            return BreakIterator.DONE;
+        }
+
+        // no matter what, we always advance at least one character forward
+        int result = getNextIndex();
+        int lookaheadResult = 0;
+
+        // begin in state 1
+        int state = START_STATE;
+        int category;
+        int c = getCurrent();
+
+        // loop until we reach the end of the text or transition to state 0
+        while (c != CharacterIterator.DONE && state != STOP_STATE) {
+
+            // look up the current character's character category (which tells us
+            // which column in the state table to look at)
+            category = lookupCategory(c);
+
+            // if the character isn't an ignore character, look up a state
+            // transition in the state table
+            if (category != IGNORE) {
+                state = lookupState(state, category);
+            }
+
+            // if the state we've just transitioned to is a lookahead state,
+            // (but not also an end state), save its position.  If it's
+            // both a lookahead state and an end state, update the break position
+            // to the last saved lookup-state position
+            if (lookaheadStates[state]) {
+                if (endStates[state]) {
+                    result = lookaheadResult;
+                }
+                else {
+                    lookaheadResult = getNextIndex();
+                }
+            }
+
+            // otherwise, if the state we've just transitioned to is an accepting
+            // state, update the break position to be the current iteration position
+            else {
+                if (endStates[state]) {
+                    result = getNextIndex();
+                }
+            }
+
+            c = getNext();
+        }
+
+        // if we've run off the end of the text, and the very last character took us into
+        // a lookahead state, advance the break position to the lookahead position
+        // (the theory here is that if there are no characters at all after the lookahead
+        // position, that always matches the lookahead criteria)
+        if (c == CharacterIterator.DONE && lookaheadResult == text.getEndIndex()) {
+            result = lookaheadResult;
+        }
+
+        text.setIndex(result);
+        return result;
+    }
+
+    /**
+     * This method backs the iterator back up to a "safe position" in the text.
+     * This is a position that we know, without any context, must be a break position.
+     * The various calling methods then iterate forward from this safe position to
+     * the appropriate position to return.  (For more information, see the description
+     * of buildBackwardsStateTable() in RuleBasedBreakIterator.Builder.)
+     */
+    protected int handlePrevious() {
+        CharacterIterator text = getText();
+        int state = START_STATE;
+        int category = 0;
+        int lastCategory = 0;
+        int c = getCurrent();
+
+        // loop until we reach the beginning of the text or transition to state 0
+        while (c != CharacterIterator.DONE && state != STOP_STATE) {
+
+            // save the last character's category and look up the current
+            // character's category
+            lastCategory = category;
+            category = lookupCategory(c);
+
+            // if the current character isn't an ignore character, look up a
+            // state transition in the backwards state table
+            if (category != IGNORE) {
+                state = lookupBackwardState(state, category);
+            }
+
+            // then advance one character backwards
+            c = getPrevious();
+        }
+
+        // if we didn't march off the beginning of the text, we're either one or two
+        // positions away from the real break position.  (One because of the call to
+        // previous() at the end of the loop above, and another because the character
+        // that takes us into the stop state will always be the character BEFORE
+        // the break position.)
+        if (c != CharacterIterator.DONE) {
+            if (lastCategory != IGNORE) {
+                getNext();
+                getNext();
+            }
+            else {
+                getNext();
+            }
+        }
+        return text.getIndex();
+    }
+
+    /**
+     * Looks up a character's category (i.e., its category for breaking purposes,
+     * not its Unicode category)
+     */
+    protected int lookupCategory(int c) {
+        if (c < Character.MIN_SUPPLEMENTARY_CODE_POINT) {
+            return charCategoryTable.elementAt((char)c);
+        } else {
+            return supplementaryCharCategoryTable.getValue(c);
+        }
+    }
+
+    /**
+     * Given a current state and a character category, looks up the
+     * next state to transition to in the state table.
+     */
+    protected int lookupState(int state, int category) {
+        return stateTable[state * numCategories + category];
+    }
+
+    /**
+     * Given a current state and a character category, looks up the
+     * next state to transition to in the backwards state table.
+     */
+    protected int lookupBackwardState(int state, int category) {
+        return backwardsStateTable[state * numCategories + category];
+    }
+
+    /*
+     * This class exists to work around a bug in incorrect implementations
+     * of CharacterIterator, which incorrectly handle setIndex(endIndex).
+     * This iterator relies only on base.setIndex(n) where n is less than
+     * endIndex.
+     *
+     * One caveat:  if the base iterator's begin and end indices change
+     * the change will not be reflected by this wrapper.  Does that matter?
+     */
+    // TODO: Review this class to see if it's still required.
+    private static final class SafeCharIterator implements CharacterIterator,
+                                                           Cloneable {
+
+        private CharacterIterator base;
+        private int rangeStart;
+        private int rangeLimit;
+        private int currentIndex;
+
+        SafeCharIterator(CharacterIterator base) {
+            this.base = base;
+            this.rangeStart = base.getBeginIndex();
+            this.rangeLimit = base.getEndIndex();
+            this.currentIndex = base.getIndex();
+        }
+
+        @Override
+        public char first() {
+            return setIndex(rangeStart);
+        }
+
+        @Override
+        public char last() {
+            return setIndex(rangeLimit - 1);
+        }
+
+        @Override
+        public char current() {
+            if (currentIndex < rangeStart || currentIndex >= rangeLimit) {
+                return DONE;
+            }
+            else {
+                return base.setIndex(currentIndex);
+            }
+        }
+
+        @Override
+        public char next() {
+
+            currentIndex++;
+            if (currentIndex >= rangeLimit) {
+                currentIndex = rangeLimit;
+                return DONE;
+            }
+            else {
+                return base.setIndex(currentIndex);
+            }
+        }
+
+        @Override
+        public char previous() {
+
+            currentIndex--;
+            if (currentIndex < rangeStart) {
+                currentIndex = rangeStart;
+                return DONE;
+            }
+            else {
+                return base.setIndex(currentIndex);
+            }
+        }
+
+        @Override
+        public char setIndex(int i) {
+
+            if (i < rangeStart || i > rangeLimit) {
+                throw new IllegalArgumentException("Invalid position");
+            }
+            currentIndex = i;
+            return current();
+        }
+
+        @Override
+        public int getBeginIndex() {
+            return rangeStart;
+        }
+
+        @Override
+        public int getEndIndex() {
+            return rangeLimit;
+        }
+
+        @Override
+        public int getIndex() {
+            return currentIndex;
+        }
+
+        @Override
+        public Object clone() {
+
+            SafeCharIterator copy = null;
+            try {
+                copy = (SafeCharIterator) super.clone();
+            }
+            catch(CloneNotSupportedException e) {
+                throw new Error("Clone not supported: " + e);
+            }
+
+            CharacterIterator copyOfBase = (CharacterIterator) base.clone();
+            copy.base = copyOfBase;
+            return copy;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/sun/text/resources/BreakIteratorResources.java	Thu Oct 27 09:42:08 2016 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.text.resources;
+
+import java.util.ResourceBundle;
+import sun.util.resources.BreakIteratorResourceBundle;
+
+public class BreakIteratorResources extends BreakIteratorResourceBundle {
+    @Override
+    protected ResourceBundle getBreakIteratorInfo() {
+        return new BreakIteratorInfo();
+    }
+}
--- a/src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java	Thu Oct 27 09:38:46 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,352 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- */
-
-/*
- *
- * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
- * (C) Copyright IBM Corp. 1996 - 2002 - All Rights Reserved
- *
- * The original version of this source code and documentation
- * is copyrighted and owned by Taligent, Inc., a wholly-owned
- * subsidiary of IBM. These materials are provided under terms
- * of a License Agreement between Taligent and Sun. This technology
- * is protected by multiple US and International patents.
- *
- * This notice and attribution to Taligent may not be removed.
- * Taligent is a registered trademark of Taligent, Inc.
- */
-package sun.util.locale.provider;
-
-import java.io.BufferedInputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.lang.reflect.Module;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.MissingResourceException;
-import sun.text.CompactByteArray;
-import sun.text.SupplementaryCharacterData;
-
-/**
- * This is the class that represents the list of known words used by
- * DictionaryBasedBreakIterator.  The conceptual data structure used
- * here is a trie: there is a node hanging off the root node for every
- * letter that can start a word.  Each of these nodes has a node hanging
- * off of it for every letter that can be the second letter of a word
- * if this node is the first letter, and so on.  The trie is represented
- * as a two-dimensional array that can be treated as a table of state
- * transitions.  Indexes are used to compress this array, taking
- * advantage of the fact that this array will always be very sparse.
- */
-class BreakDictionary {
-
-    //=========================================================================
-    // data members
-    //=========================================================================
-
-    /**
-      * The version of the dictionary that was read in.
-      */
-    private static int supportedVersion = 1;
-
-    /**
-     * Maps from characters to column numbers.  The main use of this is to
-     * avoid making room in the array for empty columns.
-     */
-    private CompactByteArray columnMap = null;
-    private SupplementaryCharacterData supplementaryCharColumnMap = null;
-
-    /**
-     * The number of actual columns in the table
-     */
-    private int numCols;
-
-    /**
-     * Columns are organized into groups of 32.  This says how many
-     * column groups.  (We could calculate this, but we store the
-     * value to avoid having to repeatedly calculate it.)
-     */
-    private int numColGroups;
-
-    /**
-     * The actual compressed state table.  Each conceptual row represents
-     * a state, and the cells in it contain the row numbers of the states
-     * to transition to for each possible letter.  0 is used to indicate
-     * an illegal combination of letters (i.e., the error state).  The
-     * table is compressed by eliminating all the unpopulated (i.e., zero)
-     * cells.  Multiple conceptual rows can then be doubled up in a single
-     * physical row by sliding them up and possibly shifting them to one
-     * side or the other so the populated cells don't collide.  Indexes
-     * are used to identify unpopulated cells and to locate populated cells.
-     */
-    private short[] table = null;
-
-    /**
-     * This index maps logical row numbers to physical row numbers
-     */
-    private short[] rowIndex = null;
-
-    /**
-     * A bitmap is used to tell which cells in the comceptual table are
-     * populated.  This array contains all the unique bit combinations
-     * in that bitmap.  If the table is more than 32 columns wide,
-     * successive entries in this array are used for a single row.
-     */
-    private int[] rowIndexFlags = null;
-
-    /**
-     * This index maps from a logical row number into the bitmap table above.
-     * (This keeps us from storing duplicate bitmap combinations.)  Since there
-     * are a lot of rows with only one populated cell, instead of wasting space
-     * in the bitmap table, we just store a negative number in this index for
-     * rows with one populated cell.  The absolute value of that number is
-     * the column number of the populated cell.
-     */
-    private short[] rowIndexFlagsIndex = null;
-
-    /**
-     * For each logical row, this index contains a constant that is added to
-     * the logical column number to get the physical column number
-     */
-    private byte[] rowIndexShifts = null;
-
-    //=========================================================================
-    // deserialization
-    //=========================================================================
-
-    BreakDictionary(Module module, String dictionaryName)
-        throws IOException, MissingResourceException {
-
-        readDictionaryFile(module, dictionaryName);
-    }
-
-    private void readDictionaryFile(final Module module, final String dictionaryName)
-        throws IOException, MissingResourceException {
-
-        BufferedInputStream in;
-        try {
-            PrivilegedExceptionAction<BufferedInputStream> pa = () -> {
-                String pathName = "jdk.localedata".equals(module.getName()) ?
-                     "sun/text/resources/ext/" :
-                     "sun/text/resources/";
-                InputStream is = module.getResourceAsStream(pathName + dictionaryName);
-                if (is == null) {
-                    // Try to load the file with "java.base" module instance. Assumption
-                    // here is that the fall back data files to be read should reside in
-                    // java.base.
-                    is = BreakDictionary.class.getModule().getResourceAsStream("sun/text/resources/" + dictionaryName);
-                }
-
-                return new BufferedInputStream(is);
-            };
-            in = AccessController.doPrivileged(pa);
-        }
-        catch (PrivilegedActionException e) {
-            throw new InternalError(e.toString(), e);
-        }
-
-        byte[] buf = new byte[8];
-        if (in.read(buf) != 8) {
-            throw new MissingResourceException("Wrong data length",
-                                               dictionaryName, "");
-        }
-
-        // check version
-        int version = RuleBasedBreakIterator.getInt(buf, 0);
-        if (version != supportedVersion) {
-            throw new MissingResourceException("Dictionary version(" + version + ") is unsupported",
-                                                           dictionaryName, "");
-        }
-
-        // get data size
-        int len = RuleBasedBreakIterator.getInt(buf, 4);
-        buf = new byte[len];
-        if (in.read(buf) != len) {
-            throw new MissingResourceException("Wrong data length",
-                                               dictionaryName, "");
-        }
-
-        // close the stream
-        in.close();
-
-        int l;
-        int offset = 0;
-
-        // read in the column map for BMP characteres (this is serialized in
-        // its internal form: an index array followed by a data array)
-        l = RuleBasedBreakIterator.getInt(buf, offset);
-        offset += 4;
-        short[] temp = new short[l];
-        for (int i = 0; i < l; i++, offset+=2) {
-            temp[i] = RuleBasedBreakIterator.getShort(buf, offset);
-        }
-        l = RuleBasedBreakIterator.getInt(buf, offset);
-        offset += 4;
-        byte[] temp2 = new byte[l];
-        for (int i = 0; i < l; i++, offset++) {
-            temp2[i] = buf[offset];
-        }
-        columnMap = new CompactByteArray(temp, temp2);
-
-        // read in numCols and numColGroups
-        numCols = RuleBasedBreakIterator.getInt(buf, offset);
-        offset += 4;
-        numColGroups = RuleBasedBreakIterator.getInt(buf, offset);
-        offset += 4;
-
-        // read in the row-number index
-        l = RuleBasedBreakIterator.getInt(buf, offset);
-        offset += 4;
-        rowIndex = new short[l];
-        for (int i = 0; i < l; i++, offset+=2) {
-            rowIndex[i] = RuleBasedBreakIterator.getShort(buf, offset);
-        }
-
-        // load in the populated-cells bitmap: index first, then bitmap list
-        l = RuleBasedBreakIterator.getInt(buf, offset);
-        offset += 4;
-        rowIndexFlagsIndex = new short[l];
-        for (int i = 0; i < l; i++, offset+=2) {
-            rowIndexFlagsIndex[i] = RuleBasedBreakIterator.getShort(buf, offset);
-        }
-        l = RuleBasedBreakIterator.getInt(buf, offset);
-        offset += 4;
-        rowIndexFlags = new int[l];
-        for (int i = 0; i < l; i++, offset+=4) {
-            rowIndexFlags[i] = RuleBasedBreakIterator.getInt(buf, offset);
-        }
-
-        // load in the row-shift index
-        l = RuleBasedBreakIterator.getInt(buf, offset);
-        offset += 4;
-        rowIndexShifts = new byte[l];
-        for (int i = 0; i < l; i++, offset++) {
-            rowIndexShifts[i] = buf[offset];
-        }
-
-        // load in the actual state table
-        l = RuleBasedBreakIterator.getInt(buf, offset);
-        offset += 4;
-        table = new short[l];
-        for (int i = 0; i < l; i++, offset+=2) {
-            table[i] = RuleBasedBreakIterator.getShort(buf, offset);
-        }
-
-        // finally, prepare the column map for supplementary characters
-        l = RuleBasedBreakIterator.getInt(buf, offset);
-        offset += 4;
-        int[] temp3 = new int[l];
-        for (int i = 0; i < l; i++, offset+=4) {
-            temp3[i] = RuleBasedBreakIterator.getInt(buf, offset);
-        }
-        supplementaryCharColumnMap = new SupplementaryCharacterData(temp3);
-    }
-
-    //=========================================================================
-    // access to the words
-    //=========================================================================
-
-    /**
-     * Uses the column map to map the character to a column number, then
-     * passes the row and column number to getNextState()
-     * @param row The current state
-     * @param ch The character whose column we're interested in
-     * @return The new state to transition to
-     */
-    public final short getNextStateFromCharacter(int row, int ch) {
-        int col;
-        if (ch < Character.MIN_SUPPLEMENTARY_CODE_POINT) {
-            col = columnMap.elementAt((char)ch);
-        } else {
-            col = supplementaryCharColumnMap.getValue(ch);
-        }
-        return getNextState(row, col);
-    }
-
-    /**
-     * Returns the value in the cell with the specified (logical) row and
-     * column numbers.  In DictionaryBasedBreakIterator, the row number is
-     * a state number, the column number is an input, and the return value
-     * is the row number of the new state to transition to.  (0 is the
-     * "error" state, and -1 is the "end of word" state in a dictionary)
-     * @param row The row number of the current state
-     * @param col The column number of the input character (0 means "not a
-     * dictionary character")
-     * @return The row number of the new state to transition to
-     */
-    public final short getNextState(int row, int col) {
-        if (cellIsPopulated(row, col)) {
-            // we map from logical to physical row number by looking up the
-            // mapping in rowIndex; we map from logical column number to
-            // physical column number by looking up a shift value for this
-            // logical row and offsetting the logical column number by
-            // the shift amount.  Then we can use internalAt() to actually
-            // get the value out of the table.
-            return internalAt(rowIndex[row], col + rowIndexShifts[row]);
-        }
-        else {
-            return 0;
-        }
-    }
-
-    /**
-     * Given (logical) row and column numbers, returns true if the
-     * cell in that position is populated
-     */
-    private boolean cellIsPopulated(int row, int col) {
-        // look up the entry in the bitmap index for the specified row.
-        // If it's a negative number, it's the column number of the only
-        // populated cell in the row
-        if (rowIndexFlagsIndex[row] < 0) {
-            return col == -rowIndexFlagsIndex[row];
-        }
-
-        // if it's a positive number, it's the offset of an entry in the bitmap
-        // list.  If the table is more than 32 columns wide, the bitmap is stored
-        // successive entries in the bitmap list, so we have to divide the column
-        // number by 32 and offset the number we got out of the index by the result.
-        // Once we have the appropriate piece of the bitmap, test the appropriate
-        // bit and return the result.
-        else {
-            int flags = rowIndexFlags[rowIndexFlagsIndex[row] + (col >> 5)];
-            return (flags & (1 << (col & 0x1f))) != 0;
-        }
-    }
-
-    /**
-     * Implementation of getNextState() when we know the specified cell is
-     * populated.
-     * @param row The PHYSICAL row number of the cell
-     * @param col The PHYSICAL column number of the cell
-     * @return The value stored in the cell
-     */
-    private short internalAt(int row, int col) {
-        // the table is a one-dimensional array, so this just does the math necessary
-        // to treat it as a two-dimensional array (we don't just use a two-dimensional
-        // array because two-dimensional arrays are inefficient in Java)
-        return table[row * numCols + col];
-    }
-}
--- a/src/java.base/share/classes/sun/util/locale/provider/BreakIteratorProviderImpl.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/sun/util/locale/provider/BreakIteratorProviderImpl.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,8 @@
 import java.util.MissingResourceException;
 import java.util.Objects;
 import java.util.Set;
+import sun.text.DictionaryBasedBreakIterator;
+import sun.text.RuleBasedBreakIterator;
 
 /**
  * Concrete implementation of the  {@link java.text.spi.BreakIteratorProvider
@@ -153,29 +155,31 @@
     }
 
     private BreakIterator getBreakInstance(Locale locale,
-                                                  int type,
-                                                  String dataName,
-                                                  String dictionaryName) {
+                                           int type,
+                                           String ruleName,
+                                           String dictionaryName) {
         Objects.requireNonNull(locale);
 
         LocaleResources lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
         String[] classNames = (String[]) lr.getBreakIteratorInfo("BreakIteratorClasses");
-        String dataFile = (String) lr.getBreakIteratorInfo(dataName);
+        String ruleFile = (String) lr.getBreakIteratorInfo(ruleName);
+        byte[] ruleData = lr.getBreakIteratorResources(ruleName);
 
         try {
             switch (classNames[type]) {
             case "RuleBasedBreakIterator":
-                return new RuleBasedBreakIterator(
-                    lr.getBreakIteratorDataModule(), dataFile);
+                return new RuleBasedBreakIterator(ruleFile, ruleData);
+
             case "DictionaryBasedBreakIterator":
                 String dictionaryFile = (String) lr.getBreakIteratorInfo(dictionaryName);
-                return new DictionaryBasedBreakIterator(
-                    lr.getBreakIteratorDataModule(), dataFile, dictionaryFile);
+                byte[] dictionaryData = lr.getBreakIteratorResources(dictionaryName);
+                return new DictionaryBasedBreakIterator(ruleFile, ruleData,
+                                                        dictionaryFile, dictionaryData);
             default:
                 throw new IllegalArgumentException("Invalid break iterator class \"" +
                                 classNames[type] + "\"");
             }
-        } catch (IOException | MissingResourceException | IllegalArgumentException e) {
+        } catch (MissingResourceException | IllegalArgumentException e) {
             throw new InternalError(e.toString(), e);
         }
     }
--- a/src/java.base/share/classes/sun/util/locale/provider/DictionaryBasedBreakIterator.java	Thu Oct 27 09:38:46 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,524 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- */
-
-/*
- *
- * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
- * (C) Copyright IBM Corp. 1996 - 2002 - All Rights Reserved
- *
- * The original version of this source code and documentation
- * is copyrighted and owned by Taligent, Inc., a wholly-owned
- * subsidiary of IBM. These materials are provided under terms
- * of a License Agreement between Taligent and Sun. This technology
- * is protected by multiple US and International patents.
- *
- * This notice and attribution to Taligent may not be removed.
- * Taligent is a registered trademark of Taligent, Inc.
- */
-
-package sun.util.locale.provider;
-
-import java.io.IOException;
-import java.lang.reflect.Module;
-import java.text.CharacterIterator;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Stack;
-
-/**
- * A subclass of RuleBasedBreakIterator that adds the ability to use a dictionary
- * to further subdivide ranges of text beyond what is possible using just the
- * state-table-based algorithm.  This is necessary, for example, to handle
- * word and line breaking in Thai, which doesn't use spaces between words.  The
- * state-table-based algorithm used by RuleBasedBreakIterator is used to divide
- * up text as far as possible, and then contiguous ranges of letters are
- * repeatedly compared against a list of known words (i.e., the dictionary)
- * to divide them up into words.
- *
- * DictionaryBasedBreakIterator uses the same rule language as RuleBasedBreakIterator,
- * but adds one more special substitution name: &lt;dictionary&gt;.  This substitution
- * name is used to identify characters in words in the dictionary.  The idea is that
- * if the iterator passes over a chunk of text that includes two or more characters
- * in a row that are included in &lt;dictionary&gt;, it goes back through that range and
- * derives additional break positions (if possible) using the dictionary.
- *
- * DictionaryBasedBreakIterator is also constructed with the filename of a dictionary
- * file.  It follows a prescribed search path to locate the dictionary (right now,
- * it looks for it in /com/ibm/text/resources in each directory in the classpath,
- * and won't find it in JAR files, but this location is likely to change).  The
- * dictionary file is in a serialized binary format.  We have a very primitive (and
- * slow) BuildDictionaryFile utility for creating dictionary files, but aren't
- * currently making it public.  Contact us for help.
- */
-class DictionaryBasedBreakIterator extends RuleBasedBreakIterator {
-
-    /**
-     * a list of known words that is used to divide up contiguous ranges of letters,
-     * stored in a compressed, indexed, format that offers fast access
-     */
-    private BreakDictionary dictionary;
-
-    /**
-     * a list of flags indicating which character categories are contained in
-     * the dictionary file (this is used to determine which ranges of characters
-     * to apply the dictionary to)
-     */
-    private boolean[] categoryFlags;
-
-    /**
-     * a temporary hiding place for the number of dictionary characters in the
-     * last range passed over by next()
-     */
-    private int dictionaryCharCount;
-
-    /**
-     * when a range of characters is divided up using the dictionary, the break
-     * positions that are discovered are stored here, preventing us from having
-     * to use either the dictionary or the state table again until the iterator
-     * leaves this range of text
-     */
-    private int[] cachedBreakPositions;
-
-    /**
-     * if cachedBreakPositions is not null, this indicates which item in the
-     * cache the current iteration position refers to
-     */
-    private int positionInCache;
-
-    /**
-     * Constructs a DictionaryBasedBreakIterator.
-     * @param module The module where the dictionary file resides
-     * @param dictionaryFilename The filename of the dictionary file to use
-     */
-    DictionaryBasedBreakIterator(Module module, String dataFile, String dictionaryFile)
-                                        throws IOException {
-        super(module, dataFile);
-        byte[] tmp = super.getAdditionalData();
-        if (tmp != null) {
-            prepareCategoryFlags(tmp);
-            super.setAdditionalData(null);
-        }
-        dictionary = new BreakDictionary(module, dictionaryFile);
-    }
-
-    private void prepareCategoryFlags(byte[] data) {
-        categoryFlags = new boolean[data.length];
-        for (int i = 0; i < data.length; i++) {
-            categoryFlags[i] = (data[i] == (byte)1) ? true : false;
-        }
-    }
-
-    @Override
-    public void setText(CharacterIterator newText) {
-        super.setText(newText);
-        cachedBreakPositions = null;
-        dictionaryCharCount = 0;
-        positionInCache = 0;
-    }
-
-    /**
-     * Sets the current iteration position to the beginning of the text.
-     * (i.e., the CharacterIterator's starting offset).
-     * @return The offset of the beginning of the text.
-     */
-    @Override
-    public int first() {
-        cachedBreakPositions = null;
-        dictionaryCharCount = 0;
-        positionInCache = 0;
-        return super.first();
-    }
-
-    /**
-     * Sets the current iteration position to the end of the text.
-     * (i.e., the CharacterIterator's ending offset).
-     * @return The text's past-the-end offset.
-     */
-    @Override
-    public int last() {
-        cachedBreakPositions = null;
-        dictionaryCharCount = 0;
-        positionInCache = 0;
-        return super.last();
-    }
-
-    /**
-     * Advances the iterator one step backwards.
-     * @return The position of the last boundary position before the
-     * current iteration position
-     */
-    @Override
-    public int previous() {
-        CharacterIterator text = getText();
-
-        // if we have cached break positions and we're still in the range
-        // covered by them, just move one step backward in the cache
-        if (cachedBreakPositions != null && positionInCache > 0) {
-            --positionInCache;
-            text.setIndex(cachedBreakPositions[positionInCache]);
-            return cachedBreakPositions[positionInCache];
-        }
-
-        // otherwise, dump the cache and use the inherited previous() method to move
-        // backward.  This may fill up the cache with new break positions, in which
-        // case we have to mark our position in the cache
-        else {
-            cachedBreakPositions = null;
-            int result = super.previous();
-            if (cachedBreakPositions != null) {
-                positionInCache = cachedBreakPositions.length - 2;
-            }
-            return result;
-        }
-    }
-
-    /**
-     * Sets the current iteration position to the last boundary position
-     * before the specified position.
-     * @param offset The position to begin searching from
-     * @return The position of the last boundary before "offset"
-     */
-    @Override
-    public int preceding(int offset) {
-        CharacterIterator text = getText();
-        checkOffset(offset, text);
-
-        // if we have no cached break positions, or "offset" is outside the
-        // range covered by the cache, we can just call the inherited routine
-        // (which will eventually call other routines in this class that may
-        // refresh the cache)
-        if (cachedBreakPositions == null || offset <= cachedBreakPositions[0] ||
-                offset > cachedBreakPositions[cachedBreakPositions.length - 1]) {
-            cachedBreakPositions = null;
-            return super.preceding(offset);
-        }
-
-        // on the other hand, if "offset" is within the range covered by the cache,
-        // then all we have to do is search the cache for the last break position
-        // before "offset"
-        else {
-            positionInCache = 0;
-            while (positionInCache < cachedBreakPositions.length
-                   && offset > cachedBreakPositions[positionInCache]) {
-                ++positionInCache;
-            }
-            --positionInCache;
-            text.setIndex(cachedBreakPositions[positionInCache]);
-            return text.getIndex();
-        }
-    }
-
-    /**
-     * Sets the current iteration position to the first boundary position after
-     * the specified position.
-     * @param offset The position to begin searching forward from
-     * @return The position of the first boundary after "offset"
-     */
-    @Override
-    public int following(int offset) {
-        CharacterIterator text = getText();
-        checkOffset(offset, text);
-
-        // if we have no cached break positions, or if "offset" is outside the
-        // range covered by the cache, then dump the cache and call our
-        // inherited following() method.  This will call other methods in this
-        // class that may refresh the cache.
-        if (cachedBreakPositions == null || offset < cachedBreakPositions[0] ||
-                offset >= cachedBreakPositions[cachedBreakPositions.length - 1]) {
-            cachedBreakPositions = null;
-            return super.following(offset);
-        }
-
-        // on the other hand, if "offset" is within the range covered by the
-        // cache, then just search the cache for the first break position
-        // after "offset"
-        else {
-            positionInCache = 0;
-            while (positionInCache < cachedBreakPositions.length
-                   && offset >= cachedBreakPositions[positionInCache]) {
-                ++positionInCache;
-            }
-            text.setIndex(cachedBreakPositions[positionInCache]);
-            return text.getIndex();
-        }
-    }
-
-    /**
-     * This is the implementation function for next().
-     */
-    @Override
-    protected int handleNext() {
-        CharacterIterator text = getText();
-
-        // if there are no cached break positions, or if we've just moved
-        // off the end of the range covered by the cache, we have to dump
-        // and possibly regenerate the cache
-        if (cachedBreakPositions == null ||
-            positionInCache == cachedBreakPositions.length - 1) {
-
-            // start by using the inherited handleNext() to find a tentative return
-            // value.   dictionaryCharCount tells us how many dictionary characters
-            // we passed over on our way to the tentative return value
-            int startPos = text.getIndex();
-            dictionaryCharCount = 0;
-            int result = super.handleNext();
-
-            // if we passed over more than one dictionary character, then we use
-            // divideUpDictionaryRange() to regenerate the cached break positions
-            // for the new range
-            if (dictionaryCharCount > 1 && result - startPos > 1) {
-                divideUpDictionaryRange(startPos, result);
-            }
-
-            // otherwise, the value we got back from the inherited fuction
-            // is our return value, and we can dump the cache
-            else {
-                cachedBreakPositions = null;
-                return result;
-            }
-        }
-
-        // if the cache of break positions has been regenerated (or existed all
-        // along), then just advance to the next break position in the cache
-        // and return it
-        if (cachedBreakPositions != null) {
-            ++positionInCache;
-            text.setIndex(cachedBreakPositions[positionInCache]);
-            return cachedBreakPositions[positionInCache];
-        }
-        return -9999;   // SHOULD NEVER GET HERE!
-    }
-
-    /**
-     * Looks up a character category for a character.
-     */
-    @Override
-    protected int lookupCategory(int c) {
-        // this override of lookupCategory() exists only to keep track of whether we've
-        // passed over any dictionary characters.  It calls the inherited lookupCategory()
-        // to do the real work, and then checks whether its return value is one of the
-        // categories represented in the dictionary.  If it is, bump the dictionary-
-        // character count.
-        int result = super.lookupCategory(c);
-        if (result != RuleBasedBreakIterator.IGNORE && categoryFlags[result]) {
-            ++dictionaryCharCount;
-        }
-        return result;
-    }
-
-    /**
-     * This is the function that actually implements the dictionary-based
-     * algorithm.  Given the endpoints of a range of text, it uses the
-     * dictionary to determine the positions of any boundaries in this
-     * range.  It stores all the boundary positions it discovers in
-     * cachedBreakPositions so that we only have to do this work once
-     * for each time we enter the range.
-     */
-    @SuppressWarnings("unchecked")
-    private void divideUpDictionaryRange(int startPos, int endPos) {
-        CharacterIterator text = getText();
-
-        // the range we're dividing may begin or end with non-dictionary characters
-        // (i.e., for line breaking, we may have leading or trailing punctuation
-        // that needs to be kept with the word).  Seek from the beginning of the
-        // range to the first dictionary character
-        text.setIndex(startPos);
-        int c = getCurrent();
-        int category = lookupCategory(c);
-        while (category == IGNORE || !categoryFlags[category]) {
-            c = getNext();
-            category = lookupCategory(c);
-        }
-
-        // initialize.  We maintain two stacks: currentBreakPositions contains
-        // the list of break positions that will be returned if we successfully
-        // finish traversing the whole range now.  possibleBreakPositions lists
-        // all other possible word ends we've passed along the way.  (Whenever
-        // we reach an error [a sequence of characters that can't begin any word
-        // in the dictionary], we back up, possibly delete some breaks from
-        // currentBreakPositions, move a break from possibleBreakPositions
-        // to currentBreakPositions, and start over from there.  This process
-        // continues in this way until we either successfully make it all the way
-        // across the range, or exhaust all of our combinations of break
-        // positions.)
-        Stack<Integer> currentBreakPositions = new Stack<>();
-        Stack<Integer> possibleBreakPositions = new Stack<>();
-        List<Integer> wrongBreakPositions = new ArrayList<>();
-
-        // the dictionary is implemented as a trie, which is treated as a state
-        // machine.  -1 represents the end of a legal word.  Every word in the
-        // dictionary is represented by a path from the root node to -1.  A path
-        // that ends in state 0 is an illegal combination of characters.
-        int state = 0;
-
-        // these two variables are used for error handling.  We keep track of the
-        // farthest we've gotten through the range being divided, and the combination
-        // of breaks that got us that far.  If we use up all possible break
-        // combinations, the text contains an error or a word that's not in the
-        // dictionary.  In this case, we "bless" the break positions that got us the
-        // farthest as real break positions, and then start over from scratch with
-        // the character where the error occurred.
-        int farthestEndPoint = text.getIndex();
-        Stack<Integer> bestBreakPositions = null;
-
-        // initialize (we always exit the loop with a break statement)
-        c = getCurrent();
-        while (true) {
-
-            // if we can transition to state "-1" from our current state, we're
-            // on the last character of a legal word.  Push that position onto
-            // the possible-break-positions stack
-            if (dictionary.getNextState(state, 0) == -1) {
-                possibleBreakPositions.push(text.getIndex());
-            }
-
-            // look up the new state to transition to in the dictionary
-            state = dictionary.getNextStateFromCharacter(state, c);
-
-            // if the character we're sitting on causes us to transition to
-            // the "end of word" state, then it was a non-dictionary character
-            // and we've successfully traversed the whole range.  Drop out
-            // of the loop.
-            if (state == -1) {
-                currentBreakPositions.push(text.getIndex());
-                break;
-            }
-
-            // if the character we're sitting on causes us to transition to
-            // the error state, or if we've gone off the end of the range
-            // without transitioning to the "end of word" state, we've hit
-            // an error...
-            else if (state == 0 || text.getIndex() >= endPos) {
-
-                // if this is the farthest we've gotten, take note of it in
-                // case there's an error in the text
-                if (text.getIndex() > farthestEndPoint) {
-                    farthestEndPoint = text.getIndex();
-
-                    @SuppressWarnings("unchecked")
-                    Stack<Integer> currentBreakPositionsCopy = (Stack<Integer>) currentBreakPositions.clone();
-
-                    bestBreakPositions = currentBreakPositionsCopy;
-                }
-
-                // wrongBreakPositions is a list of all break positions
-                // we've tried starting that didn't allow us to traverse
-                // all the way through the text.  Every time we pop a
-                // break position off of currentBreakPositions, we put it
-                // into wrongBreakPositions to avoid trying it again later.
-                // If we make it to this spot, we're either going to back
-                // up to a break in possibleBreakPositions and try starting
-                // over from there, or we've exhausted all possible break
-                // positions and are going to do the fallback procedure.
-                // This loop prevents us from messing with anything in
-                // possibleBreakPositions that didn't work as a starting
-                // point the last time we tried it (this is to prevent a bunch of
-                // repetitive checks from slowing down some extreme cases)
-                while (!possibleBreakPositions.isEmpty()
-                        && wrongBreakPositions.contains(possibleBreakPositions.peek())) {
-                    possibleBreakPositions.pop();
-                }
-
-                // if we've used up all possible break-position combinations, there's
-                // an error or an unknown word in the text.  In this case, we start
-                // over, treating the farthest character we've reached as the beginning
-                // of the range, and "blessing" the break positions that got us that
-                // far as real break positions
-                if (possibleBreakPositions.isEmpty()) {
-                    if (bestBreakPositions != null) {
-                        currentBreakPositions = bestBreakPositions;
-                        if (farthestEndPoint < endPos) {
-                            text.setIndex(farthestEndPoint + 1);
-                        }
-                        else {
-                            break;
-                        }
-                    }
-                    else {
-                        if ((currentBreakPositions.size() == 0 ||
-                             currentBreakPositions.peek().intValue() != text.getIndex())
-                            && text.getIndex() != startPos) {
-                            currentBreakPositions.push(text.getIndex());
-                        }
-                        getNext();
-                        currentBreakPositions.push(text.getIndex());
-                    }
-                }
-
-                // if we still have more break positions we can try, then promote the
-                // last break in possibleBreakPositions into currentBreakPositions,
-                // and get rid of all entries in currentBreakPositions that come after
-                // it.  Then back up to that position and start over from there (i.e.,
-                // treat that position as the beginning of a new word)
-                else {
-                    Integer temp = possibleBreakPositions.pop();
-                    Integer temp2 = null;
-                    while (!currentBreakPositions.isEmpty() && temp.intValue() <
-                           currentBreakPositions.peek().intValue()) {
-                        temp2 = currentBreakPositions.pop();
-                        wrongBreakPositions.add(temp2);
-                    }
-                    currentBreakPositions.push(temp);
-                    text.setIndex(currentBreakPositions.peek().intValue());
-                }
-
-                // re-sync "c" for the next go-round, and drop out of the loop if
-                // we've made it off the end of the range
-                c = getCurrent();
-                if (text.getIndex() >= endPos) {
-                    break;
-                }
-            }
-
-            // if we didn't hit any exceptional conditions on this last iteration,
-            // just advance to the next character and loop
-            else {
-                c = getNext();
-            }
-        }
-
-        // dump the last break position in the list, and replace it with the actual
-        // end of the range (which may be the same character, or may be further on
-        // because the range actually ended with non-dictionary characters we want to
-        // keep with the word)
-        if (!currentBreakPositions.isEmpty()) {
-            currentBreakPositions.pop();
-        }
-        currentBreakPositions.push(endPos);
-
-        // create a regular array to hold the break positions and copy
-        // the break positions from the stack to the array (in addition,
-        // our starting position goes into this array as a break position).
-        // This array becomes the cache of break positions used by next()
-        // and previous(), so this is where we actually refresh the cache.
-        cachedBreakPositions = new int[currentBreakPositions.size() + 1];
-        cachedBreakPositions[0] = startPos;
-
-        for (int i = 0; i < currentBreakPositions.size(); i++) {
-            cachedBreakPositions[i + 1] = currentBreakPositions.elementAt(i).intValue();
-        }
-        positionInCache = 0;
-    }
-}
--- a/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,6 @@
 
 import java.lang.ref.ReferenceQueue;
 import java.lang.ref.SoftReference;
-import java.lang.reflect.Module;
 import java.text.MessageFormat;
 import java.util.Calendar;
 import java.util.LinkedHashSet;
@@ -113,13 +112,14 @@
         if (data == null || ((biInfo = data.get()) == null)) {
            biInfo = localeData.getBreakIteratorInfo(locale).getObject(key);
            cache.put(cacheKey, new ResourceReference(cacheKey, biInfo, referenceQueue));
-       }
+        }
 
        return biInfo;
     }
 
-    Module getBreakIteratorDataModule() {
-       return localeData.getBreakIteratorInfo(locale).getClass().getModule();
+    @SuppressWarnings("unchecked")
+    byte[] getBreakIteratorResources(String key) {
+        return (byte[]) localeData.getBreakIteratorResources(locale).getObject(key);
     }
 
     int getCalendarData(String key) {
--- a/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java	Thu Oct 27 09:38:46 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1198 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- */
-
-/*
- *
- * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
- * (C) Copyright IBM Corp. 1996 - 2002 - All Rights Reserved
- *
- * The original version of this source code and documentation
- * is copyrighted and owned by Taligent, Inc., a wholly-owned
- * subsidiary of IBM. These materials are provided under terms
- * of a License Agreement between Taligent and Sun. This technology
- * is protected by multiple US and International patents.
- *
- * This notice and attribution to Taligent may not be removed.
- * Taligent is a registered trademark of Taligent, Inc.
- */
-
-package sun.util.locale.provider;
-
-import java.io.BufferedInputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.lang.reflect.Module;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.text.BreakIterator;
-import java.text.CharacterIterator;
-import java.text.StringCharacterIterator;
-import java.util.MissingResourceException;
-import sun.text.CompactByteArray;
-import sun.text.SupplementaryCharacterData;
-
-/**
- * <p>A subclass of BreakIterator whose behavior is specified using a list of rules.</p>
- *
- * <p>There are two kinds of rules, which are separated by semicolons: <i>substitutions</i>
- * and <i>regular expressions.</i></p>
- *
- * <p>A substitution rule defines a name that can be used in place of an expression. It
- * consists of a name, which is a string of characters contained in angle brackets, an equals
- * sign, and an expression. (There can be no whitespace on either side of the equals sign.)
- * To keep its syntactic meaning intact, the expression must be enclosed in parentheses or
- * square brackets. A substitution is visible after its definition, and is filled in using
- * simple textual substitution. Substitution definitions can contain other substitutions, as
- * long as those substitutions have been defined first. Substitutions are generally used to
- * make the regular expressions (which can get quite complex) shorted and easier to read.
- * They typically define either character categories or commonly-used subexpressions.</p>
- *
- * <p>There is one special substitution.&nbsp; If the description defines a substitution
- * called &quot;&lt;ignore&gt;&quot;, the expression must be a [] expression, and the
- * expression defines a set of characters (the &quot;<em>ignore characters</em>&quot;) that
- * will be transparent to the BreakIterator.&nbsp; A sequence of characters will break the
- * same way it would if any ignore characters it contains are taken out.&nbsp; Break
- * positions never occur befoer ignore characters.</p>
- *
- * <p>A regular expression uses a subset of the normal Unix regular-expression syntax, and
- * defines a sequence of characters to be kept together. With one significant exception, the
- * iterator uses a longest-possible-match algorithm when matching text to regular
- * expressions. The iterator also treats descriptions containing multiple regular expressions
- * as if they were ORed together (i.e., as if they were separated by |).</p>
- *
- * <p>The special characters recognized by the regular-expression parser are as follows:</p>
- *
- * <blockquote>
- *   <table border="1" width="100%">
- *     <tr>
- *       <td width="6%">*</td>
- *       <td width="94%">Specifies that the expression preceding the asterisk may occur any number
- *       of times (including not at all).</td>
- *     </tr>
- *     <tr>
- *       <td width="6%">{}</td>
- *       <td width="94%">Encloses a sequence of characters that is optional.</td>
- *     </tr>
- *     <tr>
- *       <td width="6%">()</td>
- *       <td width="94%">Encloses a sequence of characters.&nbsp; If followed by *, the sequence
- *       repeats.&nbsp; Otherwise, the parentheses are just a grouping device and a way to delimit
- *       the ends of expressions containing |.</td>
- *     </tr>
- *     <tr>
- *       <td width="6%">|</td>
- *       <td width="94%">Separates two alternative sequences of characters.&nbsp; Either one
- *       sequence or the other, but not both, matches this expression.&nbsp; The | character can
- *       only occur inside ().</td>
- *     </tr>
- *     <tr>
- *       <td width="6%">.</td>
- *       <td width="94%">Matches any character.</td>
- *     </tr>
- *     <tr>
- *       <td width="6%">*?</td>
- *       <td width="94%">Specifies a non-greedy asterisk.&nbsp; *? works the same way as *, except
- *       when there is overlap between the last group of characters in the expression preceding the
- *       * and the first group of characters following the *.&nbsp; When there is this kind of
- *       overlap, * will match the longest sequence of characters that match the expression before
- *       the *, and *? will match the shortest sequence of characters matching the expression
- *       before the *?.&nbsp; For example, if you have &quot;xxyxyyyxyxyxxyxyxyy&quot; in the text,
- *       &quot;x[xy]*x&quot; will match through to the last x (i.e., &quot;<strong>xxyxyyyxyxyxxyxyx</strong>yy&quot;,
- *       but &quot;x[xy]*?x&quot; will only match the first two xes (&quot;<strong>xx</strong>yxyyyxyxyxxyxyxyy&quot;).</td>
- *     </tr>
- *     <tr>
- *       <td width="6%">[]</td>
- *       <td width="94%">Specifies a group of alternative characters.&nbsp; A [] expression will
- *       match any single character that is specified in the [] expression.&nbsp; For more on the
- *       syntax of [] expressions, see below.</td>
- *     </tr>
- *     <tr>
- *       <td width="6%">/</td>
- *       <td width="94%">Specifies where the break position should go if text matches this
- *       expression.&nbsp; (e.g., &quot;[a-z]&#42;/[:Zs:]*[1-0]&quot; will match if the iterator sees a run
- *       of letters, followed by a run of whitespace, followed by a digit, but the break position
- *       will actually go before the whitespace).&nbsp; Expressions that don't contain / put the
- *       break position at the end of the matching text.</td>
- *     </tr>
- *     <tr>
- *       <td width="6%">\</td>
- *       <td width="94%">Escape character.&nbsp; The \ itself is ignored, but causes the next
- *       character to be treated as literal character.&nbsp; This has no effect for many
- *       characters, but for the characters listed above, this deprives them of their special
- *       meaning.&nbsp; (There are no special escape sequences for Unicode characters, or tabs and
- *       newlines; these are all handled by a higher-level protocol.&nbsp; In a Java string,
- *       &quot;\n&quot; will be converted to a literal newline character by the time the
- *       regular-expression parser sees it.&nbsp; Of course, this means that \ sequences that are
- *       visible to the regexp parser must be written as \\ when inside a Java string.)&nbsp; All
- *       characters in the ASCII range except for letters, digits, and control characters are
- *       reserved characters to the parser and must be preceded by \ even if they currently don't
- *       mean anything.</td>
- *     </tr>
- *     <tr>
- *       <td width="6%">!</td>
- *       <td width="94%">If ! appears at the beginning of a regular expression, it tells the regexp
- *       parser that this expression specifies the backwards-iteration behavior of the iterator,
- *       and not its normal iteration behavior.&nbsp; This is generally only used in situations
- *       where the automatically-generated backwards-iteration brhavior doesn't produce
- *       satisfactory results and must be supplemented with extra client-specified rules.</td>
- *     </tr>
- *     <tr>
- *       <td width="6%"><em>(all others)</em></td>
- *       <td width="94%">All other characters are treated as literal characters, which must match
- *       the corresponding character(s) in the text exactly.</td>
- *     </tr>
- *   </table>
- * </blockquote>
- *
- * <p>Within a [] expression, a number of other special characters can be used to specify
- * groups of characters:</p>
- *
- * <blockquote>
- *   <table border="1" width="100%">
- *     <tr>
- *       <td width="6%">-</td>
- *       <td width="94%">Specifies a range of matching characters.&nbsp; For example
- *       &quot;[a-p]&quot; matches all lowercase Latin letters from a to p (inclusive).&nbsp; The -
- *       sign specifies ranges of continuous Unicode numeric values, not ranges of characters in a
- *       language's alphabetical order: &quot;[a-z]&quot; doesn't include capital letters, nor does
- *       it include accented letters such as a-umlaut.</td>
- *     </tr>
- *     <tr>
- *       <td width="6%">::</td>
- *       <td width="94%">A pair of colons containing a one- or two-letter code matches all
- *       characters in the corresponding Unicode category.&nbsp; The two-letter codes are the same
- *       as the two-letter codes in the Unicode database (for example, &quot;[:Sc::Sm:]&quot;
- *       matches all currency symbols and all math symbols).&nbsp; Specifying a one-letter code is
- *       the same as specifying all two-letter codes that begin with that letter (for example,
- *       &quot;[:L:]&quot; matches all letters, and is equivalent to
- *       &quot;[:Lu::Ll::Lo::Lm::Lt:]&quot;).&nbsp; Anything other than a valid two-letter Unicode
- *       category code or a single letter that begins a Unicode category code is illegal within
- *       colons.</td>
- *     </tr>
- *     <tr>
- *       <td width="6%">[]</td>
- *       <td width="94%">[] expressions can nest.&nbsp; This has no effect, except when used in
- *       conjunction with the ^ token.</td>
- *     </tr>
- *     <tr>
- *       <td width="6%">^</td>
- *       <td width="94%">Excludes the character (or the characters in the [] expression) following
- *       it from the group of characters.&nbsp; For example, &quot;[a-z^p]&quot; matches all Latin
- *       lowercase letters except p.&nbsp; &quot;[:L:^[&#92;u4e00-&#92;u9fff]]&quot; matches all letters
- *       except the Han ideographs.</td>
- *     </tr>
- *     <tr>
- *       <td width="6%"><em>(all others)</em></td>
- *       <td width="94%">All other characters are treated as literal characters.&nbsp; (For
- *       example, &quot;[aeiou]&quot; specifies just the letters a, e, i, o, and u.)</td>
- *     </tr>
- *   </table>
- * </blockquote>
- *
- * <p>For a more complete explanation, see <a
- * href="http://www.ibm.com/java/education/boundaries/boundaries.html">http://www.ibm.com/java/education/boundaries/boundaries.html</a>.
- * &nbsp; For examples, see the resource data (which is annotated).</p>
- *
- * @author Richard Gillam
- */
-class RuleBasedBreakIterator extends BreakIterator {
-
-    /**
-     * A token used as a character-category value to identify ignore characters
-     */
-    protected static final byte IGNORE = -1;
-
-    /**
-     * The state number of the starting state
-     */
-    private static final short START_STATE = 1;
-
-    /**
-     * The state-transition value indicating "stop"
-     */
-    private static final short STOP_STATE = 0;
-
-    /**
-     * Magic number for the BreakIterator data file format.
-     */
-    static final byte[] LABEL = {
-        (byte)'B', (byte)'I', (byte)'d', (byte)'a', (byte)'t', (byte)'a',
-        (byte)'\0'
-    };
-    static final int    LABEL_LENGTH = LABEL.length;
-
-    /**
-     * Version number of the dictionary that was read in.
-     */
-    static final byte supportedVersion = 1;
-
-    /**
-     * Header size in byte count
-     */
-    private static final int HEADER_LENGTH = 36;
-
-    /**
-     * An array length of indices for BMP characters
-     */
-    private static final int BMP_INDICES_LENGTH = 512;
-
-    /**
-     * Tables that indexes from character values to character category numbers
-     */
-    private CompactByteArray charCategoryTable = null;
-    private SupplementaryCharacterData supplementaryCharCategoryTable = null;
-
-    /**
-     * The table of state transitions used for forward iteration
-     */
-    private short[] stateTable = null;
-
-    /**
-     * The table of state transitions used to sync up the iterator with the
-     * text in backwards and random-access iteration
-     */
-    private short[] backwardsStateTable = null;
-
-    /**
-     * A list of flags indicating which states in the state table are accepting
-     * ("end") states
-     */
-    private boolean[] endStates = null;
-
-    /**
-     * A list of flags indicating which states in the state table are
-     * lookahead states (states which turn lookahead on and off)
-     */
-    private boolean[] lookaheadStates = null;
-
-    /**
-     * A table for additional data. May be used by a subclass of
-     * RuleBasedBreakIterator.
-     */
-    private byte[] additionalData = null;
-
-    /**
-     * The number of character categories (and, thus, the number of columns in
-     * the state tables)
-     */
-    private int numCategories;
-
-    /**
-     * The character iterator through which this BreakIterator accesses the text
-     */
-    private CharacterIterator text = null;
-
-    /**
-     * A CRC32 value of all data in datafile
-     */
-    private long checksum;
-
-    //=======================================================================
-    // constructors
-    //=======================================================================
-
-    /**
-     * Constructs a RuleBasedBreakIterator according to the module and the datafile
-     * provided.
-     */
-    RuleBasedBreakIterator(Module module, String datafile)
-        throws IOException, MissingResourceException {
-        readTables(module, datafile);
-    }
-
-    /**
-     * Read datafile. The datafile's format is as follows:
-     * <pre>
-     *   BreakIteratorData {
-     *       u1           magic[7];
-     *       u1           version;
-     *       u4           totalDataSize;
-     *       header_info  header;
-     *       body         value;
-     *   }
-     * </pre>
-     * <code>totalDataSize</code> is the summation of the size of
-     * <code>header_info</code> and <code>body</code> in byte count.
-     * <p>
-     * In <code>header</code>, each field except for checksum implies the
-     * length of each field. Since <code>BMPdataLength</code> is a fixed-length
-     *  data(512 entries), its length isn't included in <code>header</code>.
-     * <code>checksum</code> is a CRC32 value of all in <code>body</code>.
-     * <pre>
-     *   header_info {
-     *       u4           stateTableLength;
-     *       u4           backwardsStateTableLength;
-     *       u4           endStatesLength;
-     *       u4           lookaheadStatesLength;
-     *       u4           BMPdataLength;
-     *       u4           nonBMPdataLength;
-     *       u4           additionalDataLength;
-     *       u8           checksum;
-     *   }
-     * </pre>
-     * <p>
-     *
-     * Finally, <code>BMPindices</code> and <code>BMPdata</code> are set to
-     * <code>charCategoryTable</code>. <code>nonBMPdata</code> is set to
-     * <code>supplementaryCharCategoryTable</code>.
-     * <pre>
-     *   body {
-     *       u2           stateTable[stateTableLength];
-     *       u2           backwardsStateTable[backwardsStateTableLength];
-     *       u1           endStates[endStatesLength];
-     *       u1           lookaheadStates[lookaheadStatesLength];
-     *       u2           BMPindices[512];
-     *       u1           BMPdata[BMPdataLength];
-     *       u4           nonBMPdata[numNonBMPdataLength];
-     *       u1           additionalData[additionalDataLength];
-     *   }
-     * </pre>
-     */
-    protected final void readTables(Module module, String datafile)
-        throws IOException, MissingResourceException {
-
-        byte[] buffer = readFile(module, datafile);
-
-        /* Read header_info. */
-        int stateTableLength = getInt(buffer, 0);
-        int backwardsStateTableLength = getInt(buffer, 4);
-        int endStatesLength = getInt(buffer, 8);
-        int lookaheadStatesLength = getInt(buffer, 12);
-        int BMPdataLength = getInt(buffer, 16);
-        int nonBMPdataLength = getInt(buffer, 20);
-        int additionalDataLength = getInt(buffer, 24);
-        checksum = getLong(buffer, 28);
-
-        /* Read stateTable[numCategories * numRows] */
-        stateTable = new short[stateTableLength];
-        int offset = HEADER_LENGTH;
-        for (int i = 0; i < stateTableLength; i++, offset+=2) {
-           stateTable[i] = getShort(buffer, offset);
-        }
-
-        /* Read backwardsStateTable[numCategories * numRows] */
-        backwardsStateTable = new short[backwardsStateTableLength];
-        for (int i = 0; i < backwardsStateTableLength; i++, offset+=2) {
-           backwardsStateTable[i] = getShort(buffer, offset);
-        }
-
-        /* Read endStates[numRows] */
-        endStates = new boolean[endStatesLength];
-        for (int i = 0; i < endStatesLength; i++, offset++) {
-           endStates[i] = buffer[offset] == 1;
-        }
-
-        /* Read lookaheadStates[numRows] */
-        lookaheadStates = new boolean[lookaheadStatesLength];
-        for (int i = 0; i < lookaheadStatesLength; i++, offset++) {
-           lookaheadStates[i] = buffer[offset] == 1;
-        }
-
-        /* Read a category table and indices for BMP characters. */
-        short[] temp1 = new short[BMP_INDICES_LENGTH];  // BMPindices
-        for (int i = 0; i < BMP_INDICES_LENGTH; i++, offset+=2) {
-            temp1[i] = getShort(buffer, offset);
-        }
-        byte[] temp2 = new byte[BMPdataLength];  // BMPdata
-        System.arraycopy(buffer, offset, temp2, 0, BMPdataLength);
-        offset += BMPdataLength;
-        charCategoryTable = new CompactByteArray(temp1, temp2);
-
-        /* Read a category table for non-BMP characters. */
-        int[] temp3 = new int[nonBMPdataLength];
-        for (int i = 0; i < nonBMPdataLength; i++, offset+=4) {
-            temp3[i] = getInt(buffer, offset);
-        }
-        supplementaryCharCategoryTable = new SupplementaryCharacterData(temp3);
-
-        /* Read additional data */
-        if (additionalDataLength > 0) {
-            additionalData = new byte[additionalDataLength];
-            System.arraycopy(buffer, offset, additionalData, 0, additionalDataLength);
-        }
-
-        /* Set numCategories */
-        numCategories = stateTable.length / endStates.length;
-    }
-
-    protected byte[] readFile(final Module module, final String datafile)
-        throws IOException, MissingResourceException {
-
-        BufferedInputStream is;
-        try {
-            PrivilegedExceptionAction<BufferedInputStream> pa = () -> {
-                String pathName = "jdk.localedata".equals(module.getName()) ?
-                     "sun/text/resources/ext/" :
-                     "sun/text/resources/";
-                InputStream in = module.getResourceAsStream(pathName + datafile);
-                if (in == null) {
-                    // Try to load the file with "java.base" module instance. Assumption
-                    // here is that the fall back data files to be read should reside in
-                    // java.base.
-                    in = RuleBasedBreakIterator.class.getModule().getResourceAsStream("sun/text/resources/" + datafile);
-                }
-
-                return new BufferedInputStream(in);
-            };
-            is = AccessController.doPrivileged(pa);
-        } catch (PrivilegedActionException e) {
-            throw new InternalError(e.toString(), e);
-        }
-
-        int offset = 0;
-
-        /* First, read magic, version, and header_info. */
-        int len = LABEL_LENGTH + 5;
-        byte[] buf = new byte[len];
-        if (is.read(buf) != len) {
-            throw new MissingResourceException("Wrong header length",
-                                               datafile, "");
-        }
-
-        /* Validate the magic number. */
-        for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
-            if (buf[offset] != LABEL[offset]) {
-                throw new MissingResourceException("Wrong magic number",
-                                                   datafile, "");
-            }
-        }
-
-        /* Validate the version number. */
-        if (buf[offset] != supportedVersion) {
-            throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
-                                               datafile, "");
-        }
-
-        /* Read data: totalDataSize + 8(for checksum) */
-        len = getInt(buf, ++offset);
-        buf = new byte[len];
-        if (is.read(buf) != len) {
-            throw new MissingResourceException("Wrong data length",
-                                               datafile, "");
-        }
-
-        is.close();
-
-        return buf;
-    }
-
-    byte[] getAdditionalData() {
-        return additionalData;
-    }
-
-    void setAdditionalData(byte[] b) {
-        additionalData = b;
-    }
-
-    //=======================================================================
-    // boilerplate
-    //=======================================================================
-    /**
-     * Clones this iterator.
-     * @return A newly-constructed RuleBasedBreakIterator with the same
-     * behavior as this one.
-     */
-    @Override
-    public Object clone() {
-        RuleBasedBreakIterator result = (RuleBasedBreakIterator) super.clone();
-        if (text != null) {
-            result.text = (CharacterIterator) text.clone();
-        }
-        return result;
-    }
-
-    /**
-     * Returns true if both BreakIterators are of the same class, have the same
-     * rules, and iterate over the same text.
-     */
-    @Override
-    public boolean equals(Object that) {
-        try {
-            if (that == null) {
-                return false;
-            }
-
-            RuleBasedBreakIterator other = (RuleBasedBreakIterator) that;
-            if (checksum != other.checksum) {
-                return false;
-            }
-            if (text == null) {
-                return other.text == null;
-            } else {
-                return text.equals(other.text);
-            }
-        }
-        catch(ClassCastException e) {
-            return false;
-        }
-    }
-
-    /**
-     * Returns text
-     */
-    @Override
-    public String toString() {
-        return "[checksum=0x" + Long.toHexString(checksum) + ']';
-    }
-
-    /**
-     * Compute a hashcode for this BreakIterator
-     * @return A hash code
-     */
-    @Override
-    public int hashCode() {
-        return (int)checksum;
-    }
-
-    //=======================================================================
-    // BreakIterator overrides
-    //=======================================================================
-
-    /**
-     * Sets the current iteration position to the beginning of the text.
-     * (i.e., the CharacterIterator's starting offset).
-     * @return The offset of the beginning of the text.
-     */
-    @Override
-    public int first() {
-        CharacterIterator t = getText();
-
-        t.first();
-        return t.getIndex();
-    }
-
-    /**
-     * Sets the current iteration position to the end of the text.
-     * (i.e., the CharacterIterator's ending offset).
-     * @return The text's past-the-end offset.
-     */
-    @Override
-    public int last() {
-        CharacterIterator t = getText();
-
-        // I'm not sure why, but t.last() returns the offset of the last character,
-        // rather than the past-the-end offset
-        t.setIndex(t.getEndIndex());
-        return t.getIndex();
-    }
-
-    /**
-     * Advances the iterator either forward or backward the specified number of steps.
-     * Negative values move backward, and positive values move forward.  This is
-     * equivalent to repeatedly calling next() or previous().
-     * @param n The number of steps to move.  The sign indicates the direction
-     * (negative is backwards, and positive is forwards).
-     * @return The character offset of the boundary position n boundaries away from
-     * the current one.
-     */
-    @Override
-    public int next(int n) {
-        int result = current();
-        while (n > 0) {
-            result = handleNext();
-            --n;
-        }
-        while (n < 0) {
-            result = previous();
-            ++n;
-        }
-        return result;
-    }
-
-    /**
-     * Advances the iterator to the next boundary position.
-     * @return The position of the first boundary after this one.
-     */
-    @Override
-    public int next() {
-        return handleNext();
-    }
-
-    private int cachedLastKnownBreak = BreakIterator.DONE;
-
-    /**
-     * Advances the iterator backwards, to the last boundary preceding this one.
-     * @return The position of the last boundary position preceding this one.
-     */
-    @Override
-    public int previous() {
-        // if we're already sitting at the beginning of the text, return DONE
-        CharacterIterator text = getText();
-        if (current() == text.getBeginIndex()) {
-            return BreakIterator.DONE;
-        }
-
-        // set things up.  handlePrevious() will back us up to some valid
-        // break position before the current position (we back our internal
-        // iterator up one step to prevent handlePrevious() from returning
-        // the current position), but not necessarily the last one before
-        // where we started
-        int start = current();
-        int lastResult = cachedLastKnownBreak;
-        if (lastResult >= start || lastResult <= BreakIterator.DONE) {
-            getPrevious();
-            lastResult = handlePrevious();
-        } else {
-            //it might be better to check if handlePrevious() give us closer
-            //safe value but handlePrevious() is slow too
-            //So, this has to be done carefully
-            text.setIndex(lastResult);
-        }
-        int result = lastResult;
-
-        // iterate forward from the known break position until we pass our
-        // starting point.  The last break position before the starting
-        // point is our return value
-        while (result != BreakIterator.DONE && result < start) {
-            lastResult = result;
-            result = handleNext();
-        }
-
-        // set the current iteration position to be the last break position
-        // before where we started, and then return that value
-        text.setIndex(lastResult);
-        cachedLastKnownBreak = lastResult;
-        return lastResult;
-    }
-
-    /**
-     * Returns previous character
-     */
-    private int getPrevious() {
-        char c2 = text.previous();
-        if (Character.isLowSurrogate(c2) &&
-            text.getIndex() > text.getBeginIndex()) {
-            char c1 = text.previous();
-            if (Character.isHighSurrogate(c1)) {
-                return Character.toCodePoint(c1, c2);
-            } else {
-                text.next();
-            }
-        }
-        return (int)c2;
-    }
-
-    /**
-     * Returns current character
-     */
-    int getCurrent() {
-        char c1 = text.current();
-        if (Character.isHighSurrogate(c1) &&
-            text.getIndex() < text.getEndIndex()) {
-            char c2 = text.next();
-            text.previous();
-            if (Character.isLowSurrogate(c2)) {
-                return Character.toCodePoint(c1, c2);
-            }
-        }
-        return (int)c1;
-    }
-
-    /**
-     * Returns the count of next character.
-     */
-    private int getCurrentCodePointCount() {
-        char c1 = text.current();
-        if (Character.isHighSurrogate(c1) &&
-            text.getIndex() < text.getEndIndex()) {
-            char c2 = text.next();
-            text.previous();
-            if (Character.isLowSurrogate(c2)) {
-                return 2;
-            }
-        }
-        return 1;
-    }
-
-    /**
-     * Returns next character
-     */
-    int getNext() {
-        int index = text.getIndex();
-        int endIndex = text.getEndIndex();
-        if (index == endIndex ||
-            (index += getCurrentCodePointCount()) >= endIndex) {
-            return CharacterIterator.DONE;
-        }
-        text.setIndex(index);
-        return getCurrent();
-    }
-
-    /**
-     * Returns the position of next character.
-     */
-    private int getNextIndex() {
-        int index = text.getIndex() + getCurrentCodePointCount();
-        int endIndex = text.getEndIndex();
-        if (index > endIndex) {
-            return endIndex;
-        } else {
-            return index;
-        }
-    }
-
-    /**
-     * Throw IllegalArgumentException unless begin <= offset < end.
-     */
-    protected static final void checkOffset(int offset, CharacterIterator text) {
-        if (offset < text.getBeginIndex() || offset > text.getEndIndex()) {
-            throw new IllegalArgumentException("offset out of bounds");
-        }
-    }
-
-    /**
-     * Sets the iterator to refer to the first boundary position following
-     * the specified position.
-     * @offset The position from which to begin searching for a break position.
-     * @return The position of the first break after the current position.
-     */
-    @Override
-    public int following(int offset) {
-
-        CharacterIterator text = getText();
-        checkOffset(offset, text);
-
-        // Set our internal iteration position (temporarily)
-        // to the position passed in.  If this is the _beginning_ position,
-        // then we can just use next() to get our return value
-        text.setIndex(offset);
-        if (offset == text.getBeginIndex()) {
-            cachedLastKnownBreak = handleNext();
-            return cachedLastKnownBreak;
-        }
-
-        // otherwise, we have to sync up first.  Use handlePrevious() to back
-        // us up to a known break position before the specified position (if
-        // we can determine that the specified position is a break position,
-        // we don't back up at all).  This may or may not be the last break
-        // position at or before our starting position.  Advance forward
-        // from here until we've passed the starting position.  The position
-        // we stop on will be the first break position after the specified one.
-        int result = cachedLastKnownBreak;
-        if (result >= offset || result <= BreakIterator.DONE) {
-            result = handlePrevious();
-        } else {
-            //it might be better to check if handlePrevious() give us closer
-            //safe value but handlePrevious() is slow too
-            //So, this has to be done carefully
-            text.setIndex(result);
-        }
-        while (result != BreakIterator.DONE && result <= offset) {
-            result = handleNext();
-        }
-        cachedLastKnownBreak = result;
-        return result;
-    }
-
-    /**
-     * Sets the iterator to refer to the last boundary position before the
-     * specified position.
-     * @offset The position to begin searching for a break from.
-     * @return The position of the last boundary before the starting position.
-     */
-    @Override
-    public int preceding(int offset) {
-        // if we start by updating the current iteration position to the
-        // position specified by the caller, we can just use previous()
-        // to carry out this operation
-        CharacterIterator text = getText();
-        checkOffset(offset, text);
-        text.setIndex(offset);
-        return previous();
-    }
-
-    /**
-     * Returns true if the specified position is a boundary position.  As a side
-     * effect, leaves the iterator pointing to the first boundary position at
-     * or after "offset".
-     * @param offset the offset to check.
-     * @return True if "offset" is a boundary position.
-     */
-    @Override
-    public boolean isBoundary(int offset) {
-        CharacterIterator text = getText();
-        checkOffset(offset, text);
-        if (offset == text.getBeginIndex()) {
-            return true;
-        }
-
-        // to check whether this is a boundary, we can use following() on the
-        // position before the specified one and return true if the position we
-        // get back is the one the user specified
-        else {
-            return following(offset - 1) == offset;
-        }
-    }
-
-    /**
-     * Returns the current iteration position.
-     * @return The current iteration position.
-     */
-    @Override
-    public int current() {
-        return getText().getIndex();
-    }
-
-    /**
-     * Return a CharacterIterator over the text being analyzed.  This version
-     * of this method returns the actual CharacterIterator we're using internally.
-     * Changing the state of this iterator can have undefined consequences.  If
-     * you need to change it, clone it first.
-     * @return An iterator over the text being analyzed.
-     */
-    @Override
-    public CharacterIterator getText() {
-        // The iterator is initialized pointing to no text at all, so if this
-        // function is called while we're in that state, we have to fudge an
-        // iterator to return.
-        if (text == null) {
-            text = new StringCharacterIterator("");
-        }
-        return text;
-    }
-
-    /**
-     * Set the iterator to analyze a new piece of text.  This function resets
-     * the current iteration position to the beginning of the text.
-     * @param newText An iterator over the text to analyze.
-     */
-    @Override
-    public void setText(CharacterIterator newText) {
-        // Test iterator to see if we need to wrap it in a SafeCharIterator.
-        // The correct behavior for CharacterIterators is to allow the
-        // position to be set to the endpoint of the iterator.  Many
-        // CharacterIterators do not uphold this, so this is a workaround
-        // to permit them to use this class.
-        int end = newText.getEndIndex();
-        boolean goodIterator;
-        try {
-            newText.setIndex(end);  // some buggy iterators throw an exception here
-            goodIterator = newText.getIndex() == end;
-        }
-        catch(IllegalArgumentException e) {
-            goodIterator = false;
-        }
-
-        if (goodIterator) {
-            text = newText;
-        }
-        else {
-            text = new SafeCharIterator(newText);
-        }
-        text.first();
-
-        cachedLastKnownBreak = BreakIterator.DONE;
-    }
-
-
-    //=======================================================================
-    // implementation
-    //=======================================================================
-
-    /**
-     * This method is the actual implementation of the next() method.  All iteration
-     * vectors through here.  This method initializes the state machine to state 1
-     * and advances through the text character by character until we reach the end
-     * of the text or the state machine transitions to state 0.  We update our return
-     * value every time the state machine passes through a possible end state.
-     */
-    protected int handleNext() {
-        // if we're already at the end of the text, return DONE.
-        CharacterIterator text = getText();
-        if (text.getIndex() == text.getEndIndex()) {
-            return BreakIterator.DONE;
-        }
-
-        // no matter what, we always advance at least one character forward
-        int result = getNextIndex();
-        int lookaheadResult = 0;
-
-        // begin in state 1
-        int state = START_STATE;
-        int category;
-        int c = getCurrent();
-
-        // loop until we reach the end of the text or transition to state 0
-        while (c != CharacterIterator.DONE && state != STOP_STATE) {
-
-            // look up the current character's character category (which tells us
-            // which column in the state table to look at)
-            category = lookupCategory(c);
-
-            // if the character isn't an ignore character, look up a state
-            // transition in the state table
-            if (category != IGNORE) {
-                state = lookupState(state, category);
-            }
-
-            // if the state we've just transitioned to is a lookahead state,
-            // (but not also an end state), save its position.  If it's
-            // both a lookahead state and an end state, update the break position
-            // to the last saved lookup-state position
-            if (lookaheadStates[state]) {
-                if (endStates[state]) {
-                    result = lookaheadResult;
-                }
-                else {
-                    lookaheadResult = getNextIndex();
-                }
-            }
-
-            // otherwise, if the state we've just transitioned to is an accepting
-            // state, update the break position to be the current iteration position
-            else {
-                if (endStates[state]) {
-                    result = getNextIndex();
-                }
-            }
-
-            c = getNext();
-        }
-
-        // if we've run off the end of the text, and the very last character took us into
-        // a lookahead state, advance the break position to the lookahead position
-        // (the theory here is that if there are no characters at all after the lookahead
-        // position, that always matches the lookahead criteria)
-        if (c == CharacterIterator.DONE && lookaheadResult == text.getEndIndex()) {
-            result = lookaheadResult;
-        }
-
-        text.setIndex(result);
-        return result;
-    }
-
-    /**
-     * This method backs the iterator back up to a "safe position" in the text.
-     * This is a position that we know, without any context, must be a break position.
-     * The various calling methods then iterate forward from this safe position to
-     * the appropriate position to return.  (For more information, see the description
-     * of buildBackwardsStateTable() in RuleBasedBreakIterator.Builder.)
-     */
-    protected int handlePrevious() {
-        CharacterIterator text = getText();
-        int state = START_STATE;
-        int category = 0;
-        int lastCategory = 0;
-        int c = getCurrent();
-
-        // loop until we reach the beginning of the text or transition to state 0
-        while (c != CharacterIterator.DONE && state != STOP_STATE) {
-
-            // save the last character's category and look up the current
-            // character's category
-            lastCategory = category;
-            category = lookupCategory(c);
-
-            // if the current character isn't an ignore character, look up a
-            // state transition in the backwards state table
-            if (category != IGNORE) {
-                state = lookupBackwardState(state, category);
-            }
-
-            // then advance one character backwards
-            c = getPrevious();
-        }
-
-        // if we didn't march off the beginning of the text, we're either one or two
-        // positions away from the real break position.  (One because of the call to
-        // previous() at the end of the loop above, and another because the character
-        // that takes us into the stop state will always be the character BEFORE
-        // the break position.)
-        if (c != CharacterIterator.DONE) {
-            if (lastCategory != IGNORE) {
-                getNext();
-                getNext();
-            }
-            else {
-                getNext();
-            }
-        }
-        return text.getIndex();
-    }
-
-    /**
-     * Looks up a character's category (i.e., its category for breaking purposes,
-     * not its Unicode category)
-     */
-    protected int lookupCategory(int c) {
-        if (c < Character.MIN_SUPPLEMENTARY_CODE_POINT) {
-            return charCategoryTable.elementAt((char)c);
-        } else {
-            return supplementaryCharCategoryTable.getValue(c);
-        }
-    }
-
-    /**
-     * Given a current state and a character category, looks up the
-     * next state to transition to in the state table.
-     */
-    protected int lookupState(int state, int category) {
-        return stateTable[state * numCategories + category];
-    }
-
-    /**
-     * Given a current state and a character category, looks up the
-     * next state to transition to in the backwards state table.
-     */
-    protected int lookupBackwardState(int state, int category) {
-        return backwardsStateTable[state * numCategories + category];
-    }
-
-    static long getLong(byte[] buf, int offset) {
-        long num = buf[offset]&0xFF;
-        for (int i = 1; i < 8; i++) {
-            num = num<<8 | (buf[offset+i]&0xFF);
-        }
-        return num;
-    }
-
-    static int getInt(byte[] buf, int offset) {
-        int num = buf[offset]&0xFF;
-        for (int i = 1; i < 4; i++) {
-            num = num<<8 | (buf[offset+i]&0xFF);
-        }
-        return num;
-    }
-
-    static short getShort(byte[] buf, int offset) {
-        short num = (short)(buf[offset]&0xFF);
-        num = (short)(num<<8 | (buf[offset+1]&0xFF));
-        return num;
-    }
-
-    /*
-     * This class exists to work around a bug in incorrect implementations
-     * of CharacterIterator, which incorrectly handle setIndex(endIndex).
-     * This iterator relies only on base.setIndex(n) where n is less than
-     * endIndex.
-     *
-     * One caveat:  if the base iterator's begin and end indices change
-     * the change will not be reflected by this wrapper.  Does that matter?
-     */
-    // TODO: Review this class to see if it's still required.
-    private static final class SafeCharIterator implements CharacterIterator,
-                                                           Cloneable {
-
-        private CharacterIterator base;
-        private int rangeStart;
-        private int rangeLimit;
-        private int currentIndex;
-
-        SafeCharIterator(CharacterIterator base) {
-            this.base = base;
-            this.rangeStart = base.getBeginIndex();
-            this.rangeLimit = base.getEndIndex();
-            this.currentIndex = base.getIndex();
-        }
-
-        @Override
-        public char first() {
-            return setIndex(rangeStart);
-        }
-
-        @Override
-        public char last() {
-            return setIndex(rangeLimit - 1);
-        }
-
-        @Override
-        public char current() {
-            if (currentIndex < rangeStart || currentIndex >= rangeLimit) {
-                return DONE;
-            }
-            else {
-                return base.setIndex(currentIndex);
-            }
-        }
-
-        @Override
-        public char next() {
-
-            currentIndex++;
-            if (currentIndex >= rangeLimit) {
-                currentIndex = rangeLimit;
-                return DONE;
-            }
-            else {
-                return base.setIndex(currentIndex);
-            }
-        }
-
-        @Override
-        public char previous() {
-
-            currentIndex--;
-            if (currentIndex < rangeStart) {
-                currentIndex = rangeStart;
-                return DONE;
-            }
-            else {
-                return base.setIndex(currentIndex);
-            }
-        }
-
-        @Override
-        public char setIndex(int i) {
-
-            if (i < rangeStart || i > rangeLimit) {
-                throw new IllegalArgumentException("Invalid position");
-            }
-            currentIndex = i;
-            return current();
-        }
-
-        @Override
-        public int getBeginIndex() {
-            return rangeStart;
-        }
-
-        @Override
-        public int getEndIndex() {
-            return rangeLimit;
-        }
-
-        @Override
-        public int getIndex() {
-            return currentIndex;
-        }
-
-        @Override
-        public Object clone() {
-
-            SafeCharIterator copy = null;
-            try {
-                copy = (SafeCharIterator) super.clone();
-            }
-            catch(CloneNotSupportedException e) {
-                throw new Error("Clone not supported: " + e);
-            }
-
-            CharacterIterator copyOfBase = (CharacterIterator) base.clone();
-            copy.base = copyOfBase;
-            return copy;
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/sun/util/resources/BreakIteratorResourceBundle.java	Thu Oct 27 09:42:08 2016 -0700
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.util.resources;
+
+import java.io.InputStream;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+/**
+ * BreakIteratorResourceBundle is an abstract class for loading BreakIterator
+ * data (rules or dictionary) from each module. An implementation class must
+ * implement getBreakIteratorInfo() that returns an instance of the
+ * corresponding BreakIteratorInfo (basename).  The data name is taken from the
+ * BreakIteratorInfo instance.
+ *
+ * <p>For example, if the given key is "WordDictionary" and Locale is "th", the
+ * data name is taken from a BreakIteratorInfo_th and the key's value is
+ * "thai_dict".  Its data thai_dict is loaded from the Module of the
+ * implementation class of this class.
+ */
+
+public abstract class BreakIteratorResourceBundle extends ResourceBundle {
+    // If any keys that are not for data names are added to BreakIteratorInfo*,
+    // those keys must be added to NON_DATA_KEYS.
+    private static final Set<String> NON_DATA_KEYS = Set.of("BreakIteratorClasses");
+
+    private volatile Set<String> keys;
+
+    /**
+     * Returns an instance of the corresponding {@code BreakIteratorInfo} (basename).
+     * The instance shouldn't have its parent.
+     */
+    protected abstract ResourceBundle getBreakIteratorInfo();
+
+    @Override
+    protected Object handleGetObject(String key) {
+        if (NON_DATA_KEYS.contains(key)) {
+            return null;
+        }
+        ResourceBundle info = getBreakIteratorInfo();
+        if (!info.containsKey(key)) {
+            return null;
+        }
+        String path = getClass().getPackage().getName().replace('.', '/')
+                      + '/' + info.getString(key);
+        byte[] data;
+        try (InputStream is = getResourceAsStream(path)) {
+            data = is.readAllBytes();
+        } catch (Exception e) {
+            throw new InternalError("Can't load " + path, e);
+        }
+        return data;
+    }
+
+    private InputStream getResourceAsStream(String path) throws Exception {
+        PrivilegedExceptionAction<InputStream> pa;
+        pa = () -> getClass().getModule().getResourceAsStream(path);
+        InputStream is;
+        try {
+            is = AccessController.doPrivileged(pa);
+        } catch (PrivilegedActionException e) {
+            throw e.getException();
+        }
+        return is;
+    }
+
+    @Override
+    public Enumeration<String> getKeys() {
+        return Collections.enumeration(keySet());
+    }
+
+    @Override
+    protected Set<String> handleKeySet() {
+        if (keys == null) {
+            ResourceBundle info = getBreakIteratorInfo();
+            Set<String> k = info.keySet();
+            k.removeAll(NON_DATA_KEYS);
+            synchronized (this) {
+                if (keys == null) {
+                    keys = k;
+                }
+            }
+        }
+        return keys;
+    }
+}
--- a/src/java.base/share/classes/sun/util/resources/LocaleData.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/classes/sun/util/resources/LocaleData.java	Thu Oct 27 09:42:08 2016 -0700
@@ -123,6 +123,14 @@
     }
 
     /**
+     * Gets a break iterator resources resource bundle, using
+     * privileges to allow accessing a sun.* package.
+     */
+    public ResourceBundle getBreakIteratorResources(Locale locale) {
+        return getBundle(type.getTextResourcesPackage() + ".BreakIteratorResources", locale);
+    }
+
+    /**
      * Gets a collation data resource bundle, using privileges
      * to allow accessing a sun.* package.
      */
--- a/src/java.base/share/conf/security/java.security	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/conf/security/java.security	Thu Oct 27 09:42:08 2016 -0700
@@ -655,6 +655,44 @@
 jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & denyAfter 2017-01-01, \
     RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224
 
+# Algorithm restrictions for signed JAR files
+#
+# In some environments, certain algorithms or key lengths may be undesirable
+# for signed JAR validation.  For example, "MD2" is generally no longer
+# considered to be a secure hash algorithm.  This section describes the
+# mechanism for disabling algorithms based on algorithm name and/or key length.
+# JARs signed with any of the disabled algorithms or key sizes will be treated
+# as unsigned.
+#
+# The syntax of the disabled algorithm string is described as follows:
+#   DisabledAlgorithms:
+#       " DisabledAlgorithm { , DisabledAlgorithm } "
+#
+#   DisabledAlgorithm:
+#       AlgorithmName [Constraint]
+#
+#   AlgorithmName:
+#       (see below)
+#
+#   Constraint:
+#       KeySizeConstraint
+#
+#   KeySizeConstraint:
+#       keySize Operator KeyLength
+#
+#   Operator:
+#       <= | < | == | != | >= | >
+#
+#   KeyLength:
+#       Integer value of the algorithm's key length in bits
+#
+# Note: This property is currently used by the JDK Reference
+# implementation. It is not guaranteed to be examined and used by other
+# implementations.
+#
+jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, \
+      DSA keySize < 1024
+
 # Algorithm restrictions for Secure Socket Layer/Transport Layer Security
 # (SSL/TLS/DTLS) processing
 #
@@ -936,41 +974,3 @@
 #
 #jdk.serialFilter=pattern;pattern
 
-# Algorithm restrictions for signed JAR files
-#
-# In some environments, certain algorithms or key lengths may be undesirable
-# for signed JAR validation.  For example, "MD2" is generally no longer
-# considered to be a secure hash algorithm.  This section describes the
-# mechanism for disabling algorithms based on algorithm name and/or key length.
-# JARs signed with any of the disabled algorithms or key sizes will be treated
-# as unsigned.
-#
-# The syntax of the disabled algorithm string is described as follows:
-#   DisabledAlgorithms:
-#       " DisabledAlgorithm { , DisabledAlgorithm } "
-#
-#   DisabledAlgorithm:
-#       AlgorithmName [Constraint]
-#
-#   AlgorithmName:
-#       (see below)
-#
-#   Constraint:
-#       KeySizeConstraint
-#
-#   KeySizeConstraint:
-#       keySize Operator KeyLength
-#
-#   Operator:
-#       <= | < | == | != | >= | >
-#
-#   KeyLength:
-#       Integer value of the algorithm's key length in bits
-#
-# Note: This property is currently used by the JDK Reference
-# implementation. It is not guaranteed to be examined and used by other
-# implementations.
-#
-jdk.jar.disabledAlgorithms=MD2, RSA keySize < 1024, \
-      DSA keySize < 1024
-
--- a/src/java.base/share/lib/security/default.policy	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/lib/security/default.policy	Thu Oct 27 09:42:08 2016 -0700
@@ -111,11 +111,11 @@
 grant codeBase "jrt:/jdk.crypto.pkcs11" {
     permission java.lang.RuntimePermission
                    "accessClassInPackage.sun.security.*";
-    permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
     permission java.lang.RuntimePermission "loadLibrary.j2pkcs11";
-    // needs "security.pkcs11.allowSingleThreadedModules"
-    permission java.util.PropertyPermission "*", "read";
+    permission java.util.PropertyPermission "sun.security.pkcs11.allowSingleThreadedModules", "read";
+    permission java.util.PropertyPermission "os.name", "read";
+    permission java.util.PropertyPermission "os.arch", "read";
     permission java.security.SecurityPermission "putProviderProperty.*";
     permission java.security.SecurityPermission "clearProviderProperties.*";
     permission java.security.SecurityPermission "removeProviderProperty.*";
--- a/src/java.base/share/native/libnet/net_util.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/native/libnet/net_util.c	Thu Oct 27 09:42:08 2016 -0700
@@ -23,20 +23,19 @@
  * questions.
  */
 
-#include "jni.h"
-#include "jvm.h"
-#include "jni_util.h"
 #include "net_util.h"
 
-int IPv6_supported() ;
-int reuseport_supported() ;
+#include "java_net_InetAddress.h"
+
+int IPv6_supported();
+int reuseport_supported();
 
 static int IPv6_available;
 static int REUSEPORT_available;
 
 JNIEXPORT jint JNICALL ipv6_available()
 {
-    return IPv6_available ;
+    return IPv6_available;
 }
 
 JNIEXPORT jint JNICALL reuseport_available()
@@ -206,11 +205,7 @@
     jobject iaObj;
 #ifdef AF_INET6
     if (him->sa_family == AF_INET6) {
-#ifdef WIN32
-        struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
-#else
         struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
-#endif
         jbyte *caddr = (jbyte *)&(him6->sin6_addr);
         if (NET_IsIPv4Mapped(caddr)) {
             int address;
@@ -218,7 +213,7 @@
             CHECK_NULL_RETURN(iaObj, NULL);
             address = NET_IPv4MappedToIPv4(caddr);
             setInetAddress_addr(env, iaObj, address);
-            setInetAddress_family(env, iaObj, IPv4);
+            setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4);
         } else {
             jint scope;
             jboolean ret;
@@ -227,7 +222,7 @@
             ret = setInet6Address_ipaddress(env, iaObj, (char *)&(him6->sin6_addr));
             if (ret == JNI_FALSE)
                 return NULL;
-            setInetAddress_family(env, iaObj, IPv6);
+            setInetAddress_family(env, iaObj, java_net_InetAddress_IPv6);
             scope = getScopeID(him);
             setInet6Address_scopeid(env, iaObj, scope);
         }
@@ -238,7 +233,7 @@
             struct sockaddr_in *him4 = (struct sockaddr_in *)him;
             iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
             CHECK_NULL_RETURN(iaObj, NULL);
-            setInetAddress_family(env, iaObj, IPv4);
+            setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4);
             setInetAddress_addr(env, iaObj, ntohl(him4->sin_addr.s_addr));
             *port = ntohs(him4->sin_port);
         }
@@ -251,13 +246,10 @@
     jint family = AF_INET;
 
 #ifdef AF_INET6
-    family = getInetAddress_family(env, iaObj) == IPv4? AF_INET : AF_INET6;
+    family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
+        AF_INET : AF_INET6;
     if (him->sa_family == AF_INET6) {
-#ifdef WIN32
-        struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
-#else
         struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
-#endif
         jbyte *caddrNew = (jbyte *)&(him6->sin6_addr);
         if (NET_IsIPv4Mapped(caddrNew)) {
             int addrNew;
--- a/src/java.base/share/native/libnet/net_util.h	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/share/native/libnet/net_util.h	Thu Oct 27 09:42:08 2016 -0700
@@ -36,12 +36,6 @@
 
 #define MAX_PACKET_LEN 65536
 
-#define IPv4 1
-#define IPv6 2
-
-#define NET_ERROR(env, ex, msg) \
-{ if (!(*env)->ExceptionOccurred(env)) JNU_ThrowByName(env, ex, msg); }
-
 #define NET_WAIT_READ    0x01
 #define NET_WAIT_WRITE   0x02
 #define NET_WAIT_CONNECT 0x04
@@ -127,45 +121,43 @@
 JNIEXPORT void JNICALL Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls);
 
 JNIEXPORT void JNICALL NET_ThrowNew(JNIEnv *env, int errorNum, char *msg);
+
 int NET_GetError();
 
 void NET_ThrowCurrent(JNIEnv *env, char *msg);
 
 jfieldID NET_GetFileDescriptorID(JNIEnv *env);
 
-JNIEXPORT jint JNICALL ipv6_available() ;
+JNIEXPORT jint JNICALL ipv6_available();
 
-JNIEXPORT jint JNICALL reuseport_available() ;
+JNIEXPORT jint JNICALL reuseport_available();
 
 JNIEXPORT int JNICALL
-NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr *him, int *len, jboolean v4MappedAddress);
+NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port,
+                          struct sockaddr *him, int *len,
+                          jboolean v4MappedAddress);
 
 JNIEXPORT jobject JNICALL
 NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port);
 
 void platformInit();
+
 void parseExclusiveBindProperty(JNIEnv *env);
 
-void
-NET_SetTrafficClass(struct sockaddr *him, int trafficClass);
+void NET_SetTrafficClass(struct sockaddr *him, int trafficClass);
 
-JNIEXPORT jint JNICALL
-NET_GetPortFromSockaddr(struct sockaddr *him);
+JNIEXPORT jint JNICALL NET_GetPortFromSockaddr(struct sockaddr *him);
 
 JNIEXPORT jint JNICALL
 NET_SockaddrEqualsInetAddress(JNIEnv *env,struct sockaddr *him, jobject iaObj);
 
-int
-NET_IsIPv4Mapped(jbyte* caddr);
+int NET_IsIPv4Mapped(jbyte* caddr);
 
-int
-NET_IPv4MappedToIPv4(jbyte* caddr);
+int NET_IPv4MappedToIPv4(jbyte* caddr);
 
-int
-NET_IsEqual(jbyte* caddr1, jbyte* caddr2);
+int NET_IsEqual(jbyte* caddr1, jbyte* caddr2);
 
-int
-NET_IsZeroAddr(jbyte* caddr);
+int NET_IsZeroAddr(jbyte* caddr);
 
 /* Socket operations
  *
@@ -191,9 +183,9 @@
 JNIEXPORT jint JNICALL
 NET_EnableFastTcpLoopback(int fd);
 
-int getScopeID (struct sockaddr *);
+int getScopeID(struct sockaddr *);
 
-int cmpScopeID (unsigned int, struct sockaddr *);
+int cmpScopeID(unsigned int, struct sockaddr *);
 
 unsigned short in_cksum(unsigned short *addr, int len);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/unix/conf/s390x/jvm.cfg	Thu Oct 27 09:42:08 2016 -0700
@@ -0,0 +1,34 @@
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+# List of JVMs that can be used as an option to java, javac, etc.
+# Order is important -- first in this list is the default JVM.
+# NOTE that this both this file and its format are UNSUPPORTED and
+# WILL GO AWAY in a future release.
+#
+# You may also select a JVM in an arbitrary location with the
+# "-XXaltjvm=<jvm_dir>" option, but that too is unsupported
+# and may not be available in a future release.
+#
+-server KNOWN
+-client IGNORE
--- a/src/java.base/unix/native/libnet/Inet4AddressImpl.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/unix/native/libnet/Inet4AddressImpl.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,27 +22,17 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
+#include <ctype.h>
 #include <errno.h>
-#include <sys/time.h>
 #include <sys/types.h>
-#include <sys/socket.h>
+#include <netinet/in.h>
 #include <netinet/in_systm.h>
-#include <netinet/in.h>
 #include <netinet/ip.h>
 #include <netinet/ip_icmp.h>
-#include <netdb.h>
+#include <stdlib.h>
 #include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
+#include <sys/time.h>
 
-#ifdef _ALLBSD_SOURCE
-#include <unistd.h>
-#include <sys/param.h>
-#endif
-
-#include "jvm.h"
-#include "jni_util.h"
 #include "net_util.h"
 
 #include "java_net_Inet4AddressImpl.h"
@@ -293,13 +283,12 @@
     addr |= ((caddr[2] <<8) & 0xff00);
     addr |= (caddr[3] & 0xff);
     memset((char *) &him4, 0, sizeof(him4));
-    him4.sin_addr.s_addr = (uint32_t) htonl(addr);
+    him4.sin_addr.s_addr = htonl(addr);
     him4.sin_family = AF_INET;
     sa = (struct sockaddr *) &him4;
     len = sizeof(him4);
 
-    error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0,
-                               NI_NAMEREQD);
+    error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
 
     if (!error) {
         ret = (*env)->NewStringUTF(env, host);
@@ -443,7 +432,7 @@
 
             if (!skip) {
                 struct addrinfo *next
-                    = (struct addrinfo*) malloc(sizeof(struct addrinfo));
+                    = (struct addrinfo *)malloc(sizeof(struct addrinfo));
                 if (!next) {
                     JNU_ThrowOutOfMemoryError(env, "Native heap allocation failed");
                     ret = NULL;
@@ -528,13 +517,12 @@
     addr |= ((caddr[2] <<8) & 0xff00);
     addr |= (caddr[3] & 0xff);
     memset((void *) &him4, 0, sizeof(him4));
-    him4.sin_addr.s_addr = (uint32_t) htonl(addr);
+    him4.sin_addr.s_addr = htonl(addr);
     him4.sin_family = AF_INET;
     sa = (struct sockaddr *) &him4;
     len = sizeof(him4);
 
-    error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0,
-                        NI_NAMEREQD);
+    error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
 
     if (!error) {
         ret = (*env)->NewStringUTF(env, host);
--- a/src/java.base/unix/native/libnet/Inet6AddressImpl.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/unix/native/libnet/Inet6AddressImpl.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,29 +22,21 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
+#include <ctype.h>
 #include <errno.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/time.h>
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <netinet/in.h>
-#include <netdb.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <ctype.h>
-#ifdef MACOSX
+#include <netinet/icmp6.h>
+
+#if defined(_ALLBSD_SOURCE)
 #include <ifaddrs.h>
 #include <net/if.h>
-#include <unistd.h> /* gethostname */
 #endif
 
-#include "jvm.h"
-#include "jni_util.h"
 #include "net_util.h"
-#ifndef IPV6_DEFS_H
-#include <netinet/icmp6.h>
-#endif
 
 #include "java_net_Inet4AddressImpl.h"
 #include "java_net_Inet6AddressImpl.h"
@@ -504,24 +496,23 @@
         addr |= ((caddr[2] <<8) & 0xff00);
         addr |= (caddr[3] & 0xff);
         memset((void *) &him4, 0, sizeof(him4));
-        him4.sin_addr.s_addr = (uint32_t) htonl(addr);
+        him4.sin_addr.s_addr = htonl(addr);
         him4.sin_family = AF_INET;
-        sa = (struct sockaddr *) &him4;
+        sa = (struct sockaddr *)&him4;
         len = sizeof(him4);
     } else {
         /*
          * For IPv6 address construct a sockaddr_in6 structure.
          */
         (*env)->GetByteArrayRegion(env, addrArray, 0, 16, caddr);
-        memset((void *) &him6, 0, sizeof(him6));
-        memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr) );
+        memset((void *)&him6, 0, sizeof(him6));
+        memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr));
         him6.sin6_family = AF_INET6;
-        sa = (struct sockaddr *) &him6 ;
-        len = sizeof(him6) ;
+        sa = (struct sockaddr *)&him6;
+        len = sizeof(him6);
     }
 
-    error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0,
-                        NI_NAMEREQD);
+    error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
 
     if (!error) {
         ret = (*env)->NewStringUTF(env, host);
--- a/src/java.base/unix/native/libnet/NetworkInterface.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/unix/native/libnet/NetworkInterface.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,55 +22,36 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
+#include <arpa/inet.h>
 #include <errno.h>
-#include <strings.h>
-#include <netinet/in.h>
+#include <net/if.h>
+#include <net/if_arp.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <net/if_arp.h>
-
-#if defined(__solaris__)
-#include <sys/dlpi.h>
-#include <fcntl.h>
-#include <stropts.h>
-#include <sys/sockio.h>
-#endif
-
-#if defined(__linux__)
 #include <sys/ioctl.h>
-#include <sys/utsname.h>
-#include <stdio.h>
-#endif
 
 #if defined(_AIX)
-#include <sys/ioctl.h>
 #include <netinet/in6_var.h>
 #include <sys/ndd_var.h>
 #include <sys/kinfo.h>
 #endif
 
+#if defined(__solaris__)
+#include <stropts.h>
+#include <sys/dlpi.h>
+#include <sys/sockio.h>
+#endif
+
 #if defined(_ALLBSD_SOURCE)
-#include <sys/param.h>
-#include <sys/ioctl.h>
-#include <sys/sockio.h>
-#if defined(__APPLE__)
 #include <net/ethernet.h>
-#include <net/if_var.h>
 #include <net/if_dl.h>
-#include <netinet/in_var.h>
 #include <ifaddrs.h>
 #endif
-#endif
 
-#include "jvm.h"
-#include "jni_util.h"
 #include "net_util.h"
 
+#include "java_net_InetAddress.h"
+
 #if defined(__linux__)
     #define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
 #elif defined(__solaris__)
@@ -332,7 +313,7 @@
 {
     netif *ifs, *curr;
 #if defined(AF_INET6)
-    int family = (getInetAddress_family(env, iaObj) == IPv4) ? AF_INET : AF_INET6;
+    int family = (getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4) ? AF_INET : AF_INET6;
 #else
     int family =  AF_INET;
 #endif
--- a/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,29 +22,23 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 #include <errno.h>
-#include <netinet/in.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+#include <sys/ioctl.h>
 
-#ifdef __solaris__
-#include <fcntl.h>
-#include <unistd.h>
-#include <stropts.h>
+#if defined(__solaris__)
+#include <sys/filio.h>
+#endif
 
-#ifndef BSD_COMP
-#define BSD_COMP
-#endif
-#endif
+#include "net_util.h"
+
+#include "java_net_PlainDatagramSocketImpl.h"
+#include "java_net_InetAddress.h"
+#include "java_net_NetworkInterface.h"
+#include "java_net_SocketOptions.h"
+
 #ifdef __linux__
-#include <unistd.h>
-#include <sys/sysctl.h>
-#include <sys/utsname.h>
-#include <netinet/ip.h>
-
 #define IPV6_MULTICAST_IF 17
 #ifndef SO_BSDCOMPAT
 #define SO_BSDCOMPAT  14
@@ -58,7 +52,11 @@
 #endif
 #endif  //  __linux__
 
-#include <sys/ioctl.h>
+#ifdef __solaris__
+#ifndef BSD_COMP
+#define BSD_COMP
+#endif
+#endif
 
 #ifndef IPTOS_TOS_MASK
 #define IPTOS_TOS_MASK 0x1e
@@ -67,12 +65,6 @@
 #define IPTOS_PREC_MASK 0xe0
 #endif
 
-#include "jvm.h"
-#include "jni_util.h"
-#include "net_util.h"
-#include "java_net_SocketOptions.h"
-#include "java_net_PlainDatagramSocketImpl.h"
-#include "java_net_NetworkInterface.h"
 /************************************************************************
  * PlainDatagramSocketImpl
  */
@@ -151,9 +143,6 @@
 JNIEXPORT void JNICALL
 Java_java_net_PlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) {
 
-#ifdef __linux__
-    struct utsname sysinfo;
-#endif
     pdsi_fdID = (*env)->GetFieldID(env, cls, "fd",
                                    "Ljava/io/FileDescriptor;");
     CHECK_NULL(pdsi_fdID);
@@ -550,7 +539,8 @@
 
     iaObj = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &port);
 #ifdef AF_INET6
-    family = getInetAddress_family(env, iaObj) == IPv4? AF_INET : AF_INET6;
+    family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
+        AF_INET : AF_INET6;
 #else
     family = AF_INET;
 #endif
@@ -1071,7 +1061,7 @@
      */
     for (i = 0; i < len; i++) {
         addr = (*env)->GetObjectArrayElement(env, addrArray, i);
-        if (getInetAddress_family(env, addr) == IPv4) {
+        if (getInetAddress_family(env, addr) == java_net_InetAddress_IPv4) {
             in.s_addr = htonl(getInetAddress_addr(env, addr));
             break;
         }
@@ -1970,7 +1960,7 @@
     ipv6_join_leave = ipv6_available();
 
 #ifdef __linux__
-    if (getInetAddress_family(env, iaObj) == IPv4) {
+    if (getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4) {
         ipv6_join_leave = JNI_FALSE;
     }
 #endif
@@ -2162,7 +2152,8 @@
         jbyte caddr[16];
         jint family;
         jint address;
-        family = getInetAddress_family(env, iaObj) == IPv4? AF_INET : AF_INET6;
+        family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
+            AF_INET : AF_INET6;
         if (family == AF_INET) { /* will convert to IPv4-mapped address */
             memset((char *) caddr, 0, 16);
             address = getInetAddress_addr(env, iaObj);
--- a/src/java.base/unix/native/libnet/PlainSocketImpl.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/unix/native/libnet/PlainSocketImpl.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,32 +22,8 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+#include <errno.h>
 
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#if defined(__linux__)
-#include <sys/poll.h>
-#endif
-#include <netinet/tcp.h>        /* Defines TCP_NODELAY, needed for 2.6 */
-#include <netinet/in.h>
-#ifdef __linux__
-#include <netinet/ip.h>
-#endif
-#include <netdb.h>
-#include <stdlib.h>
-
-#ifdef __solaris__
-#include <fcntl.h>
-#endif
-#ifdef __linux__
-#include <unistd.h>
-#include <sys/sysctl.h>
-#endif
-
-#include "jvm.h"
-#include "jni_util.h"
 #include "net_util.h"
 
 #include "java_net_SocketOptions.h"
--- a/src/java.base/unix/native/libnet/SocketInputStream.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/unix/native/libnet/SocketInputStream.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,20 +22,15 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
 
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include "jvm.h"
-#include "jni_util.h"
 #include "net_util.h"
 
 #include "java_net_SocketInputStream.h"
 
-/************************************************************************
+/*
  * SocketInputStream
  */
 
--- a/src/java.base/unix/native/libnet/SocketOutputStream.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/unix/native/libnet/SocketOutputStream.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,15 +22,10 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
 
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include "jni_util.h"
-#include "jvm.h"
 #include "net_util.h"
 
 #include "java_net_SocketOutputStream.h"
--- a/src/java.base/unix/native/libnet/net_util_md.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/unix/native/libnet/net_util_md.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,60 +22,42 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
+#include <dlfcn.h>
 #include <errno.h>
+#include <net/if.h>
+#include <netinet/tcp.h> // defines TCP_NODELAY
+#include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/tcp.h>        /* Defines TCP_NODELAY, needed for 2.6 */
-#include <netinet/in.h>
-#include <net/if.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <dlfcn.h>
+#include <sys/ioctl.h>
 #include <sys/time.h>
 
-#ifndef _ALLBSD_SOURCE
-#include <values.h>
-#else
-#include <limits.h>
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <sys/ioctl.h>
-#ifndef MAXINT
-#define MAXINT INT_MAX
-#endif
-#endif
-
-#ifdef __solaris__
-#include <sys/filio.h>
-#include <sys/sockio.h>
-#include <stropts.h>
-#include <inet/nd.h>
-#endif
-
-#ifdef __linux__
-#include <sys/ioctl.h>
+#if defined(__linux__)
 #include <arpa/inet.h>
 #include <net/route.h>
 #include <sys/utsname.h>
+#endif
 
-#ifndef IPV6_FLOWINFO_SEND
+#if defined(__solaris__)
+#include <inet/nd.h>
+#include <limits.h>
+#include <stropts.h>
+#include <sys/filio.h>
+#include <sys/sockio.h>
+#endif
+
+#include "net_util.h"
+
+#include "java_net_SocketOptions.h"
+#include "java_net_InetAddress.h"
+
+#if defined(__linux__) && !defined(IPV6_FLOWINFO_SEND)
 #define IPV6_FLOWINFO_SEND      33
 #endif
 
+#if defined(__solaris__) && !defined(MAXINT)
+#define MAXINT INT_MAX
 #endif
 
-#ifdef _AIX
-#include <sys/ioctl.h>
-#endif
-
-#include "jni_util.h"
-#include "jvm.h"
-#include "net_util.h"
-
-#include "java_net_SocketOptions.h"
-
 /*
  * EXCLBIND socket options only on Solaris
  */
@@ -806,13 +788,15 @@
     family = getInetAddress_family(env, iaObj);
 #ifdef AF_INET6
     /* needs work. 1. family 2. clean up him6 etc deallocate memory */
-    if (ipv6_available() && !(family == IPv4 && v4MappedAddress == JNI_FALSE)) {
+    if (ipv6_available() && !(family == java_net_InetAddress_IPv4 &&
+                              v4MappedAddress == JNI_FALSE)) {
         struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
         jbyte caddr[16];
         jint address;
 
 
-        if (family == IPv4) { /* will convert to IPv4-mapped address */
+        if (family == java_net_InetAddress_IPv4) {
+            // convert to IPv4-mapped address
             memset((char *) caddr, 0, 16);
             address = getInetAddress_addr(env, iaObj);
             if (address == INADDR_ANY) {
@@ -906,7 +890,7 @@
 #else
         /* handle scope_id for solaris */
 
-        if (family != IPv4) {
+        if (family != java_net_InetAddress_IPv4) {
             if (ia6_scopeidID) {
                 him6->sin6_scope_id = getInet6Address_scopeid(env, iaObj);
             }
@@ -917,14 +901,14 @@
         {
             struct sockaddr_in *him4 = (struct sockaddr_in*)him;
             jint address;
-            if (family == IPv6) {
+            if (family == java_net_InetAddress_IPv6) {
               JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family unavailable");
               return -1;
             }
             memset((char *) him4, 0, sizeof(struct sockaddr_in));
             address = getInetAddress_addr(env, iaObj);
             him4->sin_port = htons((short) port);
-            him4->sin_addr.s_addr = (uint32_t) htonl(address);
+            him4->sin_addr.s_addr = htonl(address);
             him4->sin_family = AF_INET;
             *len = sizeof(struct sockaddr_in);
         }
--- a/src/java.base/unix/native/libnet/net_util_md.h	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/unix/native/libnet/net_util_md.h	Thu Oct 27 09:42:08 2016 -0700
@@ -26,13 +26,9 @@
 #ifndef NET_UTILS_MD_H
 #define NET_UTILS_MD_H
 
+#include <netdb.h>
+#include <sys/poll.h>
 #include <sys/socket.h>
-#include <sys/types.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <unistd.h>
-
-#include <sys/poll.h>
 
 int NET_Timeout(int s, long timeout);
 int NET_Timeout0(int s, long timeout, long currentTime);
--- a/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,10 +22,8 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-#include <windows.h>
-#include <winsock2.h>
-#include "jni.h"
 #include "net_util.h"
+
 #include "java_net_DualStackPlainDatagramSocketImpl.h"
 
 /*
--- a/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,11 +22,10 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-#include <windows.h>
-#include <winsock2.h>
-#include "jni.h"
 #include "net_util.h"
+
 #include "java_net_DualStackPlainSocketImpl.h"
+#include "java_net_SocketOptions.h"
 
 #define SET_BLOCKING 0
 #define SET_NONBLOCKING 1
--- a/src/java.base/windows/native/libnet/Inet4AddressImpl.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnet/Inet4AddressImpl.c	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,24 +22,12 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+#include <malloc.h>
 
-#include <windows.h>
-#include <winsock2.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <sys/types.h>
-#include <process.h>
-#include <iphlpapi.h>
-#include <icmpapi.h>
-#include <WinError.h>
+#include "net_util.h"
 
 #include "java_net_InetAddress.h"
 #include "java_net_Inet4AddressImpl.h"
-#include "net_util.h"
-#include "icmp.h"
-
 
 /*
  * Returns true if hostname is in dotted IP address format. Note that this
--- a/src/java.base/windows/native/libnet/Inet6AddressImpl.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnet/Inet6AddressImpl.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,38 +22,13 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+#include <malloc.h>
 
-#include <windows.h>
-#include <winsock2.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <sys/types.h>
-#include <process.h>
-#include <iphlpapi.h>
-#include <icmpapi.h>
+#include "net_util.h"
 
 #include "java_net_InetAddress.h"
 #include "java_net_Inet4AddressImpl.h"
 #include "java_net_Inet6AddressImpl.h"
-#include "net_util.h"
-#include "icmp.h"
-
-#ifdef WIN32
-#ifndef _WIN64
-
-/* Retain this code a little longer to support building in
- * old environments.  _MSC_VER is defined as:
- *     1200 for MSVC++ 6.0
- *     1310 for Vc7
- */
-#if defined(_MSC_VER) && _MSC_VER < 1310
-#define sockaddr_in6 SOCKADDR_IN6
-#endif
-#endif
-#define uint32_t UINT32
-#endif
 
 /*
  * Inet6AddressImpl
@@ -300,7 +275,7 @@
         addr |= ((caddr[2] <<8) & 0xff00);
         addr |= (caddr[3] & 0xff);
         memset((char *) &him4, 0, sizeof(him4));
-        him4.sin_addr.s_addr = (uint32_t) htonl(addr);
+        him4.sin_addr.s_addr = htonl(addr);
         him4.sin_family = AF_INET;
         sa = (struct sockaddr *) &him4;
         len = sizeof(him4);
--- a/src/java.base/windows/native/libnet/NetworkInterface.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnet/NetworkInterface.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,17 +22,10 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
-#include <stdlib.h>
-#include <windows.h>
-#include <winsock2.h>           /* needed for htonl */
-#include <iprtrmib.h>
-#include <assert.h>
+#include "net_util.h"
+#include "NetworkInterface.h"
 
 #include "java_net_NetworkInterface.h"
-#include "jni_util.h"
-
-#include "NetworkInterface.h"
 
 /*
  * Windows implementation of the java.net.NetworkInterface native methods.
--- a/src/java.base/windows/native/libnet/NetworkInterface.h	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnet/NetworkInterface.h	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 #ifndef NETWORK_INTERFACE_H
 #define NETWORK_INTERFACE_H
 
-#include <iphlpapi.h>
 #include "net_util.h"
 
 /*
--- a/src/java.base/windows/native/libnet/NetworkInterface_winXP.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnet/NetworkInterface_winXP.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,19 +22,10 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
-#include <stdlib.h>
-#include <windows.h>
-#include <winsock2.h>           /* needed for htonl */
-#include <iprtrmib.h>
-#include <assert.h>
-#include <limits.h>
+#include "net_util.h"
+#include "NetworkInterface.h"
 
 #include "java_net_NetworkInterface.h"
-#include "jni_util.h"
-
-#include "NetworkInterface.h"
-#include "net_util.h"
 
 /*
  * Windows implementation of the java.net.NetworkInterface native methods.
@@ -554,14 +545,20 @@
      * Create a NetworkInterface object and populate it
      */
     netifObj = (*env)->NewObject(env, ni_class, ni_ctor);
+    if (netifObj == NULL) {
+        return NULL;
+    }
     name = (*env)->NewStringUTF(env, ifs->name);
+    if (name == NULL) {
+        return NULL;
+    }
     if (ifs->dNameIsUnicode) {
         displayName = (*env)->NewString(env, (PWCHAR)ifs->displayName,
                                         (jsize)wcslen ((PWCHAR)ifs->displayName));
     } else {
         displayName = (*env)->NewStringUTF(env, ifs->displayName);
     }
-    if (netifObj == NULL || name == NULL || displayName == NULL) {
+    if (displayName == NULL) {
         return NULL;
     }
     (*env)->SetObjectField(env, netifObj, ni_nameID, name);
@@ -621,26 +618,28 @@
             (*env)->SetObjectArrayElement(env, bindsArr, bind_index++, ibObj);
         } else /* AF_INET6 */ {
             int scope;
+            jboolean ret;
             iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
-            if (iaObj) {
-                jboolean ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.sa6.sin6_addr.s6_addr));
-                if (ret == JNI_FALSE) {
-                    return NULL;
-                }
-                scope = addrs->addr.sa6.sin6_scope_id;
-                if (scope != 0) { /* zero is default value, no need to set */
-                    setInet6Address_scopeid(env, iaObj, scope);
-                    setInet6Address_scopeifname(env, iaObj, netifObj);
-                }
-                ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
-                if (ibObj == NULL) {
-                  free_netaddr(netaddrP);
-                  return NULL;
-                }
-                (*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj);
-                (*env)->SetShortField(env, ibObj, ni_ibmaskID, addrs->mask);
-                (*env)->SetObjectArrayElement(env, bindsArr, bind_index++, ibObj);
+            if (iaObj == NULL) {
+                return NULL;
             }
+            ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.sa6.sin6_addr.s6_addr));
+            if (ret == JNI_FALSE) {
+                return NULL;
+            }
+            scope = addrs->addr.sa6.sin6_scope_id;
+            if (scope != 0) { /* zero is default value, no need to set */
+                setInet6Address_scopeid(env, iaObj, scope);
+                setInet6Address_scopeifname(env, iaObj, netifObj);
+            }
+            ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
+            if (ibObj == NULL) {
+              free_netaddr(netaddrP);
+              return NULL;
+            }
+            (*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj);
+            (*env)->SetShortField(env, ibObj, ni_ibmaskID, addrs->mask);
+            (*env)->SetObjectArrayElement(env, bindsArr, bind_index++, ibObj);
         }
         (*env)->SetObjectArrayElement(env, addrArr, addr_index, iaObj);
         addrs = addrs->next;
--- a/src/java.base/windows/native/libnet/SocketInputStream.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnet/SocketInputStream.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,24 +22,15 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+#include <malloc.h>
 
-#include <windows.h>
-#include <winsock2.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <sys/types.h>
+#include "net_util.h"
 
 #include "java_net_SocketInputStream.h"
 
-#include "net_util.h"
-#include "jni_util.h"
-
 /*************************************************************************
  * SocketInputStream
  */
-
 static jfieldID IO_fd_fdID;
 
 /*
--- a/src/java.base/windows/native/libnet/SocketOutputStream.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnet/SocketOutputStream.c	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,20 +22,12 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+#include <malloc.h>
 
-#include <windows.h>
-#include <winsock2.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <sys/types.h>
+#include "net_util.h"
 
 #include "java_net_SocketOutputStream.h"
 
-#include "net_util.h"
-#include "jni_util.h"
-
 /************************************************************************
  * SocketOutputStream
  */
--- a/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,15 +22,15 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+#include <malloc.h>
 
-#include <windows.h>
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <sys/types.h>
+#include "net_util.h"
+#include "NetworkInterface.h"
+
+#include "java_net_TwoStacksPlainDatagramSocketImpl.h"
+#include "java_net_SocketOptions.h"
+#include "java_net_NetworkInterface.h"
+#include "java_net_InetAddress.h"
 
 #ifndef IPTOS_TOS_MASK
 #define IPTOS_TOS_MASK 0x1e
@@ -39,14 +39,6 @@
 #define IPTOS_PREC_MASK 0xe0
 #endif
 
-#include "java_net_TwoStacksPlainDatagramSocketImpl.h"
-#include "java_net_SocketOptions.h"
-#include "java_net_NetworkInterface.h"
-
-#include "NetworkInterface.h"
-#include "jvm.h"
-#include "jni_util.h"
-#include "net_util.h"
 
 #define IN_CLASSD(i)    (((long)(i) & 0xf0000000) == 0xe0000000)
 #define IN_MULTICAST(i) IN_CLASSD(i)
@@ -439,7 +431,7 @@
     memset((char *)&lcladdr, 0, sizeof(lcladdr));
 
     family = getInetAddress_family(env, addressObj);
-    if (family == IPv6 && !ipv6_supported) {
+    if (family == java_net_InetAddress_IPv6 && !ipv6_supported) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                         "Protocol family not supported");
         return;
@@ -561,13 +553,13 @@
     addr = getInetAddress_addr(env, address);
 
     family = getInetAddress_family(env, address);
-    if (family == IPv6 && !ipv6_supported) {
+    if (family == java_net_InetAddress_IPv6 && !ipv6_supported) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                         "Protocol family not supported");
         return;
     }
 
-    fdc = family == IPv4? fd: fd1;
+    fdc = family == java_net_InetAddress_IPv4 ? fd : fd1;
 
     if (xp_or_later) {
         /* SIO_UDP_CONNRESET fixes a bug introduced in Windows 2000, which
@@ -605,12 +597,12 @@
     jint fd, len;
     SOCKETADDRESS addr;
 
-    if (family == IPv4) {
+    if (family == java_net_InetAddress_IPv4) {
         fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
-        len = sizeof (struct sockaddr_in);
+        len = sizeof(struct sockaddr_in);
     } else {
         fdObj = (*env)->GetObjectField(env, this, pdsi_fd1ID);
-        len = sizeof (struct SOCKADDR_IN6);
+        len = sizeof(struct sockaddr_in6);
     }
 
     if (IS_NULL(fdObj)) {
@@ -678,7 +670,7 @@
     }
 
     family = getInetAddress_family(env, iaObj);
-    if (family == IPv4) {
+    if (family == java_net_InetAddress_IPv4) {
         fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
     } else {
         if (!ipv6_available()) {
@@ -830,6 +822,7 @@
     }
     if (IS_NULL(addressObj)) {
         JNU_ThrowNullPointerException(env, "Null address in peek()");
+        return -1;
     } else {
         address = getInetAddress_addr(env, addressObj);
         /* We only handle IPv4 for now. Will support IPv6 once its in the os */
@@ -905,7 +898,7 @@
         return 0;
     }
     setInetAddress_addr(env, addressObj, ntohl(remote_addr.sa4.sin_addr.s_addr));
-    setInetAddress_family(env, addressObj, IPv4);
+    setInetAddress_family(env, addressObj, java_net_InetAddress_IPv4);
 
     /* return port */
     return ntohs(remote_addr.sa4.sin_port);
@@ -1127,11 +1120,23 @@
     }
     if (n == -1) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "socket closed");
+        if (packetBufferLen > MAX_BUFFER_LEN) {
+            free(fullPacket);
+        }
+        return -1;
     } else if (n == -2) {
         JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
                         "operation interrupted");
+        if (packetBufferLen > MAX_BUFFER_LEN) {
+            free(fullPacket);
+        }
+        return -1;
     } else if (n < 0) {
         NET_ThrowCurrent(env, "Datagram receive failed");
+        if (packetBufferLen > MAX_BUFFER_LEN) {
+            free(fullPacket);
+        }
+        return -1;
     } else {
         jobject packetAddress;
 
@@ -1597,7 +1602,7 @@
 {
     jobject addr;
 
-    int ret = getInetAddrFromIf (env, IPv4, nif, &addr);
+    int ret = getInetAddrFromIf(env, java_net_InetAddress_IPv4, nif, &addr);
     if (ret == -1) {
         return -1;
     }
@@ -1882,7 +1887,7 @@
         default :
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                 "Socket option not supported by PlainDatagramSocketImp");
-            break;
+            return;
 
     }
 
@@ -2272,9 +2277,9 @@
     len = sizeof(struct sockaddr_in);
 
     /* family==-1 when socket is not connected */
-    if ((family == IPv6) || (family == -1 && fd == -1)) {
+    if ((family == java_net_InetAddress_IPv6) || (family == -1 && fd == -1)) {
         fd = fd1; /* must be IPv6 only */
-        len = sizeof (struct SOCKADDR_IN6);
+        len = sizeof(struct sockaddr_in6);
     }
 
     if (fd == -1) {
@@ -2325,6 +2330,7 @@
       if (NET_SetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_TTL, (char*)&ittl,
                          sizeof (ittl)) < 0) {
         NET_ThrowCurrent(env, "set IP_MULTICAST_TTL failed");
+        return;
       }
     }
 
@@ -2518,6 +2524,9 @@
         } else {
             ifindex = getIndexFromIf (env, niObj);
             if (ifindex == -1) {
+                if ((*env)->ExceptionOccurred(env)) {
+                    return;
+                }
                 NET_ThrowCurrent(env, "get ifindex failed");
                 return;
             }
--- a/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,23 +22,13 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
-#include <windows.h>
-#include <winsock2.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <malloc.h>
-#include <sys/types.h>
-
-#include "java_net_SocketOptions.h"
-#include "java_net_TwoStacksPlainSocketImpl.h"
-#include "java_net_InetAddress.h"
-#include "java_io_FileDescriptor.h"
-#include "java_lang_Integer.h"
 
 #include "net_util.h"
-#include "jni_util.h"
+
+#include "java_net_TwoStacksPlainSocketImpl.h"
+#include "java_net_SocketOptions.h"
+#include "java_net_InetAddress.h"
 
 /************************************************************************
  * TwoStacksPlainSocketImpl
@@ -108,7 +98,7 @@
     psi_portID = (*env)->GetFieldID(env, cls, "port", "I");
     CHECK_NULL(psi_portID);
     psi_lastfdID = (*env)->GetFieldID(env, cls, "lastfd", "I");
-    CHECK_NULL(psi_portID);
+    CHECK_NULL(psi_lastfdID);
     psi_localportID = (*env)->GetFieldID(env, cls, "localport", "I");
     CHECK_NULL(psi_localportID);
     psi_timeoutID = (*env)->GetFieldID(env, cls, "timeout", "I");
@@ -153,17 +143,17 @@
         fd1Obj = (*env)->GetObjectField(env, this, psi_fd1ID);
 
         if (IS_NULL(fd1Obj)) {
+            (*env)->SetIntField(env, fdObj, IO_fd_fdID, -1);
+            NET_SocketClose(fd);
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                             "null fd1 object");
-            (*env)->SetIntField(env, fdObj, IO_fd_fdID, -1);
-            NET_SocketClose(fd);
             return;
         }
         fd1 = socket(AF_INET6, (stream ? SOCK_STREAM: SOCK_DGRAM), 0);
         if (fd1 == -1) {
-            NET_ThrowCurrent(env, "create");
             (*env)->SetIntField(env, fdObj, IO_fd_fdID, -1);
             NET_SocketClose(fd);
+            NET_ThrowCurrent(env, "create");
             return;
         } else {
             /* Set socket attribute so it is not passed to any child process */
@@ -413,7 +403,7 @@
 
     family = getInetAddress_family(env, iaObj);
 
-    if (family == IPv6 && !ipv6_supported) {
+    if (family == java_net_InetAddress_IPv6 && !ipv6_supported) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                         "Protocol family not supported");
         return;
@@ -655,18 +645,18 @@
             return;
         }
         if (fd2 == fd) { /* v4 */
-            len = sizeof (struct sockaddr_in);
+            len = sizeof(struct sockaddr_in);
         } else {
-            len = sizeof (struct SOCKADDR_IN6);
+            len = sizeof(struct sockaddr_in6);
         }
         fd = fd2;
     } else {
         int ret;
         if (fd1 != -1) {
             fd = fd1;
-            len = sizeof (struct SOCKADDR_IN6);
+            len = sizeof(struct sockaddr_in6);
         } else {
-            len = sizeof (struct sockaddr_in);
+            len = sizeof(struct sockaddr_in);
         }
         if (timeout) {
             ret = NET_Timeout(fd, timeout);
@@ -728,7 +718,7 @@
         }
 
         setInetAddress_addr(env, socketAddressObj, ntohl(him.sa4.sin_addr.s_addr));
-        setInetAddress_family(env, socketAddressObj, IPv4);
+        setInetAddress_family(env, socketAddressObj, java_net_InetAddress_IPv4);
         (*env)->SetObjectField(env, socket, psi_addressID, socketAddressObj);
     } else {
         /* AF_INET6 -> Inet6Address */
@@ -754,7 +744,7 @@
             return;
         }
         setInet6Address_ipaddress(env, socketAddressObj, (char *)&him.sa6.sin6_addr);
-        setInetAddress_family(env, socketAddressObj, IPv6);
+        setInetAddress_family(env, socketAddressObj, java_net_InetAddress_IPv6);
         setInet6Address_scopeid(env, socketAddressObj, him.sa6.sin6_scope_id);
 
     }
@@ -907,6 +897,7 @@
                     isRcvTimeoutSupported = JNI_FALSE;
                 } else {
                     NET_ThrowCurrent(env, "setsockopt SO_RCVTIMEO");
+                    return;
                 }
             }
             if (fd1 != -1) {
--- a/src/java.base/windows/native/libnet/icmp.h	Thu Oct 27 09:38:46 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#ifndef ICMP_H
-#define ICMP_H
-
-/*
- * Structure of an internet header, naked of options.
- *
- * We declare ip_len and ip_off to be short, rather than ushort_t
- * pragmatically since otherwise unsigned comparisons can result
- * against negative integers quite easily, and fail in subtle ways.
- */
-struct ip {
-        unsigned char   ip_hl:4,        /* header length */
-                        ip_v:4;         /* version */
-        unsigned char   ip_tos;                 /* type of service */
-        short   ip_len;                 /* total length */
-        unsigned short ip_id;                   /* identification */
-        short   ip_off;                 /* fragment offset field */
-#define IP_DF 0x4000                    /* don't fragment flag */
-#define IP_MF 0x2000                    /* more fragments flag */
-        unsigned char   ip_ttl;                 /* time to live */
-        unsigned char   ip_p;                   /* protocol */
-        unsigned short ip_sum;          /* checksum */
-        struct  in_addr ip_src, ip_dst; /* source and dest address */
-};
-
-/*
- * Structure of an icmp header.
- */
-struct icmp {
-        unsigned char   icmp_type;              /* type of message, see below */
-        unsigned char   icmp_code;              /* type sub code */
-        unsigned short icmp_cksum;              /* ones complement cksum of struct */
-        union {
-                unsigned char ih_pptr;          /* ICMP_PARAMPROB */
-                struct in_addr ih_gwaddr;       /* ICMP_REDIRECT */
-                struct ih_idseq {
-                        unsigned short icd_id;
-                        unsigned short icd_seq;
-                } ih_idseq;
-                int ih_void;
-
-                /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
-                struct ih_pmtu {
-                        unsigned short ipm_void;
-                        unsigned short ipm_nextmtu;
-                } ih_pmtu;
-
-                struct ih_rtradv {
-                        unsigned char irt_num_addrs;
-                        unsigned char irt_wpa;
-                        unsigned short irt_lifetime;
-                } ih_rtradv;
-        } icmp_hun;
-#define icmp_pptr       icmp_hun.ih_pptr
-#define icmp_gwaddr     icmp_hun.ih_gwaddr
-#define icmp_id         icmp_hun.ih_idseq.icd_id
-#define icmp_seq        icmp_hun.ih_idseq.icd_seq
-#define icmp_void       icmp_hun.ih_void
-#define icmp_pmvoid     icmp_hun.ih_pmtu.ipm_void
-#define icmp_nextmtu    icmp_hun.ih_pmtu.ipm_nextmtu
-        union {
-                struct id_ts {
-                        unsigned int its_otime;
-                        unsigned int its_rtime;
-                        unsigned int its_ttime;
-                } id_ts;
-                struct id_ip  {
-                        struct ip idi_ip;
-                        /* options and then 64 bits of data */
-                } id_ip;
-                unsigned int id_mask;
-                char    id_data[1];
-        } icmp_dun;
-#define icmp_otime      icmp_dun.id_ts.its_otime
-#define icmp_rtime      icmp_dun.id_ts.its_rtime
-#define icmp_ttime      icmp_dun.id_ts.its_ttime
-#define icmp_ip         icmp_dun.id_ip.idi_ip
-#define icmp_mask       icmp_dun.id_mask
-#define icmp_data       icmp_dun.id_data
-};
-
-#define ICMP_ECHOREPLY          0               /* echo reply */
-#define ICMP_ECHO               8               /* echo service */
-
-/*
- * ICMPv6 structures & constants
- */
-
-typedef struct icmp6_hdr {
-        u_char   icmp6_type;    /* type field */
-        u_char   icmp6_code;    /* code field */
-        u_short  icmp6_cksum;   /* checksum field */
-        union {
-                u_int icmp6_un_data32[1];       /* type-specific field */
-                u_short icmp6_un_data16[2];     /* type-specific field */
-                u_char  icmp6_un_data8[4];      /* type-specific field */
-        } icmp6_dataun;
-} icmp6_t;
-
-#define icmp6_data32    icmp6_dataun.icmp6_un_data32
-#define icmp6_data16    icmp6_dataun.icmp6_un_data16
-#define icmp6_data8     icmp6_dataun.icmp6_un_data8
-#define icmp6_pptr      icmp6_data32[0] /* parameter prob */
-#define icmp6_mtu       icmp6_data32[0] /* packet too big */
-#define icmp6_id        icmp6_data16[0] /* echo request/reply */
-#define icmp6_seq       icmp6_data16[1] /* echo request/reply */
-#define icmp6_maxdelay  icmp6_data16[0] /* mcast group membership */
-
-struct ip6_pseudo_hdr  /* for calculate the ICMPv6 checksum */
-{
-  struct in6_addr ip6_src;
-  struct in6_addr ip6_dst;
-  u_int       ip6_plen;
-  u_int       ip6_nxt;
-};
-
-#define ICMP6_ECHO_REQUEST      128
-#define ICMP6_ECHO_REPLY        129
-#define IPPROTO_ICMPV6          58
-#define IPV6_UNICAST_HOPS       4  /* Set/get IP unicast hop limit */
-
-
-#endif
--- a/src/java.base/windows/native/libnet/net_util_md.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnet/net_util_md.c	Thu Oct 27 09:42:08 2016 -0700
@@ -22,12 +22,10 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+#include "net_util.h"
 
-#include <winsock2.h>
-#include <ws2tcpip.h>
-
-#include "net_util.h"
-#include "jni.h"
+#include "java_net_InetAddress.h"
+#include "java_net_SocketOptions.h"
 
 // Taken from mstcpip.h in Windows SDK 8.0 or newer.
 #define SIO_LOOPBACK_FAST_PATH              _WSAIOW(IOC_VENDOR,16)
@@ -593,7 +591,7 @@
 
 
 void dumpAddr (char *str, void *addr) {
-    struct SOCKADDR_IN6 *a = (struct SOCKADDR_IN6 *)addr;
+    struct sockaddr_in6 *a = (struct sockaddr_in6 *)addr;
     int family = a->sin6_family;
     printf ("%s\n", str);
     if (family == AF_INET) {
@@ -812,7 +810,7 @@
  *      0 if error
  *      > 0 interface index to use
  */
-jint getDefaultIPv6Interface(JNIEnv *env, struct SOCKADDR_IN6 *target_addr)
+jint getDefaultIPv6Interface(JNIEnv *env, struct sockaddr_in6 *target_addr)
 {
     int ret;
     DWORD b;
@@ -866,9 +864,9 @@
                           int *len, jboolean v4MappedAddress) {
     jint family, iafam;
     iafam = getInetAddress_family(env, iaObj);
-    family = (iafam == IPv4)? AF_INET : AF_INET6;
+    family = (iafam == java_net_InetAddress_IPv4)? AF_INET : AF_INET6;
     if (ipv6_available() && !(family == AF_INET && v4MappedAddress == JNI_FALSE)) {
-        struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
+        struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
         jbyte caddr[16];
         jint address, scopeid = 0;
         jint cached_scope_id = 0;
@@ -894,7 +892,7 @@
             cached_scope_id = (jint)(*env)->GetIntField(env, iaObj, ia6_cachedscopeidID);
         }
 
-        memset((char *)him6, 0, sizeof(struct SOCKADDR_IN6));
+        memset((char *)him6, 0, sizeof(struct sockaddr_in6));
         him6->sin6_port = (u_short) htons((u_short)port);
         memcpy((void *)&(him6->sin6_addr), caddr, sizeof(struct in6_addr) );
         him6->sin6_family = AF_INET6;
@@ -904,7 +902,7 @@
             (*env)->SetIntField(env, iaObj, ia6_cachedscopeidID, cached_scope_id);
         }
         him6->sin6_scope_id = scopeid != 0 ? scopeid : cached_scope_id;
-        *len = sizeof(struct SOCKADDR_IN6) ;
+        *len = sizeof(struct sockaddr_in6) ;
     } else {
         struct sockaddr_in *him4 = (struct sockaddr_in *)him;
         jint address;
@@ -964,12 +962,12 @@
 }
 
 int getScopeID(struct sockaddr *him) {
-    struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
+    struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
     return him6->sin6_scope_id;
 }
 
 int cmpScopeID(unsigned int scope, struct sockaddr *him) {
-    struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
+    struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
     return him6->sin6_scope_id == scope;
 }
 
--- a/src/java.base/windows/native/libnet/net_util_md.h	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnet/net_util_md.h	Thu Oct 27 09:42:08 2016 -0700
@@ -22,195 +22,10 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 #include <winsock2.h>
 #include <WS2tcpip.h>
-
-/* typedefs that were defined correctly for the first time
- * in Nov. 2001 SDK, which we need to include here.
- * Specifically, in6_addr and sockaddr_in6 (which is defined but
- * not correctly). When moving to a later SDK remove following
- * code between START and END
- */
-
-/* --- START --- */
-
-/* WIN64 already uses newer SDK */
-#ifdef _WIN64
-
-#define SOCKADDR_IN6 sockaddr_in6
-
-#else
-
-#ifdef _MSC_VER
-#define WS2TCPIP_INLINE __inline
-#else
-#define WS2TCPIP_INLINE extern inline /* GNU style */
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1310
-
-#define SOCKADDR_IN6 sockaddr_in6
-
-#else
-
-/*SO_REUSEPORT is not supported on Windows, define it to 0*/
-#define SO_REUSEPORT 0
-
-/* Retain this code a little longer to support building in
- * old environments.  _MSC_VER is defined as:
- *     1200 for MSVC++ 6.0
- *     1310 for Vc7
- */
-
-#define IPPROTO_IPV6    41
-#define IPV6_MULTICAST_IF 9
-
-struct in6_addr {
-    union {
-        u_char Byte[16];
-        u_short Word[8];
-    } u;
-};
-
-/*
-** Defines to match RFC 2553.
-*/
-#define _S6_un     u
-#define _S6_u8     Byte
-#define s6_addr    _S6_un._S6_u8
-
-/*
-** Defines for our implementation.
-*/
-#define s6_bytes   u.Byte
-#define s6_words   u.Word
-
-/* IPv6 socket address structure, RFC 2553 */
-
-struct SOCKADDR_IN6 {
-        short   sin6_family;    /* AF_INET6 */
-        u_short sin6_port;      /* Transport level port number */
-        u_long  sin6_flowinfo;  /* IPv6 flow information */
-        struct in6_addr sin6_addr; /* IPv6 address */
-        u_long sin6_scope_id;  /* set of interfaces for a scope */
-};
-
-
-/* Error codes from getaddrinfo() */
-
-#define EAI_AGAIN       WSATRY_AGAIN
-#define EAI_BADFLAGS    WSAEINVAL
-#define EAI_FAIL        WSANO_RECOVERY
-#define EAI_FAMILY      WSAEAFNOSUPPORT
-#define EAI_MEMORY      WSA_NOT_ENOUGH_MEMORY
-//#define EAI_NODATA      WSANO_DATA
-#define EAI_NONAME      WSAHOST_NOT_FOUND
-#define EAI_SERVICE     WSATYPE_NOT_FOUND
-#define EAI_SOCKTYPE    WSAESOCKTNOSUPPORT
-
-#define EAI_NODATA      EAI_NONAME
-
-/* Structure used in getaddrinfo() call */
-
-typedef struct addrinfo {
-    int ai_flags;              /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
-    int ai_family;             /* PF_xxx */
-    int ai_socktype;           /* SOCK_xxx */
-    int ai_protocol;           /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
-    size_t ai_addrlen;         /* Length of ai_addr */
-    char *ai_canonname;        /* Canonical name for nodename */
-    struct sockaddr *ai_addr;  /* Binary address */
-    struct addrinfo *ai_next;  /* Next structure in linked list */
-} ADDRINFO, FAR * LPADDRINFO;
-
-/* Flags used in "hints" argument to getaddrinfo() */
-
-#define AI_PASSIVE     0x1  /* Socket address will be used in bind() call */
-#define AI_CANONNAME   0x2  /* Return canonical name in first ai_canonname */
-#define AI_NUMERICHOST 0x4  /* Nodename must be a numeric address string */
-
-/* IPv6 Multicasting definitions */
-
-/* Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP */
-
-typedef struct ipv6_mreq {
-    struct in6_addr ipv6mr_multiaddr;  /* IPv6 multicast address */
-    unsigned int    ipv6mr_interface;  /* Interface index */
-} IPV6_MREQ;
-
-#define IPV6_ADD_MEMBERSHIP     12 /* Add an IP group membership */
-#define IPV6_DROP_MEMBERSHIP    13 /* Drop an IP group membership */
-#define IPV6_MULTICAST_LOOP     11 /* Set/get IP multicast loopback */
-
-WS2TCPIP_INLINE int
-IN6_IS_ADDR_MULTICAST(const struct in6_addr *a)
-{
-    return (a->s6_bytes[0] == 0xff);
-}
-
-WS2TCPIP_INLINE int
-IN6_IS_ADDR_LINKLOCAL(const struct in6_addr *a)
-{
-    return (a->s6_bytes[0] == 0xfe
-            && a->s6_bytes[1] == 0x80);
-}
-
-#define NI_MAXHOST  1025  /* Max size of a fully-qualified domain name */
-#define NI_MAXSERV    32  /* Max size of a service name */
-
-#define INET_ADDRSTRLEN  16 /* Max size of numeric form of IPv4 address */
-#define INET6_ADDRSTRLEN 46 /* Max size of numeric form of IPv6 address */
-
-/* Flags for getnameinfo() */
-
-#define NI_NOFQDN       0x01  /* Only return nodename portion for local hosts */
-#define NI_NUMERICHOST  0x02  /* Return numeric form of the host's address */
-#define NI_NAMEREQD     0x04  /* Error if the host's name not in DNS */
-#define NI_NUMERICSERV  0x08  /* Return numeric form of the service (port #) */
-#define NI_DGRAM        0x10  /* Service is a datagram service */
-
-
-#define IN6_IS_ADDR_V4MAPPED(a) \
-    (((a)->s6_words[0] == 0) && ((a)->s6_words[1] == 0) &&      \
-    ((a)->s6_words[2] == 0) && ((a)->s6_words[3] == 0) &&       \
-    ((a)->s6_words[4] == 0) && ((a)->s6_words[5] == 0xffff))
-
-
-/* --- END --- */
-#endif /* end 'else older build environment' */
-
-#endif
-
-#if !INCL_WINSOCK_API_TYPEDEFS
-
-typedef
-int
-(WSAAPI * LPFN_GETADDRINFO)(
-    IN const char FAR * nodename,
-    IN const char FAR * servname,
-    IN const struct addrinfo FAR * hints,
-    OUT struct addrinfo FAR * FAR * res
-    );
-
-typedef
-void
-(WSAAPI * LPFN_FREEADDRINFO)(
-    IN struct addrinfo FAR * ai
-    );
-
-typedef
-int
-(WSAAPI * LPFN_GETNAMEINFO)(
-    IN  const struct sockaddr FAR * sa,
-    IN  int             salen,
-    OUT char FAR *      host,
-    IN  DWORD           hostlen,
-    OUT char FAR *      serv,
-    IN  DWORD           servlen,
-    IN  int             flags
-    );
-#endif
+#include <iphlpapi.h>
+#include <icmpapi.h>
 
 /* used to disable connection reset messages on Windows XP */
 #ifndef SIO_UDP_CONNRESET
@@ -229,13 +44,9 @@
 #define IPV6_V6ONLY     27 /* Treat wildcard bind as AF_INET6-only. */
 #endif
 
-#include "java_io_FileDescriptor.h"
-#include "java_net_SocketOptions.h"
-
 #define MAX_BUFFER_LEN          2048
 #define MAX_HEAP_BUFFER_LEN     65536
 
-
 /* true if SO_RCVTIMEO is supported by underlying provider */
 extern jboolean isRcvTimeoutSupported;
 
@@ -249,7 +60,7 @@
 typedef union {
     struct sockaddr     sa;
     struct sockaddr_in  sa4;
-    struct SOCKADDR_IN6 sa6;
+    struct sockaddr_in6 sa6;
 } SOCKETADDRESS;
 
 /*
@@ -264,7 +75,7 @@
 
 #define SOCKETADDRESS_COPY(DST,SRC) {                           \
     if ((SRC)->sa_family == AF_INET6) {                         \
-        memcpy ((DST), (SRC), sizeof (struct SOCKADDR_IN6));    \
+        memcpy ((DST), (SRC), sizeof (struct sockaddr_in6));    \
     } else {                                                    \
         memcpy ((DST), (SRC), sizeof (struct sockaddr_in));     \
     }                                                           \
--- a/src/java.base/windows/native/libnio/ch/FileDispatcherImpl.c	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.base/windows/native/libnio/ch/FileDispatcherImpl.c	Thu Oct 27 09:42:08 2016 -0700
@@ -202,6 +202,7 @@
 
     if ((h == INVALID_HANDLE_VALUE) || (result == 0)) {
         JNU_ThrowIOExceptionWithLastError(env, "Write failed");
+        return IOS_THROWN;
     }
 
     return convertReturnVal(env, (jint)written, JNI_FALSE);
@@ -250,6 +251,7 @@
 
     if ((h == INVALID_HANDLE_VALUE) || (result == 0)) {
         JNU_ThrowIOExceptionWithLastError(env, "Write failed");
+        return IOS_THROWN;
     }
 
     return convertLongReturnVal(env, totalWritten, JNI_FALSE);
--- a/src/java.desktop/share/classes/sun/applet/AppletSecurity.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.desktop/share/classes/sun/applet/AppletSecurity.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,36 +40,25 @@
 import java.util.StringTokenizer;
 import java.security.*;
 import java.lang.reflect.*;
+import jdk.internal.misc.JavaNetURLClassLoaderAccess;
+import jdk.internal.misc.JavaSecurityAccess;
+import jdk.internal.misc.SharedSecrets;
 import sun.awt.AWTSecurityManager;
 import sun.awt.AppContext;
 import sun.awt.AWTPermissions;
 import sun.security.util.SecurityConstants;
 
 
+
 /**
  * This class defines an applet security policy
  *
  */
 public
 class AppletSecurity extends AWTSecurityManager {
-
-    //URLClassLoader.acc
-    private static Field facc = null;
-
-    //AccessControlContext.context;
-    private static Field fcontext = null;
-
-    static {
-        try {
-            facc = URLClassLoader.class.getDeclaredField("acc");
-            facc.setAccessible(true);
-            fcontext = AccessControlContext.class.getDeclaredField("context");
-            fcontext.setAccessible(true);
-        } catch (NoSuchFieldException e) {
-            throw new UnsupportedOperationException(e);
-        }
-    }
-
+    private static final JavaNetURLClassLoaderAccess JNUCLA
+            = SharedSecrets.getJavaNetURLClassLoaderAccess();
+    private static final JavaSecurityAccess JSA = SharedSecrets.getJavaSecurityAccess();
 
     /**
      * Construct and initialize.
@@ -148,6 +137,7 @@
             final ClassLoader currentLoader = context[i].getClassLoader();
 
             if (currentLoader instanceof URLClassLoader) {
+                URLClassLoader ld = (URLClassLoader)currentLoader;
                 loader = AccessController.doPrivileged(
                     new PrivilegedAction<ClassLoader>() {
                         public ClassLoader run() {
@@ -156,12 +146,12 @@
                             ProtectionDomain[] pds = null;
 
                             try {
-                                acc = (AccessControlContext) facc.get(currentLoader);
+                                acc = JNUCLA.getAccessControlContext(ld);
                                 if (acc == null) {
                                     return null;
                                 }
 
-                                pds = (ProtectionDomain[]) fcontext.get(acc);
+                                pds = JSA.getProtectDomains(acc);
                                 if (pds == null) {
                                     return null;
                                 }
--- a/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java	Thu Oct 27 09:42:08 2016 -0700
@@ -30,10 +30,6 @@
 import java.awt.Toolkit;
 import java.io.*;
 import java.io.FileNotFoundException;
-import java.nio.file.Files;
-import java.nio.file.LinkOption;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.*;
 import java.util.concurrent.Callable;
 
@@ -244,11 +240,10 @@
      * @exception FileNotFoundException if file does not exist
      */
     public static ShellFolder getShellFolder(File file) throws FileNotFoundException {
-        Path path = Paths.get(file.getPath());
         if (file instanceof ShellFolder) {
             return (ShellFolder)file;
         }
-        if (!Files.exists(path, LinkOption.NOFOLLOW_LINKS)) {
+        if (!file.exists()) {
             throw new FileNotFoundException();
         }
         return shellFolderManager.createShellFolder(file);
--- a/src/java.rmi/share/classes/sun/rmi/server/Activation.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/java.rmi/share/classes/sun/rmi/server/Activation.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1970,6 +1970,11 @@
                 AccessController.doPrivileged(
                     new PrivilegedExceptionAction<Void>() {
                         public Void run() throws IOException {
+                            boolean disable = Boolean.getBoolean(
+                                    "sun.rmi.server.activation.disableErrRedirect");
+                            if (disable)
+                                return null;
+
                             File file =
                                 Files.createTempFile("rmid-err", null).toFile();
                             PrintStream errStream =
--- a/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp	Thu Oct 27 09:42:08 2016 -0700
@@ -36,6 +36,7 @@
 #include <BaseTsd.h>
 #include <wincrypt.h>
 #include <stdio.h>
+#include <memory>
 
 
 #define OID_EKU_ANY         "2.5.29.37.0"
@@ -48,6 +49,7 @@
 #define KEYSTORE_EXCEPTION  "java/security/KeyStoreException"
 #define PROVIDER_EXCEPTION  "java/security/ProviderException"
 #define SIGNATURE_EXCEPTION "java/security/SignatureException"
+#define OUT_OF_MEMORY_ERROR "java/lang/OutOfMemoryError"
 
 extern "C" {
 
@@ -57,10 +59,22 @@
 DEF_STATIC_JNI_OnLoad
 
 /*
+ * Throws an arbitrary Java exception with the given message.
+ */
+void ThrowExceptionWithMessage(JNIEnv *env, const char *exceptionName,
+                               const char *szMessage)
+{
+    jclass exceptionClazz = env->FindClass(exceptionName);
+    if (exceptionClazz != NULL) {
+        env->ThrowNew(exceptionClazz, szMessage);
+    }
+}
+
+/*
  * Throws an arbitrary Java exception.
  * The exception message is a Windows system error message.
  */
-void ThrowException(JNIEnv *env, char *exceptionName, DWORD dwError)
+void ThrowException(JNIEnv *env, const char *exceptionName, DWORD dwError)
 {
     char szMessage[1024];
     szMessage[0] = '\0';
@@ -71,12 +85,22 @@
         strcpy(szMessage, "Unknown error");
     }
 
-    jclass exceptionClazz = env->FindClass(exceptionName);
-    if (exceptionClazz != NULL) {
-        env->ThrowNew(exceptionClazz, szMessage);
-    }
+    ThrowExceptionWithMessage(env, exceptionName, szMessage);
 }
 
+/*
+ * Overloaded 'operator new[]' variant, which will raise Java's
+ * OutOfMemoryError in the case of a failure.
+ */
+static void* operator new[](std::size_t size, JNIEnv *env)
+{
+    void* buf = ::operator new[](size, std::nothrow);
+    if (buf == NULL) {
+        ThrowExceptionWithMessage(env, OUT_OF_MEMORY_ERROR,
+                "Native memory allocation failed");
+    }
+    return buf;
+}
 
 /*
  * Maps the name of a hash algorithm to an algorithm identifier.
@@ -211,7 +235,10 @@
 
         } else if (length > 0) {
 
-            pbData = new BYTE[length];
+            pbData = new (env) BYTE[length];
+            if (pbData == NULL) {
+                __leave;
+            }
 
             if (::CryptGenRandom(
                 hCryptProv,
@@ -441,7 +468,11 @@
                                 NULL, 0)) > 1) {
 
                                 // Found friendly name
-                                pszNameString = new char[cchNameString];
+                                pszNameString = new (env) char[cchNameString];
+                                if (pszNameString == NULL) {
+                                    __leave;
+                                }
+
                                 CertGetNameString(pc,
                                     CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL,
                                     pszNameString, cchNameString);
@@ -578,7 +609,10 @@
         }
 
         // Copy hash from Java to native buffer
-        pHashBuffer = new jbyte[jHashSize];
+        pHashBuffer = new (env) jbyte[jHashSize];
+        if (pHashBuffer == NULL) {
+            __leave;
+        }
         env->GetByteArrayRegion(jHash, 0, jHashSize, pHashBuffer);
 
         // Set hash value in the hash object
@@ -616,7 +650,10 @@
             __leave;
         }
 
-        pSignedHashBuffer = new jbyte[dwBufLen];
+        pSignedHashBuffer = new (env) jbyte[dwBufLen];
+        if (pSignedHashBuffer == NULL) {
+            __leave;
+        }
         if (::CryptSignHash(hHash, dwKeySpec, NULL, dwFlags, (BYTE*)pSignedHashBuffer, &dwBufLen) == FALSE)
         {
             ThrowException(env, SIGNATURE_EXCEPTION, GetLastError());
@@ -704,9 +741,16 @@
         }
 
         // Copy hash and signedHash from Java to native buffer
-        pHashBuffer = new jbyte[jHashSize];
+        pHashBuffer = new (env) jbyte[jHashSize];
+        if (pHashBuffer == NULL) {
+            __leave;
+        }
         env->GetByteArrayRegion(jHash, 0, jHashSize, pHashBuffer);
-        pSignedHashBuffer = new jbyte[jSignedHashSize];
+
+        pSignedHashBuffer = new (env) jbyte[jSignedHashSize];
+        if (pSignedHashBuffer == NULL) {
+            __leave;
+        }
         env->GetByteArrayRegion(jSignedHash, 0, jSignedHashSize,
             pSignedHashBuffer);
 
@@ -919,7 +963,10 @@
         }
 
         // Copy encoding from Java to native buffer
-        pbCertEncoding = new jbyte[jCertEncodingSize];
+        pbCertEncoding = new (env) jbyte[jCertEncodingSize];
+        if (pbCertEncoding == NULL) {
+            __leave;
+        }
         env->GetByteArrayRegion(jCertEncoding, 0, jCertEncodingSize, pbCertEncoding);
 
         // Create a certificate context from the encoded cert
@@ -932,7 +979,10 @@
 
         // Set the certificate's friendly name
         int size = env->GetStringLength(jCertAliasName);
-        pszCertAliasName = new WCHAR[size + 1];
+        pszCertAliasName = new (env) WCHAR[size + 1];
+        if (pszCertAliasName == NULL) {
+            __leave;
+        }
 
         jCertAliasChars = env->GetStringChars(jCertAliasName, NULL);
         memcpy(pszCertAliasName, jCertAliasChars, size * sizeof(WCHAR));
@@ -970,7 +1020,10 @@
                 __leave;
             }
 
-            pszContainerName = new char[dwDataLen];
+            pszContainerName = new (env) char[dwDataLen];
+            if (pszContainerName == NULL) {
+                __leave;
+            }
 
             if (! ::CryptGetProvParam(
                 (HCRYPTPROV) hCryptProv,
@@ -984,7 +1037,10 @@
             }
 
             // Convert to a wide char string
-            pwszContainerName = new WCHAR[dwDataLen];
+            pwszContainerName = new (env) WCHAR[dwDataLen];
+            if (pwszContainerName == NULL) {
+                __leave;
+            }
 
             if (mbstowcs(pwszContainerName, pszContainerName, dwDataLen) == 0) {
                 ThrowException(env, KEYSTORE_EXCEPTION, GetLastError());
@@ -1007,7 +1063,10 @@
                 __leave;
             }
 
-            pszProviderName = new char[dwDataLen];
+            pszProviderName = new (env) char[dwDataLen];
+            if (pszProviderName == NULL) {
+                __leave;
+            }
 
             if (! ::CryptGetProvParam(
                 (HCRYPTPROV) hCryptProv,
@@ -1021,7 +1080,10 @@
             }
 
             // Convert to a wide char string
-            pwszProviderName = new WCHAR[dwDataLen];
+            pwszProviderName = new (env) WCHAR[dwDataLen];
+            if (pwszProviderName == NULL) {
+                __leave;
+            }
 
             if (mbstowcs(pwszProviderName, pszProviderName, dwDataLen) == 0) {
                 ThrowException(env, KEYSTORE_EXCEPTION, GetLastError());
@@ -1161,7 +1223,10 @@
         }
 
         // Copy encoding from Java to native buffer
-        pbCertEncoding = new jbyte[jCertEncodingSize];
+        pbCertEncoding = new (env) jbyte[jCertEncodingSize];
+        if (pbCertEncoding == NULL) {
+            __leave;
+        }
         env->GetByteArrayRegion(jCertEncoding, 0, jCertEncodingSize, pbCertEncoding);
 
         // Create a certificate context from the encoded cert
@@ -1184,7 +1249,10 @@
         if ((cchNameString = ::CertGetNameString(pTBDCertContext,
                 CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, NULL, 0)) > 1) {
 
-            pszNameString = new char[cchNameString];
+            pszNameString = new (env) char[cchNameString];
+            if (pszNameString == NULL) {
+                __leave;
+            }
 
             ::CertGetNameString(pTBDCertContext,
                 CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, pszNameString,
@@ -1334,7 +1402,10 @@
                 continue; // not found
             }
 
-            pszNameString = new char[cchNameString];
+            pszNameString = new (env) char[cchNameString];
+            if (pszNameString == NULL) {
+                __leave;
+            }
 
             if (::CertGetNameString(pCertContext,
                 CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, pszNameString,
@@ -1510,7 +1581,10 @@
     __try
     {
         // Copy data from Java buffer to native buffer
-        pData = new jbyte[dwBufLen];
+        pData = new (env) jbyte[dwBufLen];
+        if (pData == NULL) {
+            __leave;
+        }
         env->GetByteArrayRegion(jData, 0, dwBufLen, pData);
 
         if (doEncrypt == JNI_TRUE) {
@@ -1584,7 +1658,10 @@
             __leave;
         }
 
-        pbKeyBlob = new BYTE[dwBlobLen];
+        pbKeyBlob = new (env) BYTE[dwBlobLen];
+        if (pbKeyBlob == NULL) {
+            __leave;
+        }
 
         // Generate key blob
         if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0,
@@ -1638,8 +1715,12 @@
 
         RSAPUBKEY* pRsaPubKey =
             (RSAPUBKEY *) (keyBlob + sizeof(PUBLICKEYSTRUC));
+
         int len = sizeof(pRsaPubKey->pubexp);
-        exponentBytes = new jbyte[len];
+        exponentBytes = new (env) jbyte[len];
+        if (exponentBytes == NULL) {
+            __leave;
+        }
 
         // convert from little-endian while copying from blob
         for (int i = 0, j = len - 1; i < len; i++, j--) {
@@ -1690,9 +1771,12 @@
 
         RSAPUBKEY* pRsaPubKey =
             (RSAPUBKEY *) (keyBlob + sizeof(PUBLICKEYSTRUC));
+
         int len = pRsaPubKey->bitlen / 8;
-
-        modulusBytes = new jbyte[len];
+        modulusBytes = new (env) jbyte[len];
+        if (modulusBytes == NULL) {
+            __leave;
+        }
         BYTE * pbModulus =
             (BYTE *) (keyBlob + sizeof(PUBLICKEYSTRUC) + sizeof(RSAPUBKEY));
 
@@ -1813,12 +1897,16 @@
                         (jKeyBitLength / 8);
     }
 
-    jbyte* jBlobBytes = new jbyte[jBlobLength];
+    jbyte* jBlobBytes = NULL;
     jbyte* jBlobElement;
     jbyteArray jBlob = NULL;
     jsize  jElementLength;
 
     __try {
+        jBlobBytes = new (env) jbyte[jBlobLength];
+        if (jBlobBytes == NULL) {
+            __leave;
+        }
 
         BLOBHEADER *pBlobHeader = (BLOBHEADER *) jBlobBytes;
         if (bGeneratePrivateKeyBlob) {
--- a/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/Config.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/Config.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,6 @@
 
 import java.security.*;
 
-import sun.security.action.GetPropertyAction;
 import sun.security.util.PropertyExpander;
 
 import sun.security.pkcs11.wrapper.*;
@@ -58,15 +57,30 @@
     // will accept single threaded modules regardless of the setting in their
     // config files.
     private static final boolean staticAllowSingleThreadedModules;
+    private static final String osName;
+    private static final String osArch;
 
     static {
-        String p = "sun.security.pkcs11.allowSingleThreadedModules";
-        String s = AccessController.doPrivileged(new GetPropertyAction(p));
-        if ("false".equalsIgnoreCase(s)) {
+        List<String> props = AccessController.doPrivileged(
+            new PrivilegedAction<>() {
+                @Override
+                public List<String> run() {
+                    return List.of(
+                        System.getProperty(
+                            "sun.security.pkcs11.allowSingleThreadedModules",
+                            "true"),
+                        System.getProperty("os.name"),
+                        System.getProperty("os.arch"));
+                }
+            }
+        );
+        if ("false".equalsIgnoreCase(props.get(0))) {
             staticAllowSingleThreadedModules = false;
         } else {
             staticAllowSingleThreadedModules = true;
         }
+        osName = props.get(1);
+        osArch = props.get(2);
     }
 
     private final static boolean DEBUG = false;
@@ -650,8 +664,6 @@
             // replace "/$ISA/" with "/sparcv9/" on 64-bit Solaris SPARC
             // and with "/amd64/" on Solaris AMD64.
             // On all other platforms, just turn it into a "/"
-            String osName = System.getProperty("os.name", "");
-            String osArch = System.getProperty("os.arch", "");
             String prefix = lib.substring(0, i);
             String suffix = lib.substring(i + 5);
             if (osName.equals("SunOS") && osArch.equals("sparcv9")) {
--- a/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/wrapper/Constants.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/wrapper/Constants.java	Thu Oct 27 09:42:08 2016 -0700
@@ -58,7 +58,7 @@
  */
 public class Constants {
 
-    public static final String NEWLINE = System.getProperty("line.separator");
+    public static final String NEWLINE = System.lineSeparator();
 
     public static final String INDENT = "  ";
 
--- a/src/jdk.httpserver/share/classes/module-info.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.httpserver/share/classes/module-info.java	Thu Oct 27 09:42:08 2016 -0700
@@ -24,7 +24,6 @@
  */
 
 module jdk.httpserver {
-    requires java.logging;
 
     exports com.sun.net.httpserver;
     exports com.sun.net.httpserver.spi;
--- a/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java	Thu Oct 27 09:42:08 2016 -0700
@@ -29,7 +29,8 @@
 import java.net.*;
 import javax.net.ssl.*;
 import java.util.*;
-import java.util.logging.Logger;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
 import java.text.*;
 import com.sun.net.httpserver.*;
 
@@ -221,7 +222,7 @@
                 Logger logger = server.getLogger();
                 String msg = "sendResponseHeaders: rCode = "+ rCode
                     + ": forcing contentLen = -1";
-                logger.warning (msg);
+                logger.log (Level.WARNING, msg);
             }
             contentLen = -1;
         }
@@ -234,7 +235,7 @@
                 final Logger logger = server.getLogger();
                 String msg =
                     "sendResponseHeaders: being invoked with a content length for a HEAD request";
-                logger.warning (msg);
+                logger.log (Level.WARNING, msg);
             }
             noContentToSend = true;
             contentLen = 0;
--- a/src/jdk.httpserver/share/classes/sun/net/httpserver/HttpConnection.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/HttpConnection.java	Thu Oct 27 09:42:08 2016 -0700
@@ -28,7 +28,8 @@
 import java.io.*;
 import javax.net.ssl.*;
 import java.nio.channels.*;
-import java.util.logging.Logger;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
 import com.sun.net.httpserver.*;
 import com.sun.net.httpserver.spi.*;
 
@@ -119,7 +120,7 @@
         }
         closed = true;
         if (logger != null && chan != null) {
-            logger.finest ("Closing connection: " + chan.toString());
+            logger.log (Level.TRACE, "Closing connection: " + chan.toString());
         }
 
         if (!chan.isOpen()) {
--- a/src/jdk.httpserver/share/classes/sun/net/httpserver/HttpContextImpl.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/HttpContextImpl.java	Thu Oct 27 09:42:08 2016 -0700
@@ -26,7 +26,7 @@
 package sun.net.httpserver;
 import java.io.*;
 import java.util.*;
-import java.util.logging.Logger;
+import java.lang.System.Logger;
 import com.sun.net.httpserver.*;
 import com.sun.net.httpserver.spi.*;
 
--- a/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerConfig.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerConfig.java	Thu Oct 27 09:42:08 2016 -0700
@@ -25,7 +25,8 @@
 
 package sun.net.httpserver;
 
-import java.util.logging.Logger;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
 import java.security.PrivilegedAction;
 
 /**
@@ -115,7 +116,8 @@
                     if (System.getProperty("sun.net.httpserver.readTimeout")
                                                 !=null)
                     {
-                        logger.warning ("sun.net.httpserver.readTimeout "+
+                        logger.log (Level.WARNING,
+                            "sun.net.httpserver.readTimeout "+
                             "property is no longer used. "+
                             "Use sun.net.httpserver.maxReqTime instead."
                         );
@@ -123,7 +125,8 @@
                     if (System.getProperty("sun.net.httpserver.writeTimeout")
                                                 !=null)
                     {
-                        logger.warning ("sun.net.httpserver.writeTimeout "+
+                        logger.log (Level.WARNING,
+                            "sun.net.httpserver.writeTimeout "+
                             "property is no longer used. Use "+
                             "sun.net.httpserver.maxRspTime instead."
                         );
@@ -131,7 +134,8 @@
                     if (System.getProperty("sun.net.httpserver.selCacheTimeout")
                                                 !=null)
                     {
-                        logger.warning ("sun.net.httpserver.selCacheTimeout "+
+                        logger.log (Level.WARNING,
+                            "sun.net.httpserver.selCacheTimeout "+
                             "property is no longer used."
                         );
                     }
--- a/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java	Thu Oct 27 09:42:08 2016 -0700
@@ -30,8 +30,8 @@
 import java.nio.channels.*;
 import java.util.*;
 import java.util.concurrent.*;
-import java.util.logging.Logger;
-import java.util.logging.Level;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
 import javax.net.ssl.*;
 import com.sun.net.httpserver.*;
 import java.security.AccessController;
@@ -81,7 +81,7 @@
     final static boolean timer1Enabled = MAX_REQ_TIME != -1 || MAX_RSP_TIME != -1;
 
     private Timer timer, timer1;
-    private Logger logger;
+    private final Logger logger;
     private Thread dispatcherThread;
 
     ServerImpl (
@@ -90,7 +90,7 @@
 
         this.protocol = protocol;
         this.wrapper = wrapper;
-        this.logger = Logger.getLogger ("com.sun.net.httpserver");
+        this.logger = System.getLogger ("com.sun.net.httpserver");
         ServerConfig.checkLegacyProperties (logger);
         https = protocol.equalsIgnoreCase ("https");
         this.address = addr;
@@ -115,12 +115,12 @@
         if (timer1Enabled) {
             timer1 = new Timer ("server-timer1", true);
             timer1.schedule (new ServerTimerTask1(),TIMER_MILLIS,TIMER_MILLIS);
-            logger.config ("HttpServer timer1 enabled period in ms:  "+TIMER_MILLIS);
-            logger.config ("MAX_REQ_TIME:  "+MAX_REQ_TIME);
-            logger.config ("MAX_RSP_TIME:  "+MAX_RSP_TIME);
+            logger.log (Level.DEBUG, "HttpServer timer1 enabled period in ms: ", TIMER_MILLIS);
+            logger.log (Level.DEBUG, "MAX_REQ_TIME:  "+MAX_REQ_TIME);
+            logger.log (Level.DEBUG, "MAX_RSP_TIME:  "+MAX_RSP_TIME);
         }
         events = new LinkedList<Event>();
-        logger.config ("HttpServer created "+protocol+" "+ addr);
+        logger.log (Level.DEBUG, "HttpServer created "+protocol+" "+ addr);
     }
 
     public void bind (InetSocketAddress addr, int backlog) throws IOException {
@@ -211,7 +211,7 @@
                 dispatcherThread.join();
             } catch (InterruptedException e) {
                 Thread.currentThread().interrupt();
-                logger.log(Level.FINER, "ServerImpl.stop: ", e);
+                logger.log (Level.TRACE, "ServerImpl.stop: ", e);
             }
         }
     }
@@ -224,7 +224,7 @@
         }
         HttpContextImpl context = new HttpContextImpl (protocol, path, handler, this);
         contexts.add (context);
-        logger.config ("context created: " + path);
+        logger.log (Level.DEBUG, "context created: " + path);
         return context;
     }
 
@@ -234,7 +234,7 @@
         }
         HttpContextImpl context = new HttpContextImpl (protocol, path, null, this);
         contexts.add (context);
-        logger.config ("context created: " + path);
+        logger.log (Level.DEBUG, "context created: " + path);
         return context;
     }
 
@@ -243,7 +243,7 @@
             throw new NullPointerException ("null path parameter");
         }
         contexts.remove (protocol, path);
-        logger.config ("context removed: " + path);
+        logger.log (Level.DEBUG, "context removed: " + path);
     }
 
     public synchronized void removeContext (HttpContext context) throws IllegalArgumentException {
@@ -251,7 +251,7 @@
             throw new IllegalArgumentException ("wrong HttpContext type");
         }
         contexts.remove ((HttpContextImpl)context);
-        logger.config ("context removed: " + context.getPath());
+        logger.log (Level.DEBUG, "context removed: " + context.getPath());
     }
 
     public InetSocketAddress getAddress() {
@@ -310,7 +310,7 @@
                 }
             } catch (IOException e) {
                 logger.log (
-                    Level.FINER, "Dispatcher (1)", e
+                    Level.TRACE, "Dispatcher (1)", e
                 );
                 c.close();
             }
@@ -331,7 +331,7 @@
                 idleConnections.add (c);
             } catch (IOException e) {
                 dprint(e);
-                logger.log(Level.FINER, "Dispatcher(8)", e);
+                logger.log (Level.TRACE, "Dispatcher(8)", e);
                 c.close();
             }
         }
@@ -416,9 +416,9 @@
                     // call the selector just to process the cancelled keys
                     selector.selectNow();
                 } catch (IOException e) {
-                    logger.log (Level.FINER, "Dispatcher (4)", e);
+                    logger.log (Level.TRACE, "Dispatcher (4)", e);
                 } catch (Exception e) {
-                    logger.log (Level.FINER, "Dispatcher (7)", e);
+                    logger.log (Level.TRACE, "Dispatcher (7)", e);
                 }
             }
             try {selector.close(); } catch (Exception e) {}
@@ -427,7 +427,7 @@
         private void handleException (SelectionKey key, Exception e) {
             HttpConnection conn = (HttpConnection)key.attachment();
             if (e != null) {
-                logger.log (Level.FINER, "Dispatcher (2)", e);
+                logger.log (Level.TRACE, "Dispatcher (2)", e);
             }
             closeConnection(conn);
         }
@@ -439,10 +439,10 @@
                 Exchange t = new Exchange (chan, protocol, conn);
                 executor.execute (t);
             } catch (HttpError e1) {
-                logger.log (Level.FINER, "Dispatcher (4)", e1);
+                logger.log (Level.TRACE, "Dispatcher (4)", e1);
                 closeConnection(conn);
             } catch (IOException e) {
-                logger.log (Level.FINER, "Dispatcher (5)", e);
+                logger.log (Level.TRACE, "Dispatcher (5)", e);
                 closeConnection(conn);
             }
         }
@@ -522,7 +522,8 @@
                     newconnection = true;
                     if (https) {
                         if (sslContext == null) {
-                            logger.warning ("SSL connection received. No https contxt created");
+                            logger.log (Level.WARNING,
+                                "SSL connection received. No https contxt created");
                             throw new HttpError ("No SSL context established");
                         }
                         sslStreams = new SSLStreams (ServerImpl.this, sslContext, chan);
@@ -657,7 +658,7 @@
                 }
 
             } catch (IOException e1) {
-                logger.log (Level.FINER, "ServerImpl.Exchange (1)", e1);
+                logger.log (Level.TRACE, "ServerImpl.Exchange (1)", e1);
                 closeConnection(connection);
             } catch (NumberFormatException e3) {
                 reject (Code.HTTP_BAD_REQUEST,
@@ -666,7 +667,7 @@
                 reject (Code.HTTP_BAD_REQUEST,
                         requestLine, "URISyntaxException thrown");
             } catch (Exception e4) {
-                logger.log (Level.FINER, "ServerImpl.Exchange (2)", e4);
+                logger.log (Level.TRACE, "ServerImpl.Exchange (2)", e4);
                 closeConnection(connection);
             }
         }
@@ -722,7 +723,7 @@
                     closeConnection(connection);
                 }
             } catch (IOException e) {
-                logger.log (Level.FINER, "ServerImpl.sendReply", e);
+                logger.log (Level.TRACE, "ServerImpl.sendReply", e);
                 closeConnection(connection);
             }
         }
@@ -730,7 +731,7 @@
     }
 
     void logReply (int code, String requestStr, String text) {
-        if (!logger.isLoggable(Level.FINE)) {
+        if (!logger.isLoggable(Level.DEBUG)) {
             return;
         }
         if (text == null) {
@@ -744,7 +745,7 @@
         }
         String message = r + " [" + code + " " +
                     Code.msg(code) + "] ("+text+")";
-        logger.fine (message);
+        logger.log (Level.DEBUG, message);
     }
 
     long getTicks() {
@@ -843,7 +844,7 @@
                         }
                     }
                     for (HttpConnection c : toClose) {
-                        logger.log (Level.FINE, "closing: no request: " + c);
+                        logger.log (Level.DEBUG, "closing: no request: " + c);
                         reqConnections.remove (c);
                         allConnections.remove (c);
                         c.close();
@@ -859,7 +860,7 @@
                         }
                     }
                     for (HttpConnection c : toClose) {
-                        logger.log (Level.FINE, "closing: no response: " + c);
+                        logger.log (Level.DEBUG, "closing: no response: " + c);
                         rspConnections.remove (c);
                         allConnections.remove (c);
                         c.close();
@@ -870,13 +871,13 @@
     }
 
     void logStackTrace (String s) {
-        logger.finest (s);
+        logger.log (Level.TRACE, s);
         StringBuilder b = new StringBuilder ();
         StackTraceElement[] e = Thread.currentThread().getStackTrace();
         for (int i=0; i<e.length; i++) {
             b.append (e[i].toString()).append("\n");
         }
-        logger.finest (b.toString());
+        logger.log (Level.TRACE, b.toString());
     }
 
     static long getTimeMillis(long secs) {
--- a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java	Thu Oct 27 09:42:08 2016 -0700
@@ -50,6 +50,9 @@
 
 import jdk.security.jarsigner.JarSigner;
 import jdk.security.jarsigner.JarSignerException;
+import sun.security.pkcs.PKCS7;
+import sun.security.pkcs.SignerInfo;
+import sun.security.timestamp.TimestampToken;
 import sun.security.tools.KeyStoreUtil;
 import sun.security.x509.*;
 import sun.security.util.*;
@@ -87,6 +90,15 @@
 
     private static final long SIX_MONTHS = 180*24*60*60*1000L; //milliseconds
 
+    private static final DisabledAlgorithmConstraints DISABLED_CHECK =
+            new DisabledAlgorithmConstraints(
+                    DisabledAlgorithmConstraints.PROPERTY_JAR_DISABLED_ALGS);
+
+    private static final Set<CryptoPrimitive> DIGEST_PRIMITIVE_SET = Collections
+            .unmodifiableSet(EnumSet.of(CryptoPrimitive.MESSAGE_DIGEST));
+    private static final Set<CryptoPrimitive> SIG_PRIMITIVE_SET = Collections
+            .unmodifiableSet(EnumSet.of(CryptoPrimitive.SIGNATURE));
+
     // Attention:
     // This is the entry that get launched by the security tool jarsigner.
     public static void main(String args[]) throws Exception {
@@ -163,6 +175,8 @@
 
     private Throwable chainNotValidatedReason = null;
 
+    private boolean seeWeak = false;
+
     CertificateFactory certificateFactory;
     CertPathValidator validator;
     PKIXParameters pkixParameters;
@@ -628,6 +642,10 @@
     {
         boolean anySigned = false;  // if there exists entry inside jar signed
         JarFile jf = null;
+        Map<String,String> digestMap = new HashMap<>();
+        Map<String,PKCS7> sigMap = new HashMap<>();
+        Map<String,String> sigNameMap = new HashMap<>();
+        Map<String,String> unparsableSignatures = new HashMap<>();
 
         try {
             jf = new JarFile(jarName, true);
@@ -638,16 +656,44 @@
             while (entries.hasMoreElements()) {
                 JarEntry je = entries.nextElement();
                 entriesVec.addElement(je);
-                InputStream is = null;
-                try {
-                    is = jf.getInputStream(je);
-                    while (is.read(buffer, 0, buffer.length) != -1) {
-                        // we just read. this will throw a SecurityException
-                        // if  a signature/digest check fails.
-                    }
-                } finally {
-                    if (is != null) {
-                        is.close();
+                try (InputStream is = jf.getInputStream(je)) {
+                    String name = je.getName();
+                    if (signatureRelated(name)
+                            && SignatureFileVerifier.isBlockOrSF(name)) {
+                        String alias = name.substring(name.lastIndexOf('/') + 1,
+                                name.lastIndexOf('.'));
+                        try {
+                            if (name.endsWith(".SF")) {
+                                Manifest sf = new Manifest(is);
+                                boolean found = false;
+                                for (Object obj : sf.getMainAttributes().keySet()) {
+                                    String key = obj.toString();
+                                    if (key.endsWith("-Digest-Manifest")) {
+                                        digestMap.put(alias,
+                                                key.substring(0, key.length() - 16));
+                                        found = true;
+                                        break;
+                                    }
+                                }
+                                if (!found) {
+                                    unparsableSignatures.putIfAbsent(alias,
+                                        String.format(
+                                            rb.getString("history.unparsable"),
+                                            name));
+                                }
+                            } else {
+                                sigNameMap.put(alias, name);
+                                sigMap.put(alias, new PKCS7(is));
+                            }
+                        } catch (IOException ioe) {
+                            unparsableSignatures.putIfAbsent(alias, String.format(
+                                    rb.getString("history.unparsable"), name));
+                        }
+                    } else {
+                        while (is.read(buffer, 0, buffer.length) != -1) {
+                            // we just read. this will throw a SecurityException
+                            // if  a signature/digest check fails.
+                        }
                     }
                 }
             }
@@ -805,10 +851,11 @@
                     System.out.println(rb.getString(
                         ".X.not.signed.by.specified.alias.es."));
                 }
+            }
+            if (man == null) {
                 System.out.println();
+                System.out.println(rb.getString("no.manifest."));
             }
-            if (man == null)
-                System.out.println(rb.getString("no.manifest."));
 
             // If signer is a trusted cert or private entry in user's own
             // keystore, it can be self-signed.
@@ -816,8 +863,99 @@
                 signerSelfSigned = false;
             }
 
+            // Even if the verbose option is not specified, all out strings
+            // must be generated so seeWeak can be updated.
+            if (!digestMap.isEmpty()
+                    || !sigMap.isEmpty()
+                    || !unparsableSignatures.isEmpty()) {
+                if (verbose != null) {
+                    System.out.println();
+                }
+                for (String s : sigMap.keySet()) {
+                    if (!digestMap.containsKey(s)) {
+                        unparsableSignatures.putIfAbsent(s, String.format(
+                                rb.getString("history.nosf"), s));
+                    }
+                }
+                for (String s : digestMap.keySet()) {
+                    PKCS7 p7 = sigMap.get(s);
+                    if (p7 != null) {
+                        String history;
+                        try {
+                            SignerInfo si = p7.getSignerInfos()[0];
+                            X509Certificate signer = si.getCertificate(p7);
+                            String digestAlg = digestMap.get(s);
+                            String sigAlg = AlgorithmId.makeSigAlg(
+                                    si.getDigestAlgorithmId().getName(),
+                                    si.getDigestEncryptionAlgorithmId().getName());
+                            PublicKey key = signer.getPublicKey();
+                            PKCS7 tsToken = si.getTsToken();
+                            if (tsToken != null) {
+                                SignerInfo tsSi = tsToken.getSignerInfos()[0];
+                                X509Certificate tsSigner = tsSi.getCertificate(tsToken);
+                                byte[] encTsTokenInfo = tsToken.getContentInfo().getData();
+                                TimestampToken tsTokenInfo = new TimestampToken(encTsTokenInfo);
+                                PublicKey tsKey = tsSigner.getPublicKey();
+                                String tsDigestAlg = tsTokenInfo.getHashAlgorithm().getName();
+                                String tsSigAlg = AlgorithmId.makeSigAlg(
+                                        tsSi.getDigestAlgorithmId().getName(),
+                                        tsSi.getDigestEncryptionAlgorithmId().getName());
+                                Calendar c = Calendar.getInstance(
+                                        TimeZone.getTimeZone("UTC"),
+                                        Locale.getDefault(Locale.Category.FORMAT));
+                                c.setTime(tsTokenInfo.getDate());
+                                history = String.format(
+                                        rb.getString("history.with.ts"),
+                                        signer.getSubjectX500Principal(),
+                                        withWeak(digestAlg, DIGEST_PRIMITIVE_SET),
+                                        withWeak(sigAlg, SIG_PRIMITIVE_SET),
+                                        withWeak(key),
+                                        c,
+                                        tsSigner.getSubjectX500Principal(),
+                                        withWeak(tsDigestAlg, DIGEST_PRIMITIVE_SET),
+                                        withWeak(tsSigAlg, SIG_PRIMITIVE_SET),
+                                        withWeak(tsKey));
+                            } else {
+                                history = String.format(
+                                        rb.getString("history.without.ts"),
+                                        signer.getSubjectX500Principal(),
+                                        withWeak(digestAlg, DIGEST_PRIMITIVE_SET),
+                                        withWeak(sigAlg, SIG_PRIMITIVE_SET),
+                                        withWeak(key));
+                            }
+                        } catch (Exception e) {
+                            // The only usage of sigNameMap, remember the name
+                            // of the block file if it's invalid.
+                            history = String.format(
+                                    rb.getString("history.unparsable"),
+                                    sigNameMap.get(s));
+                        }
+                        if (verbose != null) {
+                            System.out.println(history);
+                        }
+                    } else {
+                        unparsableSignatures.putIfAbsent(s, String.format(
+                                rb.getString("history.nobk"), s));
+                    }
+                }
+                if (verbose != null) {
+                    for (String s : unparsableSignatures.keySet()) {
+                        System.out.println(unparsableSignatures.get(s));
+                    }
+                }
+            }
+            System.out.println();
             if (!anySigned) {
-                if (hasSignature) {
+                if (seeWeak) {
+                    if (verbose != null) {
+                        System.out.println(rb.getString("jar.treated.unsigned.see.weak.verbose"));
+                        System.out.println("\n  " +
+                                DisabledAlgorithmConstraints.PROPERTY_JAR_DISABLED_ALGS +
+                                "=" + Security.getProperty(DisabledAlgorithmConstraints.PROPERTY_JAR_DISABLED_ALGS));
+                    } else {
+                        System.out.println(rb.getString("jar.treated.unsigned.see.weak"));
+                    }
+                } else if (hasSignature) {
                     System.out.println(rb.getString("jar.treated.unsigned"));
                 } else {
                     System.out.println(rb.getString("jar.is.unsigned"));
@@ -845,7 +983,9 @@
                     if (weakAlg != 0) {
                         // In fact, jarsigner verification did not catch this
                         // since it has not read the JarFile content itself.
-                        // Everything is done with JarFile API.
+                        // Everything is done with JarFile API. The signing
+                        // history (digestMap etc) will show these info and
+                        // print out proper warnings.
                     }
 
                     if (badKeyUsage) {
@@ -936,6 +1076,26 @@
         System.exit(1);
     }
 
+    private String withWeak(String alg, Set<CryptoPrimitive> primitiveSet) {
+        if (DISABLED_CHECK.permits(primitiveSet, alg, null)) {
+            return alg;
+        } else {
+            seeWeak = true;
+            return String.format(rb.getString("with.weak"), alg);
+        }
+    }
+
+    private String withWeak(PublicKey key) {
+        if (DISABLED_CHECK.permits(SIG_PRIMITIVE_SET, key)) {
+            return String.format(
+                    rb.getString("key.bit"), KeyUtil.getKeySize(key));
+        } else {
+            seeWeak = true;
+            return String.format(
+                    rb.getString("key.bit.weak"), KeyUtil.getKeySize(key));
+        }
+    }
+
     private static MessageFormat validityTimeForm = null;
     private static MessageFormat notYetTimeForm = null;
     private static MessageFormat expiredTimeForm = null;
@@ -1125,22 +1285,22 @@
     void signJar(String jarName, String alias)
             throws Exception {
 
-        DisabledAlgorithmConstraints dac =
-                new DisabledAlgorithmConstraints(
-                        DisabledAlgorithmConstraints.PROPERTY_CERTPATH_DISABLED_ALGS);
-
-        if (digestalg != null && !dac.permits(
-                Collections.singleton(CryptoPrimitive.MESSAGE_DIGEST), digestalg, null)) {
+        if (digestalg != null && !DISABLED_CHECK.permits(
+                DIGEST_PRIMITIVE_SET, digestalg, null)) {
             weakAlg |= 1;
         }
-        if (tSADigestAlg != null && !dac.permits(
-                Collections.singleton(CryptoPrimitive.MESSAGE_DIGEST), tSADigestAlg, null)) {
+        if (tSADigestAlg != null && !DISABLED_CHECK.permits(
+                DIGEST_PRIMITIVE_SET, tSADigestAlg, null)) {
             weakAlg |= 4;
         }
-        if (sigalg != null && !dac.permits(
-                Collections.singleton(CryptoPrimitive.SIGNATURE), sigalg, null)) {
+        if (sigalg != null && !DISABLED_CHECK.permits(
+                SIG_PRIMITIVE_SET , sigalg, null)) {
             weakAlg |= 2;
         }
+        if (!DISABLED_CHECK.permits(
+                SIG_PRIMITIVE_SET, privateKey)) {
+            weakAlg |= 8;
+        }
 
         boolean aliasUsed = false;
         X509Certificate tsaCert = null;
@@ -1385,6 +1545,11 @@
                             rb.getString("The.1.algorithm.specified.for.the.2.option.is.considered.a.security.risk."),
                             tSADigestAlg, "-tsadigestalg"));
                 }
+                if ((weakAlg & 8) == 8) {
+                    System.out.println(String.format(
+                            rb.getString("The.1.signing.key.has.a.keysize.of.2.which.is.considered.a.security.risk."),
+                            privateKey.getAlgorithm(), KeyUtil.getKeySize(privateKey)));
+                }
             } else {
                 System.out.println(rb.getString("jar.signed."));
             }
--- a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java	Thu Oct 27 09:42:08 2016 -0700
@@ -145,11 +145,26 @@
         {"jar.is.unsigned",
                 "jar is unsigned."},
         {"jar.treated.unsigned",
-                "Signature not parsable or verifiable. The jar will be treated as unsigned. The jar may have been signed with a weak algorithm that is now disabled. For more information, rerun jarsigner with debug enabled (-J-Djava.security.debug=jar)."},
+                "WARNING: Signature is either not parsable or not verifiable, and the jar will be treated as unsigned. For more information, re-run jarsigner with debug enabled (-J-Djava.security.debug=jar)."},
+        {"jar.treated.unsigned.see.weak",
+                "The jar will be treated as unsigned, because it is signed with a weak algorithm that is now disabled.\n\nRe-run jarsigner with the -verbose option for more details."},
+        {"jar.treated.unsigned.see.weak.verbose",
+                "WARNING: The jar will be treated as unsigned, because it is signed with a weak algorithm that is now disabled by the security property:"},
         {"jar.signed.", "jar signed."},
         {"jar.signed.with.signer.errors.", "jar signed, with signer errors."},
         {"jar.verified.", "jar verified."},
         {"jar.verified.with.signer.errors.", "jar verified, with signer errors."},
+
+        {"history.with.ts", "- Signed by \"%1$s\"\n    Digest algorithm: %2$s\n    Signature algorithm: %3$s, %4$s\n  Timestamped by \"%6$s\" on %5$tc\n    Timestamp digest algorithm: %7$s\n    Timestamp signature algorithm: %8$s, %9$s"},
+        {"history.without.ts", "- Signed by \"%1$s\"\n    Digest algorithm: %2$s\n    Signature algorithm: %3$s, %4$s"},
+        {"history.unparsable", "- Unparsable signature-related file %s"},
+        {"history.nosf", "- Missing signature-related file META-INF/%s.SF"},
+        {"history.nobk", "- Missing block file for signature-related file META-INF/%s.SF"},
+
+        {"with.weak", "%s (weak)"},
+        {"key.bit", "%d-bit key"},
+        {"key.bit.weak", "%d-bit key (weak)"},
+
         {"jarsigner.", "jarsigner: "},
         {"signature.filename.must.consist.of.the.following.characters.A.Z.0.9.or.",
                 "signature filename must consist of the following characters: A-Z, 0-9, _ or -"},
@@ -248,6 +263,8 @@
                 "The signer's certificate is self-signed."},
         {"The.1.algorithm.specified.for.the.2.option.is.considered.a.security.risk.",
                 "The %1$s algorithm specified for the %2$s option is considered a security risk."},
+        {"The.1.signing.key.has.a.keysize.of.2.which.is.considered.a.security.risk.",
+                "The %s signing key has a keysize of %d which is considered a security risk."},
         {"This.jar.contains.entries.whose.certificate.chain.is.not.validated.reason.1",
                  "This jar contains entries whose certificate chain is not validated. Reason: %s"},
         {"no.timestamp.signing",
--- a/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Thu Oct 27 09:42:08 2016 -0700
@@ -80,6 +80,7 @@
     String fname, mname, ename;
     String zname = "";
     String rootjar = null;
+    Set<String> concealedPackages = new HashSet<>();
 
     private static final int BASE_VERSION = 0;
 
@@ -821,22 +822,21 @@
         return true;
     }
 
-    private static Set<String> findPackages(ZipFile zf) {
-        return zf.stream()
-                 .filter(e -> e.getName().endsWith(".class"))
-                 .map(e -> toPackageName(e))
-                 .filter(pkg -> pkg.length() > 0)
-                 .distinct()
-                 .collect(Collectors.toSet());
-    }
-
     private static String toPackageName(ZipEntry entry) {
         return toPackageName(entry.getName());
     }
 
     private static String toPackageName(String path) {
         assert path.endsWith(".class");
-        int index = path.lastIndexOf('/');
+        int index;
+        if (path.startsWith(VERSIONS_DIR)) {
+            index = path.indexOf('/', VERSIONS_DIR.length());
+            if (index <= 0) {
+                return "";
+            }
+            path = path.substring(index + 1);
+        }
+        index = path.lastIndexOf('/');
         if (index != -1) {
             return path.substring(0, index).replace('/', '.');
         } else {
@@ -875,7 +875,7 @@
                         entryMap.put(entryName, entry);
                 } else if (entries.add(entry)) {
                     jarEntries.add(entryName);
-                    if (entry.basename.endsWith(".class") && !entryName.startsWith(VERSIONS_DIR))
+                    if (entry.basename.endsWith(".class"))
                         packages.add(toPackageName(entry.basename));
                     if (isUpdate)
                         entryMap.put(entryName, entry);
@@ -1068,7 +1068,7 @@
                 }
 
                 jarEntries.add(name);
-                if (name.endsWith(".class") && !(name.startsWith(VERSIONS_DIR)))
+                if (name.endsWith(".class"))
                     packages.add(toPackageName(name));
             }
         }
@@ -1762,6 +1762,13 @@
     }
 
     /**
+     * Print a warning message
+     */
+    void warn(String s) {
+        err.println(s);
+    }
+
+    /**
      * Main routine to start program.
      */
     public static void main(String args[]) {
@@ -1975,24 +1982,30 @@
         ByteBuffer bb = ByteBuffer.wrap(moduleInfos.get(MODULE_INFO));
         ModuleDescriptor rd = ModuleDescriptor.read(bb);
 
-        Set<String> exports = rd.exports()
-                                .stream()
-                                .map(Exports::source)
-                                .collect(toSet());
-
-        Set<String> conceals = packages.stream()
-                                       .filter(p -> !exports.contains(p))
-                                       .collect(toSet());
+        concealedPackages = findConcealedPackages(rd);
 
         for (Map.Entry<String,byte[]> e: moduleInfos.entrySet()) {
             ModuleDescriptor vd = ModuleDescriptor.read(ByteBuffer.wrap(e.getValue()));
             if (!(isValidVersionedDescriptor(vd, rd)))
                 return false;
-            e.setValue(extendedInfoBytes(rd, vd, e.getValue(), conceals));
+            e.setValue(extendedInfoBytes(rd, vd, e.getValue(), concealedPackages));
         }
         return true;
     }
 
+    private Set<String> findConcealedPackages(ModuleDescriptor md){
+        Objects.requireNonNull(md);
+
+        Set<String> exports = md.exports()
+                .stream()
+                .map(Exports::source)
+                .collect(toSet());
+
+        return packages.stream()
+                .filter(p -> !exports.contains(p))
+                .collect(toSet());
+    }
+
     private static boolean isPlatformModule(String name) {
         return name.startsWith("java.") || name.startsWith("jdk.");
     }
--- a/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java	Thu Oct 27 09:42:08 2016 -0700
@@ -152,9 +152,13 @@
                     return;
                 }
                 if (fp.isPublicClass()) {
-                    main.error(Main.formatMsg("error.validator.new.public.class", entryName));
-                    isValid = false;
-                    return;
+                    if (!isConcealed(internalName)) {
+                        main.error(Main.formatMsg("error.validator.new.public.class", entryName));
+                        isValid = false;
+                        return;
+                    }
+                    main.warn(Main.formatMsg("warn.validator.concealed.public.class", entryName));
+                    debug("%s is a public class entry in a concealed package", entryName);
                 }
                 debug("%s is a non-public class entry", entryName);
                 fps.put(internalName, fp);
@@ -169,7 +173,7 @@
 
         // are the two classes/resources identical?
         if (fp.isIdentical(matchFp)) {
-            main.error(Main.formatMsg("error.validator.identical.entry", entryName));
+            main.warn(Main.formatMsg("warn.validator.identical.entry", entryName));
             return;  // it's okay, just takes up room
         }
         debug("sha1 not equal -- different bytes");
@@ -204,7 +208,7 @@
         }
         debug("%s is a resource", entryName);
 
-        main.error(Main.formatMsg("error.validator.resources.with.same.name", entryName));
+        main.warn(Main.formatMsg("warn.validator.resources.with.same.name", entryName));
         fps.put(internalName, fp);
         return;
     }
@@ -235,6 +239,15 @@
         return entryName.endsWith(".class") ? entryName.substring(0, entryName.length() - 6) : null;
     }
 
+    private boolean isConcealed(String internalName) {
+        if (main.concealedPackages.isEmpty()) {
+            return false;
+        }
+        int idx = internalName.lastIndexOf('/');
+        String pkgName = idx != -1 ? internalName.substring(0, idx).replace('/', '.') : "";
+        return main.concealedPackages.contains(pkgName);
+    }
+
     private void debug(String fmt, Object... args) {
         if (DEBUG) System.err.format(fmt, args);
     }
--- a/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Thu Oct 27 09:42:08 2016 -0700
@@ -99,16 +99,19 @@
         entry: {0}, is an isolated nested class
 error.validator.new.public.class=\
         entry: {0}, contains a new public class not found in base entries
-error.validator.identical.entry=\
-        warning - entry: {0} contains a class that is identical to an entry already in the jar
 error.validator.incompatible.class.version=\
         entry: {0}, has a class version incompatible with an earlier version
 error.validator.different.api=\
         entry: {0}, contains a class with different api from earlier version
-error.validator.resources.with.same.name=\
-         warning - entry: {0}, multiple resources with same name
 error.validator.names.mismatch=\
          entry: {0}, contains a class with internal name {1}, names do not match
+warn.validator.identical.entry=\
+        warning - entry: {0} contains a class that is identical to an entry already in the jar
+warn.validator.resources.with.same.name=\
+         warning - entry: {0}, multiple resources with same name
+warn.validator.concealed.public.class=\
+         warning - entry {0} is a public class in a concealed package, \n\
+         placing this jar on the class path will result in incompatible public interfaces
 out.added.manifest=\
         added manifest
 out.added.module-info=\
--- a/src/jdk.jdi/share/classes/com/sun/jdi/ObjectReference.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.jdi/share/classes/com/sun/jdi/ObjectReference.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -246,9 +246,9 @@
      * @throws java.lang.IllegalArgumentException if the method is not
      * a member of this object's class, if the size of the argument list
      * does not match the number of declared arguments for the method,
-     * if the method is a constructor or static intializer, or
+     * if the method is a constructor or static initializer, or
      * if {@link #INVOKE_NONVIRTUAL} is specified and the method is
-     * either abstract or a non-default interface member.
+     * abstract.
      * @throws {@link InvalidTypeException} if any argument in the
      * argument list is not assignable to the corresponding method argument
      * type.
--- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -347,10 +347,12 @@
                                          throws InvalidTypeException,
                                          InvocationException {
         /*
-         * Only default methods allowed for nonvirtual invokes
+         * For nonvirtual invokes, method must have a body
          */
-        if (isNonVirtual(options) && !method.isDefault()) {
-            throw new IllegalArgumentException("Not a default method");
+        if (isNonVirtual(options)) {
+            if (method.isAbstract()) {
+                throw new IllegalArgumentException("Abstract method");
+            }
         }
     }
 
--- a/src/jdk.jdi/share/classes/module-info.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.jdi/share/classes/module-info.java	Thu Oct 27 09:42:08 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,6 @@
     exports com.sun.jdi.connect.spi;
     exports com.sun.jdi.event;
     exports com.sun.jdi.request;
-    exports com.sun.tools.jdi to jdk.hotspot.agent;
 
     uses com.sun.jdi.connect.Connector;
     uses com.sun.jdi.connect.spi.TransportService;
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Thu Oct 27 09:42:08 2016 -0700
@@ -186,7 +186,7 @@
                    new PrintWriter(System.err, true));
         }
         try {
-            optionsHelper.handleOptions(this, args);
+            optionsHelper.handleOptionsNoUnhandled(this, args);
             if (options.help) {
                 optionsHelper.showHelp(PROGNAME);
                 return EXIT_OK;
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Thu Oct 27 09:42:08 2016 -0700
@@ -466,7 +466,21 @@
             return pp;
         }
 
+        // used by jimage. Return unhandled arguments like "create", "describe".
         public List<String> handleOptions(T task, String[] args) throws BadArgs {
+            return handleOptions(task, args, true);
+        }
+
+        // used by jlink. No unhandled arguments like "create", "describe".
+        void handleOptionsNoUnhandled(T task, String[] args) throws BadArgs {
+            handleOptions(task, args, false);
+        }
+
+        // shared code that handles options for both jlink and jimage. jimage uses arguments like
+        // "create", "describe" etc. as "task names". Those arguments are unhandled here and returned
+        // as "unhandled arguments list". jlink does not want such arguments. "collectUnhandled" flag
+        // tells whether to allow for unhandled arguments or not.
+        private List<String> handleOptions(T task, String[] args, boolean collectUnhandled) throws BadArgs {
             // findbugs warning, copy instead of keeping a reference.
             command = Arrays.copyOf(args, args.length);
 
@@ -499,10 +513,10 @@
             String[] arr = new String[filteredArgs.size()];
             args = filteredArgs.toArray(arr);
 
-            List<String> rest = new ArrayList<>();
+            List<String> rest = collectUnhandled? new ArrayList<>() : null;
             // process options
             for (int i = 0; i < args.length; i++) {
-                if (!args[i].isEmpty() && args[i].charAt(0) == '-') {
+                if (args[i].charAt(0) == '-') {
                     String name = args[i];
                     PlugOption pluginOption = null;
                     Option<T> option = getOption(name);
@@ -539,7 +553,12 @@
                         i = args.length;
                     }
                 } else {
-                    rest.add(args[i]);
+                    if (collectUnhandled) {
+                        rest.add(args[i]);
+                    } else {
+                        throw new BadArgs("err.orphan.argument", args[i]).
+                            showUsage(true);
+                    }
                 }
             }
             return rest;
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Thu Oct 27 09:42:08 2016 -0700
@@ -95,6 +95,7 @@
 err.dir.exists={0} already exists
 err.badpattern=bad pattern {0}
 err.unknown.option=unknown option: {0}
+err.orphan.argument=orphan argument: {0}
 err.missing.arg=no value given for {0}
 err.internal.error=internal error: {0} {1} {2}
 err.invalid.arg.for.option=invalid argument for option: {0}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/BreakIteratorResources_th.java	Thu Oct 27 09:42:08 2016 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.text.resources.ext;
+
+import java.util.ResourceBundle;
+import sun.util.resources.BreakIteratorResourceBundle;
+
+public class BreakIteratorResources_th extends BreakIteratorResourceBundle {
+    @Override
+    protected ResourceBundle getBreakIteratorInfo() {
+        return new BreakIteratorInfo_th();
+    }
+}
--- a/src/jdk.unsupported/share/classes/sun/reflect/ReflectionFactory.java	Thu Oct 27 09:38:46 2016 -0700
+++ b/src/jdk.unsupported/share/classes/sun/reflect/ReflectionFactory.java	Thu Oct 27 09:42:08 2016 -0700
@@ -25,24 +25,34 @@
 
 package sun.reflect;
 
+import java.io.OptionalDataException;
+import java.lang.invoke.MethodHandle;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.security.AccessController;
 import java.security.Permission;
 import java.security.PrivilegedAction;
 
+/**
+ * ReflectionFactory supports custom serialization.
+ * Its methods support the creation of uninitialized objects, invoking serialization
+ * private methods for readObject, writeObject, readResolve, and writeReplace.
+ * <p>
+ * ReflectionFactory access is restricted, if a security manager is active,
+ * unless the permission {@code RuntimePermission("reflectionFactoryAccess")}
+ * is granted.
+ */
 public class ReflectionFactory {
 
     private static final ReflectionFactory soleInstance = new ReflectionFactory();
-    private final jdk.internal.reflect.ReflectionFactory delegate;
-
-    private ReflectionFactory() {
-        delegate = AccessController.doPrivileged(
+    private static final jdk.internal.reflect.ReflectionFactory delegate = AccessController.doPrivileged(
             new PrivilegedAction<jdk.internal.reflect.ReflectionFactory>() {
                 public jdk.internal.reflect.ReflectionFactory run() {
                     return jdk.internal.reflect.ReflectionFactory.getReflectionFactory();
                 }
-        });
-    }
+            });
+
+    private ReflectionFactory() {}
 
     private static final Permission REFLECTION_FACTORY_ACCESS_PERM
             = new RuntimePermission("reflectionFactoryAccess");
@@ -53,7 +63,7 @@
      *
      * <p> First, if there is a security manager, its {@code checkPermission}
      * method is called with a {@link java.lang.RuntimePermission} with target
-     * {@code "reflectionFactoryAccess"}.  This may result in a securit
+     * {@code "reflectionFactoryAccess"}.  This may result in a security
      * exception.
      *
      * <p> The returned {@code ReflectionFactory} object should be carefully
@@ -61,6 +71,7 @@
      * data and invoke private methods, as well as to load unverified bytecodes.
      * It must never be passed to untrusted code.
      *
+     * @return the ReflectionFactory
      * @throws SecurityException if a security manager exists and its
      *         {@code checkPermission} method doesn't allow access to
      *         the RuntimePermission "reflectionFactoryAccess".
@@ -73,11 +84,129 @@
         return soleInstance;
     }
 
-    public Constructor<?> newConstructorForSerialization(Class<?> classToInstantiate,
-                                                         Constructor<?> constructorToCall)
+    /**
+     * Returns an accessible no-arg constructor for a class.
+     * The no-arg constructor is found searching the class and its supertypes.
+     *
+     * @param cl the class to instantiate
+     * @return a no-arg constructor for the class or {@code null} if
+     *     the class or supertypes do not have a suitable no-arg constructor
+     */
+    public final Constructor<?> newConstructorForSerialization(Class<?> cl)
     {
-        return delegate.newConstructorForSerialization(classToInstantiate,
-                                                       constructorToCall);
+        return delegate.newConstructorForSerialization(cl);
+    }
+
+    /**
+     * Returns an accessible no-arg constructor for an externalizable class to be
+     * initialized using a public no-argument constructor.
+     *
+     * @param cl the class to instantiate
+     * @return A no-arg constructor for the class; returns {@code null} if
+     *     the class does not implement {@link java.io.Externalizable}
+     */
+    public final Constructor<?> newConstructorForExternalization(Class<?> cl) {
+        return delegate.newConstructorForExternalization(cl);
+    }
+
+    /**
+     * Returns a direct MethodHandle for the {@code readObject} method on
+     * a Serializable class.
+     * The first argument of {@link MethodHandle#invoke} is the serializable
+     * object and the second argument is the {@code ObjectInputStream} passed to
+     * {@code readObject}.
+     *
+     * @param cl a Serializable class
+     * @return  a direct MethodHandle for the {@code readObject} method of the class or
+     *          {@code null} if the class does not have a {@code readObject} method
+     */
+    public final MethodHandle readObjectForSerialization(Class<?> cl) {
+        return delegate.readObjectForSerialization(cl);
+    }
+
+    /**
+     * Returns a direct MethodHandle for the {@code readObjectNoData} method on
+     * a Serializable class.
+     * The first argument of {@link MethodHandle#invoke} is the serializable
+     * object and the second argument is the {@code ObjectInputStream} passed to
+     * {@code readObjectNoData}.
+     *
+     * @param cl a Serializable class
+     * @return  a direct MethodHandle for the {@code readObjectNoData} method
+     *          of the class or {@code null} if the class does not have a
+     *          {@code readObjectNoData} method
+     */
+    public final MethodHandle readObjectNoDataForSerialization(Class<?> cl) {
+        return delegate.readObjectNoDataForSerialization(cl);
+    }
+
+    /**
+     * Returns a direct MethodHandle for the {@code writeObject} method on
+     * a Serializable class.
+     * The first argument of {@link MethodHandle#invoke} is the serializable
+     * object and the second argument is the {@code ObjectOutputStream} passed to
+     * {@code writeObject}.
+     *
+     * @param cl a Serializable class
+     * @return  a direct MethodHandle for the {@code writeObject} method of the class or
+     *          {@code null} if the class does not have a {@code writeObject} method
+     */
+    public final MethodHandle writeObjectForSerialization(Class<?> cl) {
+        return delegate.writeObjectForSerialization(cl);
+    }
+
+    /**
+     * Returns a direct MethodHandle for the {@code readResolve} method on
+     * a serializable class.
+     * The single argument of {@link MethodHandle#invoke} is the serializable
+     * object.
+     *
+     * @param cl the Serializable class
+     * @return  a direct MethodHandle for the {@code readResolve} method of the class or
+     *          {@code null} if the class does not have a {@code readResolve} method
+     */
+    public final MethodHandle readResolveForSerialization(Class<?> cl) {
+        return delegate.readResolveForSerialization(cl);
+    }
+
+    /**
+     * Returns a direct MethodHandle for the {@code writeReplace} method on
+     * a serializable class.
+     * The single argument of {@link MethodHandle#invoke} is the serializable
+     * object.
+     *
+     * @param cl the Serializable class
+     * @return  a direct MethodHandle for the {@code writeReplace} method of the class or
+     *          {@code null} if the class does not have a {@code writeReplace} method
+     */
+    public final MethodHandle writeReplaceForSerialization(Class<?> cl) {
+        return delegate.writeReplaceForSerialization(cl);
+    }
+
+    /**
+     * Returns true if the class has a static initializer.
+     * The presence of a static initializer is used to compute the serialVersionUID.
+     * @param cl a serializable class
+     * @return {@code true} if the class has a static initializer,
+     *          otherwise {@code false}
+     */
+    public final boolean hasStaticInitializerForSerialization(Class<?> cl) {
+        return delegate.hasStaticInitializerForSerialization(cl);
+    }
+
+    /**
+     * Returns a new OptionalDataException with {@code eof} set to {@code true}
+     * or {@code false}.
+     * @param bool the value of {@code eof} in the created OptionalDataException
+     * @return  a new OptionalDataException
+     */
+    public final OptionalDataException newOptionalDataExceptionForSerialization(boolean bool) {
+        Constructor<OptionalDataException> cons = delegate.newOptionalDataExceptionForSerialization();
+        try {
+            return cons.newInstance(bool);
+        } catch (InstantiationException|IllegalAccessException|InvocationTargetException ex) {
+            throw new InternalError("unable to create OptionalDataException", ex);
+        }
     }
 }
 
--- a/test/ProblemList.txt	Thu Oct 27 09:38:46 2016 -0700
+++ b/test/ProblemList.txt	Thu Oct 27 09:42:08 2016 -0700
@@ -134,8 +134,6 @@
 
 java/lang/instrument/BootClassPath/BootClassPathTest.sh         8072130 macosx-all
 
-java/lang/instrument/DaemonThread/TestDaemonThread.java         8167001 generic-all
-
 java/lang/management/MemoryMXBean/Pending.java                  8158837 generic-all
 java/lang/management/MemoryMXBean/PendingAllGC.sh               8158760 generic-all
 
--- a/test/TEST.groups	Thu Oct 27 09:38:46 2016 -0700
+++ b/test/TEST.groups	Thu Oct 27 09:42:08 2016 -0700
@@ -158,6 +158,7 @@
 
 jdk_net = \
     java/net \
+    -java/net/httpclient \
     com/sun/net/httpserver \
     sun/net \
     jdk/net
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/corba/serialization/ObjectStreamTest$_Echo_Stub.java	Thu Oct 27 09:42:08 2016 -0700
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.rmi.UnexpectedException;
+
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Util;
+
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.RemarshalException;
+import org.omg.CORBA.portable.ServantObject;
+
+
+/**
+ * ObjectStreamTest$Echo Stub class generated by rmic, do not edit.
+ */
+public class ObjectStreamTest$_Echo_Stub extends Stub implements ObjectStreamTest.Echo {
+
+    private static final String[] _type_ids = {
+        "RMI:ObjectStreamTest\\U0024Echo:0000000000000000"
+    };
+
+    private static final long serialVersionUID = 5217577841494640354L;
+
+    public String[] _ids() {
+            return _type_ids.clone();
+        }
+
+        public Object echo(Object arg0) throws java.rmi.RemoteException {
+            if (!Util.isLocal(this)) {
+                try {
+                    org.omg.CORBA.portable.InputStream in = null;
+                    try {
+                        OutputStream out = _request("echo", true);
+                        Util.writeAny(out,arg0);
+                        in = _invoke(out);
+                        return Util.readAny(in);
+                    } catch (ApplicationException ex) {
+                        in = ex.getInputStream();
+                        String $_id = in.read_string();
+                        throw new UnexpectedException($_id);
+                    } catch (RemarshalException ex) {
+                        return echo(arg0);
+                    } finally {
+                        _releaseReply(in);
+                    }
+                } catch (SystemException ex) {
+                    throw Util.mapSystemException(ex);
+                }
+            } else {
+                ServantObject so = _servant_preinvoke("echo",ObjectStreamTest.Echo.class);
+                if (so == null) {
+                    return echo(arg0);
+                }
+                try {
+                    Object arg0Copy = Util.copyObject(arg0,_orb());
+                    Object result = ((ObjectStreamTest.Echo)so.servant).echo(arg0Copy);
+                    return Util.copyObject(result,_orb());
+                } catch (Throwable ex) {
+                    Throwable exCopy = (Throwable)Util.copyObject(ex,_orb());
+                    throw Util.wrapException(exCopy);
+                } finally {
+                    _servant_postinvoke(so);
+                }
+            }
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/corba/serialization/ObjectStreamTest$_Server_Tie.java	Thu Oct 27 09:42:08 2016 -0700
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.rmi.Remote;
+
+import javax.rmi.CORBA.Tie;
+import javax.rmi.CORBA.Util;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.UnknownException;
+import org.omg.CORBA_2_3.portable.ObjectImpl;
+
+
+/**
+ * ObjectStreamClass$Echo server tie class generated by rmic, do not edit.
+ */
+public class ObjectStreamTest$_Server_Tie extends ObjectImpl implements Tie {
+
+    volatile private ObjectStreamTest.Server target = null;
+
+    private static final String[] _type_ids = {
+        "RMI:ObjectStreamTest\\U0024Echo:0000000000000000"
+    };
+
+    public void setTarget(Remote target) {
+        this.target = (ObjectStreamTest.Server) target;
+    }
+
+    public Remote getTarget() {
+        return target;
+    }
+
+    public org.omg.CORBA.Object thisObject() {
+        return this;
+    }
+
+    public void deactivate() {
+        _orb().disconnect(this);
+        _set_delegate(null);
+        target = null;
+    }
+
+    public ORB orb() {
+        return _orb();
+    }
+
+    public void orb(ORB orb) {
+        orb.connect(this);
+    }
+
+    public String[] _ids() {
+        return _type_ids.clone();
+    }
+
+    public OutputStream  _invoke(String method, InputStream _in, ResponseHandler reply) throws SystemException {
+        try {
+            ObjectStreamTest.Server target = this.target;
+            if (target == null) {
+                throw new java.io.IOException();
+            }
+            org.omg.CORBA_2_3.portable.InputStream in =
+                (org.omg.CORBA_2_3.portable.InputStream) _in;
+            if (method.equals("echo")) {
+                Object arg0 = Util.readAny(in);
+                Object result = target.echo(arg0);
+                OutputStream out = reply.createReply();
+                Util.writeAny(out,result);
+                return out;
+            }
+            throw new BAD_OPERATION();
+        } catch (SystemException ex) {
+            throw ex;
+        } catch (Throwable ex) {
+            throw new UnknownException(ex);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/corba/serialization/ObjectStreamTest.java	Thu Oct 27 09:42:08 2016 -0700
@@ -0,0 +1,399 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.time.LocalTime;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.HashMap;
+import java.util.Objects;
+import java.util.PropertyPermission;
+import java.util.Set;
+import java.util.concurrent.atomic.LongAdder;
+
+import javax.rmi.CORBA.Util;
+import javax.rmi.PortableRemoteObject;
+
+import org.omg.CORBA_2_3.ORB;
+import org.omg.CORBA_2_3.portable.OutputStream;
+import org.omg.CORBA_2_3.portable.InputStream;
+
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+import org.testng.TestNG;
+
+/*
+ * @test
+ * @library /test/lib
+ * @build jdk.test.lib.*
+ * @compile  ObjectStreamTest.java  ObjectStreamTest$_Echo_Stub.java
+ *           ObjectStreamTest$_Server_Tie.java
+ * @modules java.corba/com.sun.corba.se.impl.io java.base/java.io
+ *          java.corba/com.sun.corba.se.impl.activation
+ * @summary Tests of ReflectionFactory use in IIOP Serialization
+ * @run testng/othervm ObjectStreamTest
+ * @run testng/othervm/policy=security.policy ObjectStreamTest
+ */
+
+@Test
+public class ObjectStreamTest {
+
+    enum Colors {RED, GREEN, YELLOW}
+
+    static Set<Colors> colorSet = new HashSet<>();
+
+    static {
+        colorSet.add(Colors.RED);
+        colorSet.add(Colors.GREEN);
+    }
+
+    @DataProvider(name = "Objects")
+    static Object[][] patterns() {
+        BigInteger bigInteger = new BigInteger("8943892002309239");
+        InetAddress inetAddr;
+        try {
+            inetAddr = java.net.InetAddress.getByAddress(new byte[]{127, 0, 0, 1});
+        } catch (UnknownHostException ignored) {</