changeset 17827:f3f6f6410d2d jdk-10+23

Merge
author prr
date Tue, 05 Sep 2017 10:09:44 -0700
parents 70359afda5d0 4276a5e50032
children 777356696811
files src/java.rmi/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java src/java.rmi/share/classes/sun/rmi/transport/tcp/MultiplexConnectionInfo.java src/java.rmi/share/classes/sun/rmi/transport/tcp/MultiplexInputStream.java src/java.rmi/share/classes/sun/rmi/transport/tcp/MultiplexOutputStream.java
diffstat 35 files changed, 1438 insertions(+), 1301 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Sun Sep 03 19:31:11 2017 +0530
+++ b/.hgtags	Tue Sep 05 10:09:44 2017 -0700
@@ -446,3 +446,4 @@
 bd66ea2fdde3d60a73b5272263a7b8b0ca926a33 jdk-9+181
 6256e94781f55e6f9e04eb284298d00eb9c5e106 jdk-10+20
 4e08a69241eab6e7a67a819a7b4fe29e7398855d jdk-10+21
+83720375178f919700dfbbd90650f8c8e0cf34f2 jdk-10+22
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/data/charsetmapping/ISO_8859_16.map	Tue Sep 05 10:09:44 2017 -0700
@@ -0,0 +1,258 @@
+# Confirmed with the mapping at
+# http://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-16.TXT
+0x00    U+0000
+0x01    U+0001
+0x02    U+0002
+0x03    U+0003
+0x04    U+0004
+0x05    U+0005
+0x06    U+0006
+0x07    U+0007
+0x08    U+0008
+0x09    U+0009
+0x0A    U+000A
+0x0B    U+000B
+0x0C    U+000C
+0x0D    U+000D
+0x0E    U+000E
+0x0F    U+000F
+0x10    U+0010
+0x11    U+0011
+0x12    U+0012
+0x13    U+0013
+0x14    U+0014
+0x15    U+0015
+0x16    U+0016
+0x17    U+0017
+0x18    U+0018
+0x19    U+0019
+0x1A    U+001A
+0x1B    U+001B
+0x1C    U+001C
+0x1D    U+001D
+0x1E    U+001E
+0x1F    U+001F
+0x20    U+0020
+0x21    U+0021
+0x22    U+0022
+0x23    U+0023
+0x24    U+0024
+0x25    U+0025
+0x26    U+0026
+0x27    U+0027
+0x28    U+0028
+0x29    U+0029
+0x2A    U+002A
+0x2B    U+002B
+0x2C    U+002C
+0x2D    U+002D
+0x2E    U+002E
+0x2F    U+002F
+0x30    U+0030
+0x31    U+0031
+0x32    U+0032
+0x33    U+0033
+0x34    U+0034
+0x35    U+0035
+0x36    U+0036
+0x37    U+0037
+0x38    U+0038
+0x39    U+0039
+0x3A    U+003A
+0x3B    U+003B
+0x3C    U+003C
+0x3D    U+003D
+0x3E    U+003E
+0x3F    U+003F
+0x40    U+0040
+0x41    U+0041
+0x42    U+0042
+0x43    U+0043
+0x44    U+0044
+0x45    U+0045
+0x46    U+0046
+0x47    U+0047
+0x48    U+0048
+0x49    U+0049
+0x4A    U+004A
+0x4B    U+004B
+0x4C    U+004C
+0x4D    U+004D
+0x4E    U+004E
+0x4F    U+004F
+0x50    U+0050
+0x51    U+0051
+0x52    U+0052
+0x53    U+0053
+0x54    U+0054
+0x55    U+0055
+0x56    U+0056
+0x57    U+0057
+0x58    U+0058
+0x59    U+0059
+0x5A    U+005A
+0x5B    U+005B
+0x5C    U+005C
+0x5D    U+005D
+0x5E    U+005E
+0x5F    U+005F
+0x60    U+0060
+0x61    U+0061
+0x62    U+0062
+0x63    U+0063
+0x64    U+0064
+0x65    U+0065
+0x66    U+0066
+0x67    U+0067
+0x68    U+0068
+0x69    U+0069
+0x6A    U+006A
+0x6B    U+006B
+0x6C    U+006C
+0x6D    U+006D
+0x6E    U+006E
+0x6F    U+006F
+0x70    U+0070
+0x71    U+0071
+0x72    U+0072
+0x73    U+0073
+0x74    U+0074
+0x75    U+0075
+0x76    U+0076
+0x77    U+0077
+0x78    U+0078
+0x79    U+0079
+0x7A    U+007A
+0x7B    U+007B
+0x7C    U+007C
+0x7D    U+007D
+0x7E    U+007E
+0x7F    U+007F
+0x80    U+0080
+0x81    U+0081
+0x82    U+0082
+0x83    U+0083
+0x84    U+0084
+0x85    U+0085
+0x86    U+0086
+0x87    U+0087
+0x88    U+0088
+0x89    U+0089
+0x8A    U+008A
+0x8B    U+008B
+0x8C    U+008C
+0x8D    U+008D
+0x8E    U+008E
+0x8F    U+008F
+0x90    U+0090
+0x91    U+0091
+0x92    U+0092
+0x93    U+0093
+0x94    U+0094
+0x95    U+0095
+0x96    U+0096
+0x97    U+0097
+0x98    U+0098
+0x99    U+0099
+0x9A    U+009A
+0x9B    U+009B
+0x9C    U+009C
+0x9D    U+009D
+0x9E    U+009E
+0x9F    U+009F
+0xA0    U+00A0
+0xA1    U+0104
+0xA2    U+0105
+0xA3    U+0141
+0xA4    U+20AC
+0xA5    U+201E
+0xA6    U+0160
+0xA7    U+00A7
+0xA8    U+0161
+0xA9    U+00A9
+0xAA    U+0218
+0xAB    U+00AB
+0xAC    U+0179
+0xAD    U+00AD
+0xAE    U+017A
+0xAF    U+017B
+0xB0    U+00B0
+0xB1    U+00B1
+0xB2    U+010C
+0xB3    U+0142
+0xB4    U+017D
+0xB5    U+201D
+0xB6    U+00B6
+0xB7    U+00B7
+0xB8    U+017E
+0xB9    U+010D
+0xBA    U+0219
+0xBB    U+00BB
+0xBC    U+0152
+0xBD    U+0153
+0xBE    U+0178
+0xBF    U+017C
+0xC0    U+00C0
+0xC1    U+00C1
+0xC2    U+00C2
+0xC3    U+0102
+0xC4    U+00C4
+0xC5    U+0106
+0xC6    U+00C6
+0xC7    U+00C7
+0xC8    U+00C8
+0xC9    U+00C9
+0xCA    U+00CA
+0xCB    U+00CB
+0xCC    U+00CC
+0xCD    U+00CD
+0xCE    U+00CE
+0xCF    U+00CF
+0xD0    U+0110
+0xD1    U+0143
+0xD2    U+00D2
+0xD3    U+00D3
+0xD4    U+00D4
+0xD5    U+0150
+0xD6    U+00D6
+0xD7    U+015A
+0xD8    U+0170
+0xD9    U+00D9
+0xDA    U+00DA
+0xDB    U+00DB
+0xDC    U+00DC
+0xDD    U+0118
+0xDE    U+021A
+0xDF    U+00DF
+0xE0    U+00E0
+0xE1    U+00E1
+0xE2    U+00E2
+0xE3    U+0103
+0xE4    U+00E4
+0xE5    U+0107
+0xE6    U+00E6
+0xE7    U+00E7
+0xE8    U+00E8
+0xE9    U+00E9
+0xEA    U+00EA
+0xEB    U+00EB
+0xEC    U+00EC
+0xED    U+00ED
+0xEE    U+00EE
+0xEF    U+00EF
+0xF0    U+0111
+0xF1    U+0144
+0xF2    U+00F2
+0xF3    U+00F3
+0xF4    U+00F4
+0xF5    U+0151
+0xF6    U+00F6
+0xF7    U+015B
+0xF8    U+0171
+0xF9    U+00F9
+0xFA    U+00FA
+0xFB    U+00FB
+0xFC    U+00FC
+0xFD    U+0119
+0xFE    U+021B
+0xFF    U+00FF
--- a/make/data/charsetmapping/charsets	Sun Sep 03 19:31:11 2017 +0530
+++ b/make/data/charsetmapping/charsets	Tue Sep 05 10:09:44 2017 -0700
@@ -257,6 +257,8 @@
     hisname ISO8859_15
     ascii   true
     alias   ISO_8859-15                # IANA alias
+    alias   Latin-9
+    alias   csISO885915
     alias   8859_15                    # Other aliases
     alias   ISO-8859-15
     alias   ISO8859_15
@@ -272,6 +274,18 @@
     alias   csISOlatin9
     alias   ISO8859_15_FDIS
 
+charset ISO-8859-16 ISO_8859_16
+    package sun.nio.cs
+    type    sbcs
+    hisname ISO8859_16
+    ascii   true
+    alias   iso-ir-226
+    alias   ISO_8859-16:2001
+    alias   ISO_8859-16
+    alias   latin10
+    alias   l10
+    alias   csISO885916
+
 charset KOI8-R KOI8_R
     package sun.nio.cs
     type    sbcs
--- a/src/java.base/share/classes/java/io/FileOutputStream.java	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/java.base/share/classes/java/io/FileOutputStream.java	Tue Sep 05 10:09:44 2017 -0700
@@ -91,7 +91,7 @@
      * If the file exists but is a directory rather than a regular file, does
      * not exist but cannot be created, or cannot be opened for any other
      * reason then a <code>FileNotFoundException</code> is thrown.
-     * <p>
+     *
      * @implSpec Invoking this constructor with the parameter {@code name} is
      * equivalent to invoking {@link #FileOutputStream(String,boolean)
      * new FileOutputStream(name, false)}.
--- a/src/java.base/share/classes/module-info.java	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/java.base/share/classes/module-info.java	Tue Sep 05 10:09:44 2017 -0700
@@ -35,7 +35,7 @@
  *      The jrt file system can be created by calling
  *      {@link java.nio.file.FileSystems#newFileSystem
  *      FileSystems.newFileSystem(URI.create("jrt:/"))}.
- *      <p></dd>
+ *      </dd>
  * <dt class="simpleTagLabel" style="font-family:'DejaVu Sans', Arial, Helvetica, sans serif">Tool Guides:</dt>
  * <dd style="font-family:'DejaVu Sans', Arial, Helvetica, sans serif"> {@extLink java_tool_reference java launcher},
  *      {@extLink keytool_tool_reference keytool}</dd>
--- a/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Tue Sep 05 10:09:44 2017 -0700
@@ -137,7 +137,6 @@
 \    -Xms<size>        set initial Java heap size\n\
 \    -Xmx<size>        set maximum Java heap size\n\
 \    -Xnoclassgc       disable class garbage collection\n\
-\    -Xprof            output cpu profiling data (deprecated)\n\
 \    -Xrs              reduce use of OS signals by Java/VM (see documentation)\n\
 \    -Xshare:auto      use shared class data if possible (default)\n\
 \    -Xshare:off       do not attempt to use shared class data\n\
--- a/src/java.base/share/classes/sun/nio/cs/Unicode.java	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/java.base/share/classes/sun/nio/cs/Unicode.java	Tue Sep 05 10:09:44 2017 -0700
@@ -38,6 +38,7 @@
         return ((cs instanceof US_ASCII)
                 || (cs instanceof ISO_8859_1)
                 || (cs instanceof ISO_8859_15)
+                || (cs instanceof ISO_8859_16)
                 || (cs instanceof MS1252)
                 || (cs instanceof UTF_8)
                 || (cs instanceof UTF_16)
--- a/src/java.base/share/conf/security/java.security	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/java.base/share/conf/security/java.security	Tue Sep 05 10:09:44 2017 -0700
@@ -678,6 +678,7 @@
 jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 1024, \
     EC keySize < 224
 
+#
 # Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS)
 # processing in JSSE implementation.
 #
@@ -742,6 +743,7 @@
         RC4_128, RC4_40, DES_CBC, DES40_CBC, \
         3DES_EDE_CBC
 
+#
 # The pre-defined default finite field Diffie-Hellman ephemeral (DHE)
 # parameters for Transport Layer Security (SSL/TLS/DTLS) processing.
 #
@@ -799,54 +801,38 @@
 #       EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381 \
 #       FFFFFFFF FFFFFFFF, 2}
 
+#
 # Cryptographic Jurisdiction Policy defaults
 #
-# Due to the import control restrictions of some countries, the default
-# JCE policy files allow for strong but "limited" cryptographic key
-# lengths to be used.  If your country's cryptographic regulations allow,
-# the "unlimited" strength policy files can be used instead, which contain
-# no restrictions on cryptographic strengths.
+# Import and export control rules on cryptographic software vary from
+# country to country.  By default, Java provides two different sets of
+# cryptographic policy files[1]:
 #
-# If your country has restrictions that don't fit either "limited" or
-# "unlimited", an appropriate set of policy files should be created and
-# configured before using this distribution.  The jurisdiction policy file
-# configuration must reflect the cryptographic restrictions appropriate
-# for your country.
+#     unlimited:  These policy files contain no restrictions on cryptographic
+#                 strengths or algorithms
+#
+#     limited:    These policy files contain more restricted cryptographic
+#                 strengths
+#
+# The default setting is determined by the value of the “crypto.policy”
+# Security property below. If your country or usage requires the
+# traditional restrictive policy, the “limited” Java cryptographic
+# policy is still available and may be appropriate for your environment.
+#
+# If you have restrictions that do not fit either use case mentioned
+# above, Java provides the capability to customize these policy files.
+# The “crypto.policy” security property points to a subdirectory
+# within <java-home>/conf/security/policy/ which can be customized.
+# Please see the <java-home>/conf/security/policy/README.txt file or consult
+# the Java Security Guide/JCA documentation for more information.
 #
 # YOU ARE ADVISED TO CONSULT YOUR EXPORT/IMPORT CONTROL COUNSEL OR ATTORNEY
 # TO DETERMINE THE EXACT REQUIREMENTS.
 #
-# The policy files are flat text files organized into subdirectories of
-# <java-home>/conf/security/policy.  Each directory contains a complete
-# set of policy files.
-#
-# The "crypto.policy" Security property controls the directory selection,
-# and thus the effective cryptographic policy.
-#
-# The default set of directories is:
-#
-#     limited | unlimited
-#
-# however other directories can be created and configured.
-#
-# Within a directory, the effective policy is the combined minimum
-# permissions of the grant statements in the file(s) with the filename
-# pattern "default_*.policy".  At least one grant is required.  For
-# example:
-#
-#     limited   =  Export (all) + Import (limited)  =  Limited
-#     unlimited =  Export (all) + Import (all)      =  Unlimited
-#
-# The effective exemption policy is the combined minimum permissions
-# of the grant statements in the file(s) with the filename pattern
-# "exempt_*.policy".  Exemption grants are optional.
-#
-#     limited   =  grants exemption permissions, by which the
-#                  effective policy can be circumvented.
-#                  e.g.  KeyRecovery/Escrow/Weakening.
-#
-# Please see the JCA documentation for additional information on these
-# files and formats.
+# [1] Please note that the JCE for Java SE, including the JCE framework,
+# cryptographic policy files, and standard JCE providers provided with
+# the Java SE, have been reviewed and approved for export as mass market
+# encryption item by the US Bureau of Industry and Security.
 #
 # Note: This property is currently used by the JDK Reference implementation.
 # It is not guaranteed to be examined and used by other implementations.
--- a/src/java.base/share/conf/security/policy/README.txt	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/java.base/share/conf/security/policy/README.txt	Tue Sep 05 10:09:44 2017 -0700
@@ -5,30 +5,50 @@
                                README
 ------------------------------------------------------------------------
 
+Import and export control rules on cryptographic software vary from
+country to country.  The Java Cryptography Extension (JCE) architecture
+allows flexible cryptographic key strength to be configured via the
+jurisdiction policy files which are referenced by the “crypto.policy”
+security property in the <java-home>/conf/security/java.security file.
 
-The JCE architecture allows flexible cryptographic strength to be
-configured via the jurisdiction policy files contained within these
-directories.
+By default, Java provides two different sets of cryptographic policy
+files:
 
-The default JCE policy files bundled in this Java Runtime Environment
-allow for "unlimited" cryptographic strengths.  For convenience,
-this build also contains the historic "limited" strength policy files
-which contain restrictions on cryptographic strengths, but they must be
-specifically activated by updating the "crypto.policy" Security property
-(e.g. <java-home>/conf/security/java.security) to point to the appropriate
-directory.
+    unlimited:  These policy files contain no restrictions on cryptographic
+                strengths or algorithms
 
-Each subdirectory contains a complete policy configuration, and additional
-subdirectories can be added/removed to reflect local regulations.
+    limited:    These policy files contain more restricted cryptographic
+                strengths
 
-JCE for Java SE has been through the U.S. export review process.  The JCE
-framework, along with the various JCE providers that come standard with it
-(SunJCE, SunEC, SunPKCS11, SunMSCAPI, etc), is exportable from the
-United States.
+These files reside in <java-home>/conf/security/policy in the “unlimited”
+or “limited” subdirectories respectively.
 
-You are advised to consult your export/import control counsel or attorney
-to determine the exact requirements of your location, and what policy
-settings should be used.
+Each subdirectory contains a complete policy configuration,
+and subdirectories can be added/edited/removed to reflect your
+import or export control product requirements.
 
-Please see The Java(TM) Cryptography Architecture (JCA) Reference
-Guide and the java.security file for more information.
+Within a subdirectory, the effective policy is the combined minimum
+permissions of the grant statements in the file(s) matching the filename
+pattern "default_*.policy".  At least one grant is required.  For example:
+
+    limited   =  Export (all) + Import (limited)  =  Limited
+    unlimited =  Export (all) + Import (all)      =  Unlimited
+
+The effective exemption policy is the combined minimum permissions
+of the grant statements in the file(s) matching the filename pattern
+"exempt_*.policy".  Exemption grants are optional.  For example:
+
+    limited   =  grants exemption permissions, by which the
+                 effective policy can be circumvented.
+                 e.g.  KeyRecovery/KeyEscrow/KeyWeakening.
+
+Please see the Java Cryptography Architecture (JCA) documentation for
+additional information on these files and formats.
+
+YOU ARE ADVISED TO CONSULT YOUR EXPORT/IMPORT CONTROL COUNSEL OR ATTORNEY
+TO DETERMINE THE EXACT REQUIREMENTS.
+
+Please note that the JCE for Java SE, including the JCE framework,
+cryptographic policy files, and standard JCE providers provided with
+the Java SE, have been reviewed and approved for export as mass market
+encryption item by the US Bureau of Industry and Security.
--- a/src/java.rmi/share/classes/sun/rmi/server/ActivatableRef.java	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/java.rmi/share/classes/sun/rmi/server/ActivatableRef.java	Tue Sep 05 10:09:44 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -158,8 +158,7 @@
                 exception = e;
             } catch (ConnectIOException e) {
                 /*
-                 * Failure setting up multiplexed connection or reusing
-                 * cached connection; retry call
+                 * Failure reusing cached connection; retry call
                  */
                 exception = e;
             } catch (MarshalException e) {
--- a/src/java.rmi/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java	Sun Sep 03 19:31:11 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,449 +0,0 @@
-/*
- * Copyright (c) 1996, 2017, 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.rmi.transport.tcp;
-
-import java.io.*;
-import java.util.*;
-import java.rmi.server.LogStream;
-import java.security.PrivilegedAction;
-
-import sun.rmi.runtime.Log;
-
-/**
- * ConnectionMultiplexer manages the transparent multiplexing of
- * multiple virtual connections from one endpoint to another through
- * one given real connection to that endpoint.  The input and output
- * streams for the underlying real connection must be supplied.
- * A callback object is also supplied to be informed of new virtual
- * connections opened by the remote endpoint.  After creation, the
- * run() method must be called in a thread created for demultiplexing
- * the connections.  The openConnection() method is called to
- * initiate a virtual connection from this endpoint.
- *
- * @author Peter Jones
- */
-@SuppressWarnings("deprecation")
-final class ConnectionMultiplexer {
-
-    /** "multiplex" log level */
-    static int logLevel = LogStream.parseLevel(getLogLevel());
-
-    private static String getLogLevel() {
-        return java.security.AccessController.doPrivileged(
-           (PrivilegedAction<String>) () -> System.getProperty("sun.rmi.transport.tcp.multiplex.logLevel"));
-    }
-
-    /* multiplex system log */
-    static final Log multiplexLog =
-        Log.getLog("sun.rmi.transport.tcp.multiplex",
-                   "multiplex", ConnectionMultiplexer.logLevel);
-
-    /** multiplexing protocol operation codes */
-    private final static int OPEN     = 0xE1;
-    private final static int CLOSE    = 0xE2;
-    private final static int CLOSEACK = 0xE3;
-    private final static int REQUEST  = 0xE4;
-    private final static int TRANSMIT = 0xE5;
-
-    /** object to notify for new connections from remote endpoint */
-    private TCPChannel channel;
-
-    /** input stream for underlying single connection */
-    private InputStream in;
-
-    /** output stream for underlying single connection */
-    private OutputStream out;
-
-    /** true if underlying connection originated from this endpoint
-        (used for generating unique connection IDs) */
-    private boolean orig;
-
-    /** layered stream for reading formatted data from underlying connection */
-    private DataInputStream dataIn;
-
-    /** layered stream for writing formatted data to underlying connection */
-    private DataOutputStream dataOut;
-
-    /** table holding currently open connection IDs and related info */
-    private Hashtable<Integer, MultiplexConnectionInfo> connectionTable = new Hashtable<>(7);
-
-    /** number of currently open connections */
-    private int numConnections = 0;
-
-    /** maximum allowed open connections */
-    private final static int maxConnections = 256;
-
-    /** ID of last connection opened */
-    private int lastID = 0x1001;
-
-    /** true if this mechanism is still alive */
-    private boolean alive = true;
-
-    /**
-     * Create a new ConnectionMultiplexer using the given underlying
-     * input/output stream pair.  The run method must be called
-     * (possibly on a new thread) to handle the demultiplexing.
-     * @param channel object to notify when new connection is received
-     * @param in input stream of underlying connection
-     * @param out output stream of underlying connection
-     * @param orig true if this endpoint intiated the underlying
-     *        connection (needs to be set differently at both ends)
-     */
-    public ConnectionMultiplexer(
-        TCPChannel    channel,
-        InputStream   in,
-        OutputStream  out,
-        boolean       orig)
-    {
-        this.channel = channel;
-        this.in      = in;
-        this.out     = out;
-        this.orig    = orig;
-
-        dataIn = new DataInputStream(in);
-        dataOut = new DataOutputStream(out);
-    }
-
-    /**
-     * Process multiplexing protocol received from underlying connection.
-     */
-    public void run() throws IOException
-    {
-        try {
-            int op, id, length;
-            MultiplexConnectionInfo info;
-
-            while (true) {
-
-                // read next op code from remote endpoint
-                op = dataIn.readUnsignedByte();
-                switch (op) {
-
-                // remote endpoint initiating new connection
-                case OPEN:
-                    id = dataIn.readUnsignedShort();
-
-                    if (multiplexLog.isLoggable(Log.VERBOSE)) {
-                        multiplexLog.log(Log.VERBOSE, "operation  OPEN " + id);
-                    }
-
-                    info = connectionTable.get(id);
-                    if (info != null)
-                        throw new IOException(
-                            "OPEN: Connection ID already exists");
-                    info = new MultiplexConnectionInfo(id);
-                    info.in = new MultiplexInputStream(this, info, 2048);
-                    info.out = new MultiplexOutputStream(this, info, 2048);
-                    synchronized (connectionTable) {
-                        connectionTable.put(id, info);
-                        ++ numConnections;
-                    }
-                    sun.rmi.transport.Connection conn;
-                    conn = new TCPConnection(channel, info.in, info.out);
-                    channel.acceptMultiplexConnection(conn);
-                    break;
-
-                // remote endpoint closing connection
-                case CLOSE:
-                    id = dataIn.readUnsignedShort();
-
-                    if (multiplexLog.isLoggable(Log.VERBOSE)) {
-                        multiplexLog.log(Log.VERBOSE, "operation  CLOSE " + id);
-                    }
-
-                    info = connectionTable.get(id);
-                    if (info == null)
-                        throw new IOException(
-                            "CLOSE: Invalid connection ID");
-                    info.in.disconnect();
-                    info.out.disconnect();
-                    if (!info.closed)
-                        sendCloseAck(info);
-                    synchronized (connectionTable) {
-                        connectionTable.remove(id);
-                        -- numConnections;
-                    }
-                    break;
-
-                // remote endpoint acknowledging close of connection
-                case CLOSEACK:
-                    id = dataIn.readUnsignedShort();
-
-                    if (multiplexLog.isLoggable(Log.VERBOSE)) {
-                        multiplexLog.log(Log.VERBOSE,
-                            "operation  CLOSEACK " + id);
-                    }
-
-                    info = connectionTable.get(id);
-                    if (info == null)
-                        throw new IOException(
-                            "CLOSEACK: Invalid connection ID");
-                    if (!info.closed)
-                        throw new IOException(
-                            "CLOSEACK: Connection not closed");
-                    info.in.disconnect();
-                    info.out.disconnect();
-                    synchronized (connectionTable) {
-                        connectionTable.remove(id);
-                        -- numConnections;
-                    }
-                    break;
-
-                // remote endpoint declaring additional bytes receivable
-                case REQUEST:
-                    id = dataIn.readUnsignedShort();
-                    info = connectionTable.get(id);
-                    if (info == null)
-                        throw new IOException(
-                            "REQUEST: Invalid connection ID");
-                    length = dataIn.readInt();
-
-                    if (multiplexLog.isLoggable(Log.VERBOSE)) {
-                        multiplexLog.log(Log.VERBOSE,
-                            "operation  REQUEST " + id + ": " + length);
-                    }
-
-                    info.out.request(length);
-                    break;
-
-                // remote endpoint transmitting data packet
-                case TRANSMIT:
-                    id = dataIn.readUnsignedShort();
-                    info = connectionTable.get(id);
-                    if (info == null)
-                        throw new IOException("SEND: Invalid connection ID");
-                    length = dataIn.readInt();
-
-                    if (multiplexLog.isLoggable(Log.VERBOSE)) {
-                        multiplexLog.log(Log.VERBOSE,
-                            "operation  TRANSMIT " + id + ": " + length);
-                    }
-
-                    info.in.receive(length, dataIn);
-                    break;
-
-                default:
-                    throw new IOException("Invalid operation: " +
-                                          Integer.toHexString(op));
-                }
-            }
-        } finally {
-            shutDown();
-        }
-    }
-
-    /**
-     * Initiate a new multiplexed connection through the underlying
-     * connection.
-     */
-    public synchronized TCPConnection openConnection() throws IOException
-    {
-        // generate ID that should not be already used
-        // If all possible 32768 IDs are used,
-        // this method will block searching for a new ID forever.
-        int id;
-        do {
-            lastID = (++ lastID) & 0x7FFF;
-            id = lastID;
-
-            // The orig flag (copied to the high bit of the ID) is used
-            // to have two distinct ranges to choose IDs from for the
-            // two endpoints.
-            if (orig)
-                id |= 0x8000;
-        } while (connectionTable.get(id) != null);
-
-        // create multiplexing streams and bookkeeping information
-        MultiplexConnectionInfo info = new MultiplexConnectionInfo(id);
-        info.in = new MultiplexInputStream(this, info, 2048);
-        info.out = new MultiplexOutputStream(this, info, 2048);
-
-        // add to connection table if multiplexer has not died
-        synchronized (connectionTable) {
-            if (!alive)
-                throw new IOException("Multiplexer connection dead");
-            if (numConnections >= maxConnections)
-                throw new IOException("Cannot exceed " + maxConnections +
-                    " simultaneous multiplexed connections");
-            connectionTable.put(id, info);
-            ++ numConnections;
-        }
-
-        // inform remote endpoint of new connection
-        synchronized (dataOut) {
-            try {
-                dataOut.writeByte(OPEN);
-                dataOut.writeShort(id);
-                dataOut.flush();
-            } catch (IOException e) {
-                multiplexLog.log(Log.BRIEF, "exception: ", e);
-
-                shutDown();
-                throw e;
-            }
-        }
-
-        return new TCPConnection(channel, info.in, info.out);
-    }
-
-    /**
-     * Shut down all connections and clean up.
-     */
-    public void shutDown()
-    {
-        // inform all associated streams
-        synchronized (connectionTable) {
-            // return if multiplexer already officially dead
-            if (!alive)
-                return;
-            alive = false;
-
-            Enumeration<MultiplexConnectionInfo> enum_ =
-                    connectionTable.elements();
-            while (enum_.hasMoreElements()) {
-                MultiplexConnectionInfo info = enum_.nextElement();
-                info.in.disconnect();
-                info.out.disconnect();
-            }
-            connectionTable.clear();
-            numConnections = 0;
-        }
-
-        // close underlying connection, if possible (and not already done)
-        try {
-            in.close();
-        } catch (IOException e) {
-        }
-        try {
-            out.close();
-        } catch (IOException e) {
-        }
-    }
-
-    /**
-     * Send request for more data on connection to remote endpoint.
-     * @param info connection information structure
-     * @param len number of more bytes that can be received
-     */
-    void sendRequest(MultiplexConnectionInfo info, int len) throws IOException
-    {
-        synchronized (dataOut) {
-            if (alive && !info.closed)
-                try {
-                    dataOut.writeByte(REQUEST);
-                    dataOut.writeShort(info.id);
-                    dataOut.writeInt(len);
-                    dataOut.flush();
-                } catch (IOException e) {
-                    multiplexLog.log(Log.BRIEF, "exception: ", e);
-
-                    shutDown();
-                    throw e;
-                }
-        }
-    }
-
-    /**
-     * Send packet of requested data on connection to remote endpoint.
-     * @param info connection information structure
-     * @param buf array containing bytes to send
-     * @param off offset of first array index of packet
-     * @param len number of bytes in packet to send
-     */
-    void sendTransmit(MultiplexConnectionInfo info,
-                      byte buf[], int off, int len) throws IOException
-    {
-        synchronized (dataOut) {
-            if (alive && !info.closed)
-                try {
-                    dataOut.writeByte(TRANSMIT);
-                    dataOut.writeShort(info.id);
-                    dataOut.writeInt(len);
-                    dataOut.write(buf, off, len);
-                    dataOut.flush();
-                } catch (IOException e) {
-                    multiplexLog.log(Log.BRIEF, "exception: ", e);
-
-                    shutDown();
-                    throw e;
-                }
-        }
-    }
-
-    /**
-     * Inform remote endpoint that connection has been closed.
-     * @param info connection information structure
-     */
-    void sendClose(MultiplexConnectionInfo info) throws IOException
-    {
-        info.out.disconnect();
-        synchronized (dataOut) {
-            if (alive && !info.closed)
-                try {
-                    dataOut.writeByte(CLOSE);
-                    dataOut.writeShort(info.id);
-                    dataOut.flush();
-                    info.closed = true;
-                } catch (IOException e) {
-                    multiplexLog.log(Log.BRIEF, "exception: ", e);
-
-                    shutDown();
-                    throw e;
-                }
-        }
-    }
-
-    /**
-     * Acknowledge remote endpoint's closing of connection.
-     * @param info connection information structure
-     */
-    void sendCloseAck(MultiplexConnectionInfo info) throws IOException
-    {
-        synchronized (dataOut) {
-            if (alive && !info.closed)
-                try {
-                    dataOut.writeByte(CLOSEACK);
-                    dataOut.writeShort(info.id);
-                    dataOut.flush();
-                    info.closed = true;
-                } catch (IOException e) {
-                    multiplexLog.log(Log.BRIEF, "exception: ", e);
-
-                    shutDown();
-                    throw e;
-                }
-        }
-    }
-
-    /**
-     * Shut down connection upon finalization.
-     */
-    @SuppressWarnings("deprecation")
-    protected void finalize() throws Throwable
-    {
-        super.finalize();
-        shutDown();
-    }
-}
--- a/src/java.rmi/share/classes/sun/rmi/transport/tcp/MultiplexConnectionInfo.java	Sun Sep 03 19:31:11 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 1996, 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.rmi.transport.tcp;
-
-/**
- * MultiplexConnectionInfo groups related information about a
- * virtual connection managed by a ConnectionMultiplexer object.
- *
- * @author Peter Jones
- */
-class MultiplexConnectionInfo {
-
-    /** integer that uniquely identifies this connection */
-    int id;
-
-    /** input stream for reading from connection */
-    MultiplexInputStream in = null;
-
-    /** output stream for writing to connection */
-    MultiplexOutputStream out = null;
-
-    /** true if this connection has been closed */
-    boolean closed = false;
-
-    /**
-     * Create information structure for given connection identifier.
-     * @param id connection identifier
-     */
-    MultiplexConnectionInfo(int id)
-    {
-        this.id  = id;
-    }
-}
--- a/src/java.rmi/share/classes/sun/rmi/transport/tcp/MultiplexInputStream.java	Sun Sep 03 19:31:11 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 1996, 1997, 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.rmi.transport.tcp;
-
-import java.io.*;
-
-/**
- * MultiplexInputStream manages receiving data over a connection managed
- * by a ConnectionMultiplexer object.  This object is responsible for
- * requesting more bytes of data as space in its internal buffer becomes
- * available.
- *
- * @author Peter Jones
- */
-final class MultiplexInputStream extends InputStream {
-
-    /** object managing multiplexed connection */
-    private ConnectionMultiplexer manager;
-
-    /** information about the connection this is the input stream for */
-    private MultiplexConnectionInfo info;
-
-    /** input buffer */
-    private byte buffer[];
-
-    /** number of real data bytes present in buffer */
-    private int present = 0;
-
-    /** current position to read from in input buffer */
-    private int pos = 0;
-
-    /** pending number of bytes this stream has requested */
-    private int requested = 0;
-
-    /** true if this connection has been disconnected */
-    private boolean disconnected = false;
-
-    /**
-     * lock acquired to access shared variables:
-     * buffer, present, pos, requested, & disconnected
-     * WARNING:  Any of the methods manager.send*() should not be
-     * invoked while this lock is held, since they could potentially
-     * block if the underlying connection's transport buffers are
-     * full, and the manager may need to acquire this lock to process
-     * and consume data coming over the underlying connection.
-     */
-    private Object lock = new Object();
-
-    /** level at which more data is requested when read past */
-    private int waterMark;
-
-    /** data structure for holding reads of one byte */
-    private byte temp[] = new byte[1];
-
-    /**
-     * Create a new MultiplexInputStream for the given manager.
-     * @param manager object that manages this connection
-     * @param info structure for connection this stream reads from
-     * @param bufferLength length of input buffer
-     */
-    MultiplexInputStream(
-        ConnectionMultiplexer    manager,
-        MultiplexConnectionInfo  info,
-        int                      bufferLength)
-    {
-        this.manager = manager;
-        this.info    = info;
-
-        buffer = new byte[bufferLength];
-        waterMark = bufferLength / 2;
-    }
-
-    /**
-     * Read a byte from the connection.
-     */
-    public synchronized int read() throws IOException
-    {
-        int n = read(temp, 0, 1);
-        if (n != 1)
-            return -1;
-        return temp[0] & 0xFF;
-    }
-
-    /**
-     * Read a subarray of bytes from connection.  This method blocks for
-     * at least one byte, and it returns the number of bytes actually read,
-     * or -1 if the end of the stream was detected.
-     * @param b array to read bytes into
-     * @param off offset of beginning of bytes to read into
-     * @param len number of bytes to read
-     */
-    public synchronized int read(byte b[], int off, int len) throws IOException
-    {
-        if (len <= 0)
-            return 0;
-
-        int moreSpace;
-        synchronized (lock) {
-            if (pos >= present)
-                pos = present = 0;
-            else if (pos >= waterMark) {
-                System.arraycopy(buffer, pos, buffer, 0, present - pos);
-                present -= pos;
-                pos = 0;
-            }
-            int freeSpace = buffer.length - present;
-            moreSpace = Math.max(freeSpace - requested, 0);
-        }
-        if (moreSpace > 0)
-            manager.sendRequest(info, moreSpace);
-        synchronized (lock) {
-            requested += moreSpace;
-            while ((pos >= present) && !disconnected) {
-                try {
-                    lock.wait();
-                } catch (InterruptedException e) {
-                }
-            }
-            if (disconnected && pos >= present)
-                return -1;
-
-            int available = present - pos;
-            if (len < available) {
-                System.arraycopy(buffer, pos, b, off, len);
-                pos += len;
-                return len;
-            }
-            else {
-                System.arraycopy(buffer, pos, b, off, available);
-                pos = present = 0;
-                // could send another request here, if len > available??
-                return available;
-            }
-        }
-    }
-
-    /**
-     * Return the number of bytes immediately available for reading.
-     */
-    public int available() throws IOException
-    {
-        synchronized (lock) {
-            return present - pos;
-        }
-    }
-
-    /**
-     * Close this connection.
-     */
-    public void close() throws IOException
-    {
-        manager.sendClose(info);
-    }
-
-    /**
-     * Receive bytes transmitted from connection at remote endpoint.
-     * @param length number of bytes transmitted
-     * @param in input stream with those bytes ready to be read
-     */
-    void receive(int length, DataInputStream in)
-        throws IOException
-    {
-        /* TO DO: Optimize so that data received from stream can be loaded
-         * directly into user's buffer if there is a pending read().
-         */
-        synchronized (lock) {
-            if ((pos > 0) && ((buffer.length - present) < length)) {
-                System.arraycopy(buffer, pos, buffer, 0, present - pos);
-                present -= pos;
-                pos = 0;
-            }
-            if ((buffer.length - present) < length)
-                throw new IOException("Receive buffer overflow");
-            in.readFully(buffer, present, length);
-            present += length;
-            requested -= length;
-            lock.notifyAll();
-        }
-    }
-
-    /**
-     * Disconnect this stream from all connection activity.
-     */
-    void disconnect()
-    {
-        synchronized (lock) {
-            disconnected = true;
-            lock.notifyAll();
-        }
-    }
-}
--- a/src/java.rmi/share/classes/sun/rmi/transport/tcp/MultiplexOutputStream.java	Sun Sep 03 19:31:11 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,231 +0,0 @@
-/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.rmi.transport.tcp;
-
-import java.io.*;
-
-/**
- * MultiplexOutputStream manages sending data over a connection managed
- * by a ConnectionMultiplexer object.  Data written is buffered until the
- * internal buffer is full or the flush() method is called, at which
- * point it attempts to push a packet of bytes through to the remote
- * endpoint.  This will never push more bytes than the amount already
- * requested by the remote endpoint (to prevent receive buffer from
- * overflowing), so if the write() and flush() methods will block
- * until their operation can complete if enough bytes cannot be
- * pushed immediately.
- *
- * @author Peter Jones
- */
-final class MultiplexOutputStream extends OutputStream {
-
-    /** object managing multiplexed connection */
-    private ConnectionMultiplexer manager;
-
-    /** information about the connection this is the output stream for */
-    private MultiplexConnectionInfo info;
-
-    /** output buffer */
-    private byte buffer[];
-
-    /** current position to write to in output buffer */
-    private int pos = 0;
-
-    /** pending number of bytes requested by remote endpoint */
-    private int requested = 0;
-
-    /** true if this connection has been disconnected */
-    private boolean disconnected = false;
-
-    /**
-     * lock acquired to access shared variables:
-     * requested & disconnected
-     * WARNING:  Any of the methods manager.send*() should not be
-     * invoked while this lock is held, since they could potentially
-     * block if the underlying connection's transport buffers are
-     * full, and the manager may need to acquire this lock to process
-     * and consume data coming over the underlying connection.
-     */
-    private Object lock = new Object();
-
-    /**
-     * Create a new MultiplexOutputStream for the given manager.
-     * @param manager object that manages this connection
-     * @param info structure for connection this stream writes to
-     * @param bufferLength length of output buffer
-     */
-    MultiplexOutputStream(
-        ConnectionMultiplexer    manager,
-        MultiplexConnectionInfo  info,
-        int                      bufferLength)
-    {
-        this.manager = manager;
-        this.info    = info;
-
-        buffer = new byte[bufferLength];
-        pos = 0;
-    }
-
-    /**
-     * Write a byte over connection.
-     * @param b byte of data to write
-     */
-    public synchronized void write(int b) throws IOException
-    {
-        while (pos >= buffer.length)
-            push();
-        buffer[pos ++] = (byte) b;
-    }
-
-    /**
-     * Write a subarray of bytes over connection.
-     * @param b array containing bytes to write
-     * @param off offset of beginning of bytes to write
-     * @param len number of bytes to write
-     */
-    public synchronized void write(byte b[], int off, int len)
-        throws IOException
-    {
-        if (len <= 0)
-            return;
-
-        // if enough free space in output buffer, just copy into there
-        int freeSpace = buffer.length - pos;
-        if (len <= freeSpace) {
-            System.arraycopy(b, off, buffer, pos, len);
-            pos += len;
-            return;
-        }
-
-        // else, flush buffer and send rest directly to avoid array copy
-        flush();
-        int local_requested;
-        while (true) {
-            synchronized (lock) {
-                while ((local_requested = requested) < 1 && !disconnected) {
-                    try {
-                        lock.wait();
-                    } catch (InterruptedException e) {
-                    }
-                }
-                if (disconnected)
-                    throw new IOException("Connection closed");
-            }
-
-            if (local_requested < len) {
-                manager.sendTransmit(info, b, off, local_requested);
-                off += local_requested;
-                len -= local_requested;
-                synchronized (lock) {
-                    requested -= local_requested;
-                }
-            }
-            else {
-                manager.sendTransmit(info, b, off, len);
-                synchronized (lock) {
-                    requested -= len;
-                }
-                // len = 0;
-                break;
-            }
-        }
-    }
-
-    /**
-     * Guarantee that all data written to this stream has been pushed
-     * over and made available to the remote endpoint.
-     */
-    public synchronized void flush() throws IOException {
-        while (pos > 0)
-            push();
-    }
-
-    /**
-     * Close this connection.
-     */
-    public void close() throws IOException
-    {
-        manager.sendClose(info);
-    }
-
-    /**
-     * Take note of more bytes requested by connection at remote endpoint.
-     * @param num number of additional bytes requested
-     */
-    void request(int num)
-    {
-        synchronized (lock) {
-            requested += num;
-            lock.notifyAll();
-        }
-    }
-
-    /**
-     * Disconnect this stream from all connection activity.
-     */
-    void disconnect()
-    {
-        synchronized (lock) {
-            disconnected = true;
-            lock.notifyAll();
-        }
-    }
-
-    /**
-     * Push bytes in output buffer to connection at remote endpoint.
-     * This method blocks until at least one byte has been pushed across.
-     */
-    private void push() throws IOException
-    {
-        int local_requested;
-        synchronized (lock) {
-            while ((local_requested = requested) < 1 && !disconnected) {
-                try {
-                    lock.wait();
-                } catch (InterruptedException e) {
-                }
-            }
-            if (disconnected)
-                throw new IOException("Connection closed");
-        }
-
-        if (local_requested < pos) {
-            manager.sendTransmit(info, buffer, 0, local_requested);
-            System.arraycopy(buffer, local_requested,
-                             buffer, 0, pos - local_requested);
-            pos -= local_requested;
-            synchronized (lock) {
-                requested -= local_requested;
-            }
-        }
-        else {
-            manager.sendTransmit(info, buffer, 0, pos);
-            synchronized (lock) {
-                requested -= pos;
-            }
-            pos = 0;
-        }
-    }
-}
--- a/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPChannel.java	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPChannel.java	Tue Sep 05 10:09:44 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, 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
@@ -67,10 +67,6 @@
     /** frees cached connections that have expired (guarded by freeList) */
     private Future<?> reaper = null;
 
-    /** using multiplexer (for bi-directional applet communication */
-    private boolean usingMultiplexer = false;
-    /** connection multiplexer, if used */
-    private ConnectionMultiplexer multiplexer = null;
     /** connection acceptor (should be in TCPTransport) */
     private ConnectionAcceptor acceptor;
 
@@ -210,113 +206,99 @@
 
         TCPTransport.tcpLog.log(Log.BRIEF, "create connection");
 
-        if (!usingMultiplexer) {
-            Socket sock = ep.newSocket();
-            conn = new TCPConnection(this, sock);
+        Socket sock = ep.newSocket();
+        conn = new TCPConnection(this, sock);
 
+        try {
+            DataOutputStream out =
+                new DataOutputStream(conn.getOutputStream());
+            writeTransportHeader(out);
+
+            // choose protocol (single op if not reusable socket)
+            if (!conn.isReusable()) {
+                out.writeByte(TransportConstants.SingleOpProtocol);
+            } else {
+                out.writeByte(TransportConstants.StreamProtocol);
+                out.flush();
+
+                /*
+                 * Set socket read timeout to configured value for JRMP
+                 * connection handshake; this also serves to guard against
+                 * non-JRMP servers that do not respond (see 4322806).
+                 */
+                int originalSoTimeout = 0;
+                try {
+                    originalSoTimeout = sock.getSoTimeout();
+                    sock.setSoTimeout(handshakeTimeout);
+                } catch (Exception e) {
+                    // if we fail to set this, ignore and proceed anyway
+                }
+
+                DataInputStream in =
+                    new DataInputStream(conn.getInputStream());
+                byte ack = in.readByte();
+                if (ack != TransportConstants.ProtocolAck) {
+                    throw new ConnectIOException(
+                        ack == TransportConstants.ProtocolNack ?
+                        "JRMP StreamProtocol not supported by server" :
+                        "non-JRMP server at remote endpoint");
+                }
+
+                String suggestedHost = in.readUTF();
+                int    suggestedPort = in.readInt();
+                if (TCPTransport.tcpLog.isLoggable(Log.VERBOSE)) {
+                    TCPTransport.tcpLog.log(Log.VERBOSE,
+                        "server suggested " + suggestedHost + ":" +
+                        suggestedPort);
+                }
+
+                // set local host name, if unknown
+                TCPEndpoint.setLocalHost(suggestedHost);
+                // do NOT set the default port, because we don't
+                // know if we can't listen YET...
+
+                // write out default endpoint to match protocol
+                // (but it serves no purpose)
+                TCPEndpoint localEp =
+                    TCPEndpoint.getLocalEndpoint(0, null, null);
+                out.writeUTF(localEp.getHost());
+                out.writeInt(localEp.getPort());
+                if (TCPTransport.tcpLog.isLoggable(Log.VERBOSE)) {
+                    TCPTransport.tcpLog.log(Log.VERBOSE, "using " +
+                        localEp.getHost() + ":" + localEp.getPort());
+                }
+
+                /*
+                 * After JRMP handshake, set socket read timeout to value
+                 * configured for the rest of the lifetime of the
+                 * connection.  NOTE: this timeout, if configured to a
+                 * finite duration, places an upper bound on the time
+                 * that a remote method call is permitted to execute.
+                 */
+                try {
+                    /*
+                     * If socket factory had set a non-zero timeout on its
+                     * own, then restore it instead of using the property-
+                     * configured value.
+                     */
+                    sock.setSoTimeout((originalSoTimeout != 0 ?
+                                       originalSoTimeout :
+                                       responseTimeout));
+                } catch (Exception e) {
+                    // if we fail to set this, ignore and proceed anyway
+                }
+
+                out.flush();
+            }
+        } catch (IOException e) {
             try {
-                DataOutputStream out =
-                    new DataOutputStream(conn.getOutputStream());
-                writeTransportHeader(out);
-
-                // choose protocol (single op if not reusable socket)
-                if (!conn.isReusable()) {
-                    out.writeByte(TransportConstants.SingleOpProtocol);
-                } else {
-                    out.writeByte(TransportConstants.StreamProtocol);
-                    out.flush();
-
-                    /*
-                     * Set socket read timeout to configured value for JRMP
-                     * connection handshake; this also serves to guard against
-                     * non-JRMP servers that do not respond (see 4322806).
-                     */
-                    int originalSoTimeout = 0;
-                    try {
-                        originalSoTimeout = sock.getSoTimeout();
-                        sock.setSoTimeout(handshakeTimeout);
-                    } catch (Exception e) {
-                        // if we fail to set this, ignore and proceed anyway
-                    }
-
-                    DataInputStream in =
-                        new DataInputStream(conn.getInputStream());
-                    byte ack = in.readByte();
-                    if (ack != TransportConstants.ProtocolAck) {
-                        throw new ConnectIOException(
-                            ack == TransportConstants.ProtocolNack ?
-                            "JRMP StreamProtocol not supported by server" :
-                            "non-JRMP server at remote endpoint");
-                    }
-
-                    String suggestedHost = in.readUTF();
-                    int    suggestedPort = in.readInt();
-                    if (TCPTransport.tcpLog.isLoggable(Log.VERBOSE)) {
-                        TCPTransport.tcpLog.log(Log.VERBOSE,
-                            "server suggested " + suggestedHost + ":" +
-                            suggestedPort);
-                    }
-
-                    // set local host name, if unknown
-                    TCPEndpoint.setLocalHost(suggestedHost);
-                    // do NOT set the default port, because we don't
-                    // know if we can't listen YET...
-
-                    // write out default endpoint to match protocol
-                    // (but it serves no purpose)
-                    TCPEndpoint localEp =
-                        TCPEndpoint.getLocalEndpoint(0, null, null);
-                    out.writeUTF(localEp.getHost());
-                    out.writeInt(localEp.getPort());
-                    if (TCPTransport.tcpLog.isLoggable(Log.VERBOSE)) {
-                        TCPTransport.tcpLog.log(Log.VERBOSE, "using " +
-                            localEp.getHost() + ":" + localEp.getPort());
-                    }
-
-                    /*
-                     * After JRMP handshake, set socket read timeout to value
-                     * configured for the rest of the lifetime of the
-                     * connection.  NOTE: this timeout, if configured to a
-                     * finite duration, places an upper bound on the time
-                     * that a remote method call is permitted to execute.
-                     */
-                    try {
-                        /*
-                         * If socket factory had set a non-zero timeout on its
-                         * own, then restore it instead of using the property-
-                         * configured value.
-                         */
-                        sock.setSoTimeout((originalSoTimeout != 0 ?
-                                           originalSoTimeout :
-                                           responseTimeout));
-                    } catch (Exception e) {
-                        // if we fail to set this, ignore and proceed anyway
-                    }
-
-                    out.flush();
-                }
-            } catch (IOException e) {
-                try {
-                    conn.close();
-                } catch (Exception ex) {}
-                if (e instanceof RemoteException) {
-                    throw (RemoteException) e;
-                } else {
-                    throw new ConnectIOException(
-                        "error during JRMP connection establishment", e);
-                }
-            }
-        } else {
-            try {
-                conn = multiplexer.openConnection();
-            } catch (IOException e) {
-                synchronized (this) {
-                    usingMultiplexer = false;
-                    multiplexer = null;
-                }
+                conn.close();
+            } catch (Exception ex) {}
+            if (e instanceof RemoteException) {
+                throw (RemoteException) e;
+            } else {
                 throw new ConnectIOException(
-                    "error opening virtual connection " +
-                    "over multiplexed connection", e);
+                    "error during JRMP connection establishment", e);
             }
         }
         return conn;
@@ -388,28 +370,6 @@
     }
 
     /**
-     * Use given connection multiplexer object to obtain new connections
-     * through this channel.
-     */
-    synchronized void useMultiplexer(ConnectionMultiplexer newMultiplexer) {
-        // for now, always just use the last one given
-        multiplexer = newMultiplexer;
-
-        usingMultiplexer = true;
-    }
-
-    /**
-     * Accept a connection provided over a multiplexed channel.
-     */
-    void acceptMultiplexConnection(Connection conn) {
-        if (acceptor == null) {
-            acceptor = new ConnectionAcceptor(tr);
-            acceptor.startNewAcceptor();
-        }
-        acceptor.accept(conn);
-    }
-
-    /**
      * Closes all the connections in the cache, whether timed out or not.
      */
     public void shedCache() {
@@ -501,7 +461,7 @@
     public void startNewAcceptor() {
         Thread t = AccessController.doPrivileged(
             new NewThreadAction(ConnectionAcceptor.this,
-                                "Multiplex Accept-" + ++ threadNum,
+                                "TCPChannel Accept-" + ++ threadNum,
                                 true));
         t.start();
     }
--- a/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java	Tue Sep 05 10:09:44 2017 -0700
@@ -102,11 +102,6 @@
         AccessController.doPrivileged((PrivilegedAction<Long>) () ->
             Long.getLong("sun.rmi.transport.tcp.threadKeepAliveTime", 60000));
 
-    /** enable multiplexing protocol */
-    private static final boolean enableMultiplexProtocol =     // default false
-            AccessController.doPrivileged((PrivilegedAction<Boolean>) () ->
-                    Boolean.getBoolean("sun.rmi.transport.tcp.enableMultiplexProtocol"));
-
     /** thread pool for connection handlers */
     private static final ExecutorService connectionThreadPool =
         new ThreadPoolExecutor(0, maxConnectionThreads,
@@ -687,6 +682,7 @@
             }
         }
 
+        @SuppressWarnings("fallthrough")
         private void run0() {
             TCPEndpoint endpoint = getEndpoint();
             int port = endpoint.getPort();
@@ -801,59 +797,11 @@
                     break;
 
                 case TransportConstants.MultiplexProtocol:
-
-                    if (!enableMultiplexProtocol) {
-                        if (tcpLog.isLoggable(Log.VERBOSE)) {
-                            tcpLog.log(Log.VERBOSE, "(port " + port +
-                                    ") rejecting multiplex protocol");
-                        }
-
-                        // If MultiplexProtocol is disabled, send NACK immediately.
-                        out.writeByte(TransportConstants.ProtocolNack);
-                        out.flush();
-                        break;
-                    }
-
                     if (tcpLog.isLoggable(Log.VERBOSE)) {
                         tcpLog.log(Log.VERBOSE, "(port " + port +
-                            ") accepting multiplex protocol");
+                                ") rejecting multiplex protocol");
                     }
-
-                    // send ack
-                    out.writeByte(TransportConstants.ProtocolAck);
-
-                    // suggest endpoint (in case client doesn't already have one)
-                    if (tcpLog.isLoggable(Log.VERBOSE)) {
-                        tcpLog.log(Log.VERBOSE, "(port " + port +
-                            ") suggesting " + remoteHost + ":" + remotePort);
-                    }
-
-                    out.writeUTF(remoteHost);
-                    out.writeInt(remotePort);
-                    out.flush();
-
-                    // read endpoint client has decided to use
-                    ep = new TCPEndpoint(in.readUTF(), in.readInt(),
-                                         endpoint.getClientSocketFactory(),
-                                         endpoint.getServerSocketFactory());
-                    if (tcpLog.isLoggable(Log.VERBOSE)) {
-                        tcpLog.log(Log.VERBOSE, "(port " +
-                            port + ") client using " +
-                            ep.getHost() + ":" + ep.getPort());
-                    }
-
-                    ConnectionMultiplexer multiplexer;
-                    synchronized (channelTable) {
-                        // create or find channel for this endpoint
-                        ch = getChannel(ep);
-                        multiplexer =
-                            new ConnectionMultiplexer(ch, bufIn, sockOut,
-                                                      false);
-                        ch.useMultiplexer(multiplexer);
-                    }
-                    multiplexer.run();
-                    break;
-
+                    // Fall-through to reject use of MultiplexProtocol
                 default:
                     // protocol not understood, send nack and close socket
                     out.writeByte(TransportConstants.ProtocolNack);
--- a/src/jdk.charsets/share/classes/sun/nio/cs/ext/GB18030.java.template	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/jdk.charsets/share/classes/sun/nio/cs/ext/GB18030.java.template	Tue Sep 05 10:09:44 2017 -0700
@@ -60,11 +60,12 @@
                 || (cs.name().equals("ISO-8859-8"))
                 || (cs.name().equals("ISO-8859-9"))
                 || (cs.name().equals("ISO-8859-13"))
+                || (cs.name().equals("ISO-8859-15"))
+                || (cs.name().equals("ISO-8859-16"))
                 || (cs.name().equals("UTF-8"))
                 || (cs.name().equals("UTF-16"))
                 || (cs.name().equals("UTF-16LE"))
                 || (cs.name().equals("UTF-16BE"))
-                || (cs.name().equals("ISO-8859-15"))
                 || (cs.name().equals("windows-1251"))
                 || (cs.name().equals("windows-1252"))
                 || (cs.name().equals("windows-1253"))
--- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java	Tue Sep 05 10:09:44 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, 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
@@ -28,6 +28,7 @@
 import java.io.*;
 import static java.io.StreamTokenizer.*;
 import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
 import java.util.*;
 
 import java.security.*;
@@ -202,7 +203,8 @@
             reader = new StringReader(config);
         } else {
             reader = new BufferedReader(new InputStreamReader
-                (new FileInputStream(expand(filename))));
+                (new FileInputStream(expand(filename)),
+                    StandardCharsets.ISO_8859_1));
         }
         parsedKeywords = new HashSet<String>();
         st = new StreamTokenizer(reader);
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ConnectionPool.java	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ConnectionPool.java	Tue Sep 05 10:09:44 2017 -0700
@@ -25,11 +25,14 @@
 
 package jdk.incubator.http;
 
+import java.lang.ref.WeakReference;
 import java.net.InetSocketAddress;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.ListIterator;
 import java.util.Objects;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
 import jdk.incubator.http.internal.common.Utils;
 
 /**
@@ -37,6 +40,21 @@
  */
 final class ConnectionPool {
 
+    // These counters are used to distribute ids for debugging
+    // The ACTIVE_CLEANER_COUNTER will tell how many CacheCleaner
+    // are active at a given time. It will increase when a new
+    // CacheCleaner is started and decrease when it exits.
+    static final AtomicLong ACTIVE_CLEANER_COUNTER = new AtomicLong();
+    // The POOL_IDS_COUNTER increases each time a new ConnectionPool
+    // is created. It may wrap and become negative but will never be
+    // decremented.
+    static final AtomicLong POOL_IDS_COUNTER = new AtomicLong();
+    // The cleanerCounter is used to name cleaner threads within a
+    // a connection pool, and increments monotically.
+    // It may wrap and become negative but will never be
+    // decremented.
+    final AtomicLong cleanerCounter = new AtomicLong();
+
     static final long KEEP_ALIVE = Utils.getIntegerNetProperty(
             "jdk.httpclient.keepalive.timeout", 1200); // seconds
 
@@ -44,7 +62,12 @@
 
     final HashMap<CacheKey,LinkedList<HttpConnection>> plainPool;
     final HashMap<CacheKey,LinkedList<HttpConnection>> sslPool;
-    CacheCleaner cleaner;
+    // A monotically increasing id for this connection pool.
+    // It may be negative (that's OK)
+    // Mostly used for debugging purposes when looking at thread dumps.
+    // Global scope.
+    final long poolID = POOL_IDS_COUNTER.incrementAndGet();
+    final AtomicReference<CacheCleaner> cleanerRef;
 
     /**
      * Entries in connection pool are keyed by destination address and/or
@@ -105,6 +128,7 @@
         plainPool = new HashMap<>();
         sslPool = new HashMap<>();
         expiryList = new LinkedList<>();
+        cleanerRef = new AtomicReference<>();
     }
 
     void start() {
@@ -143,7 +167,7 @@
     findConnection(CacheKey key,
                    HashMap<CacheKey,LinkedList<HttpConnection>> pool) {
         LinkedList<HttpConnection> l = pool.get(key);
-        if (l == null || l.size() == 0) {
+        if (l == null || l.isEmpty()) {
             return null;
         } else {
             HttpConnection c = l.removeFirst();
@@ -175,19 +199,36 @@
         l.add(c);
     }
 
+    static String makeCleanerName(long poolId, long cleanerId) {
+        return "HTTP-Cache-cleaner-" + poolId + "-" + cleanerId;
+    }
+
     // only runs while entries exist in cache
-
-    final class CacheCleaner extends Thread {
+    final static class CacheCleaner extends Thread {
 
         volatile boolean stopping;
+        // A monotically increasing id. May wrap and become negative (that's OK)
+        // Mostly used for debugging purposes when looking at thread dumps.
+        // Scoped per connection pool.
+        final long cleanerID;
+        // A reference to the owning ConnectionPool.
+        // This reference's referent may become null if the HttpClientImpl
+        // that owns this pool is GC'ed.
+        final WeakReference<ConnectionPool> ownerRef;
 
-        CacheCleaner() {
-            super(null, null, "HTTP-Cache-cleaner", 0, false);
+        CacheCleaner(ConnectionPool owner) {
+            this(owner, owner.cleanerCounter.incrementAndGet());
+        }
+
+        CacheCleaner(ConnectionPool owner, long cleanerID) {
+            super(null, null, makeCleanerName(owner.poolID, cleanerID), 0, false);
+            this.cleanerID = cleanerID;
+            this.ownerRef = new WeakReference<>(owner);
             setDaemon(true);
         }
 
         synchronized boolean stopping() {
-            return stopping;
+            return stopping || ownerRef.get() == null;
         }
 
         synchronized void stopCleaner() {
@@ -196,11 +237,19 @@
 
         @Override
         public void run() {
-            while (!stopping()) {
-                try {
-                    Thread.sleep(3000);
-                } catch (InterruptedException e) {}
-                cleanCache();
+            ACTIVE_CLEANER_COUNTER.incrementAndGet();
+            try {
+                while (!stopping()) {
+                    try {
+                        Thread.sleep(3000);
+                    } catch (InterruptedException e) {}
+                    ConnectionPool owner = ownerRef.get();
+                    if (owner == null) return;
+                    owner.cleanCache(this);
+                    owner = null;
+                }
+            } finally {
+                ACTIVE_CLEANER_COUNTER.decrementAndGet();
             }
         }
     }
@@ -217,13 +266,15 @@
                 return;
             }
         }
-        if (expiryList.isEmpty()) {
+        CacheCleaner cleaner = this.cleanerRef.get();
+        if (expiryList.isEmpty() && cleaner != null) {
+            this.cleanerRef.compareAndSet(cleaner, null);
             cleaner.stopCleaner();
-            cleaner = null;
+            cleaner.interrupt();
         }
     }
 
-    private void cleanCache() {
+    private void cleanCache(CacheCleaner cleaner) {
         long now = System.currentTimeMillis() / 1000;
         LinkedList<HttpConnection> closelist = new LinkedList<>();
 
@@ -242,6 +293,10 @@
                     }
                 }
             }
+            if (expiryList.isEmpty() && cleaner != null) {
+                this.cleanerRef.compareAndSet(cleaner, null);
+                cleaner.stopCleaner();
+            }
         }
         for (HttpConnection c : closelist) {
             //System.out.println ("KAC: closing " + c);
@@ -252,10 +307,13 @@
     private synchronized void addToExpiryList(HttpConnection conn) {
         long now = System.currentTimeMillis() / 1000;
         long then = now + KEEP_ALIVE;
-
         if (expiryList.isEmpty()) {
-            cleaner = new CacheCleaner();
-            cleaner.start();
+            CacheCleaner cleaner = new CacheCleaner(this);
+            if (this.cleanerRef.compareAndSet(null, cleaner)) {
+                cleaner.start();
+            }
+            expiryList.add(new ExpiryEntry(conn, then));
+            return;
         }
 
         ListIterator<ExpiryEntry> li = expiryList.listIterator();
--- a/src/jdk.jdwp.agent/share/native/include/jdwpTransport.h	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/jdk.jdwp.agent/share/native/include/jdwpTransport.h	Tue Sep 05 10:09:44 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,8 @@
 #include "jni.h"
 
 enum {
-    JDWPTRANSPORT_VERSION_1_0 = 0x00010000
+    JDWPTRANSPORT_VERSION_1_0 = 0x00010000,
+    JDWPTRANSPORT_VERSION_1_1 = 0x00010001
 };
 
 #ifdef __cplusplus
@@ -142,6 +143,13 @@
                                                jint version,
                                                jdwpTransportEnv** env);
 
+/*
+ * JDWP transport configuration from the agent.
+ */
+typedef struct jdwpTransportConfiguration {
+    /* Field added in JDWPTRANSPORT_VERSION_1_1: */
+    const char* allowed_peers;       /* Peers allowed for connection */
+} jdwpTransportConfiguration;
 
 
 /* Function Interface */
@@ -191,6 +199,9 @@
     jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env,
         char** error);
 
+    /*  12: SetTransportConfiguration added in JDWPTRANSPORT_VERSION_1_1 */
+    jdwpTransportError (JNICALL *SetTransportConfiguration)(jdwpTransportEnv* env,
+        jdwpTransportConfiguration *config);
 };
 
 
@@ -248,6 +259,10 @@
         return functions->GetLastError(this, error);
     }
 
+    /*  SetTransportConfiguration added in JDWPTRANSPORT_VERSION_1_1 */
+    jdwpTransportError SetTransportConfiguration(jdwpTransportEnv* env,
+        return functions->SetTransportConfiguration(this, config);
+    }
 
 #endif /* __cplusplus */
 };
--- a/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c	Tue Sep 05 10:09:44 2017 -0700
@@ -34,6 +34,9 @@
 #ifdef _WIN32
  #include <winsock2.h>
  #include <ws2tcpip.h>
+#else
+ #include <arpa/inet.h>
+ #include <sys/socket.h>
 #endif
 
 /*
@@ -73,6 +76,19 @@
 static jint recv_fully(int, char *, int);
 static jint send_fully(int, char *, int);
 
+/* version >= JDWPTRANSPORT_VERSION_1_1 */
+typedef struct {
+    uint32_t subnet;
+    uint32_t netmask;
+} AllowedPeerInfo;
+
+#define STR(x) #x
+#define MAX_PEER_ENTRIES 32
+#define MAX_PEERS_STR STR(MAX_PEER_ENTRIES)
+static AllowedPeerInfo _peers[MAX_PEER_ENTRIES];
+static int _peers_cnt = 0;
+
+
 /*
  * Record the last error for this thread.
  */
@@ -260,7 +276,7 @@
     char *colon;
     int port;
 
-    memset((void *)sa,0,sizeof(struct sockaddr_in));
+    memset((void *)sa, 0, sizeof(struct sockaddr_in));
     sa->sin_family = AF_INET;
 
     /* check for host:port or port */
@@ -274,7 +290,7 @@
     if (colon == NULL) {
         // bind to localhost only if no address specified
         sa->sin_addr.s_addr = getLocalHostAddress();
-    } else if (strncmp(address,"localhost:",10) == 0) {
+    } else if (strncmp(address, "localhost:", 10) == 0) {
         // optimize for common case
         sa->sin_addr.s_addr = getLocalHostAddress();
     } else if (*address == '*' && *(address+1) == ':') {
@@ -286,7 +302,7 @@
         char *hostname;
         uint32_t addr;
 
-        buf = (*callback->alloc)((int)strlen(address)+1);
+        buf = (*callback->alloc)((int)strlen(address) + 1);
         if (buf == NULL) {
             RETURN_ERROR(JDWPTRANSPORT_ERROR_OUT_OF_MEMORY, "out of memory");
         }
@@ -320,6 +336,131 @@
     return JDWPTRANSPORT_ERROR_NONE;
 }
 
+static const char *
+ip_s2u(const char *instr, uint32_t *ip) {
+    // Convert string representation of ip to integer
+    // in network byte order (big-endian)
+    char t[4] = { 0, 0, 0, 0 };
+    const char *s = instr;
+    int i = 0;
+
+    while (1) {
+        if (*s == '.') {
+            ++i;
+            ++s;
+            continue;
+        }
+        if (*s == 0 || *s == '+' || *s == '/') {
+            break;
+        }
+        if (*s < '0' || *s > '9') {
+            return instr;
+        }
+        t[i] = (t[i] * 10) + (*s - '0');
+        ++s;
+    }
+
+    *ip = *(uint32_t*)(t);
+    return s;
+}
+
+static const char *
+mask_s2u(const char *instr, uint32_t *mask) {
+    // Convert the number of bits to a netmask
+    // in network byte order (big-endian)
+    unsigned char m = 0;
+    const char *s = instr;
+
+    while (1) {
+        if (*s == 0 || *s == '+') {
+            break;
+        }
+        if (*s < '0' || *s > '9') {
+            return instr;
+        }
+        m = (m * 10) + (*s - '0');
+        ++s;
+    }
+
+    if (m == 0 || m > 32) {
+       // Drop invalid input
+       return instr;
+    }
+
+    *mask = htonl(-1 << (32 - m));
+    return s;
+}
+
+static int
+ip_in_subnet(uint32_t subnet, uint32_t mask, uint32_t ipaddr) {
+    return (ipaddr & mask) == subnet;
+}
+
+static jdwpTransportError
+parseAllowedPeers(const char *allowed_peers) {
+    // Build a list of allowed peers from char string
+    // of format 192.168.0.10+192.168.0.0/24
+    const char *s = NULL;
+    const char *p = allowed_peers;
+    uint32_t   ip = 0;
+    uint32_t mask = 0xFFFFFFFF;
+
+    while (1) {
+        s = ip_s2u(p, &ip);
+        if (s == p) {
+            _peers_cnt = 0;
+            fprintf(stderr, "Error in allow option: '%s'\n", s);
+            RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT,
+                         "invalid IP address in allow option");
+        }
+
+        if (*s == '/') {
+            // netmask specified
+            s = mask_s2u(s + 1, &mask);
+            if (*(s - 1) == '/') {
+                // Input is not consumed, something bad happened
+                _peers_cnt = 0;
+                fprintf(stderr, "Error in allow option: '%s'\n", s);
+                RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT,
+                             "invalid netmask in allow option");
+            }
+        } else {
+            // reset netmask
+            mask = 0xFFFFFFFF;
+        }
+
+        if (*s == '+' || *s == 0) {
+            if (_peers_cnt >= MAX_PEER_ENTRIES) {
+                fprintf(stderr, "Error in allow option: '%s'\n", allowed_peers);
+                RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT,
+                             "exceeded max number of allowed peers: " MAX_PEERS_STR);
+            }
+            _peers[_peers_cnt].subnet = ip;
+            _peers[_peers_cnt].netmask = mask;
+            _peers_cnt++;
+            if (*s == 0) {
+                // end of options
+                break;
+            }
+            // advance to next IP block
+            p = s + 1;
+        }
+    }
+    return JDWPTRANSPORT_ERROR_NONE;
+}
+
+static int
+isPeerAllowed(struct sockaddr_in *peer) {
+    int i;
+    for (i = 0; i < _peers_cnt; ++i) {
+        int peer_ip = peer->sin_addr.s_addr;
+        if (ip_in_subnet(_peers[i].subnet, _peers[i].netmask, peer_ip)) {
+            return 1;
+        }
+    }
+
+    return 0;
+}
 
 static jdwpTransportError JNICALL
 socketTransport_getCapabilities(jdwpTransportEnv* env,
@@ -412,7 +553,7 @@
 socketTransport_accept(jdwpTransportEnv* env, jlong acceptTimeout, jlong handshakeTimeout)
 {
     socklen_t socketLen;
-    int err;
+    int err = JDWPTRANSPORT_ERROR_NONE;
     struct sockaddr_in socket;
     jlong startTime = (jlong)0;
 
@@ -474,14 +615,34 @@
             return JDWPTRANSPORT_ERROR_IO_ERROR;
         }
 
-        /* handshake with the debugger */
-        err = handshake(socketFD, handshakeTimeout);
+        /*
+         * version >= JDWPTRANSPORT_VERSION_1_1:
+         * Verify that peer is allowed to connect.
+         */
+        if (_peers_cnt > 0) {
+            if (!isPeerAllowed(&socket)) {
+                char ebuf[64] = { 0 };
+                char buf[INET_ADDRSTRLEN] = { 0 };
+                const char* addr_str = inet_ntop(AF_INET, &(socket.sin_addr), buf, INET_ADDRSTRLEN);
+                sprintf(ebuf, "ERROR: Peer not allowed to connect: %s\n",
+                        (addr_str == NULL) ? "<bad address>" : addr_str);
+                dbgsysSocketClose(socketFD);
+                socketFD = -1;
+                err = JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT;
+                setLastError(err, ebuf);
+            }
+        }
+
+        if (socketFD > 0) {
+          /* handshake with the debugger */
+          err = handshake(socketFD, handshakeTimeout);
+        }
 
         /*
          * If the handshake fails then close the connection. If there if an accept
          * timeout then we must adjust the timeout for the next poll.
          */
-        if (err) {
+        if (err != JDWPTRANSPORT_ERROR_NONE) {
             fprintf(stderr, "Debugger failed to attach: %s\n", getLastError());
             dbgsysSocketClose(socketFD);
             socketFD = -1;
@@ -743,20 +904,20 @@
     packet->type.cmd.len = length;
 
 
-    n = recv_fully(socketFD,(char *)&(packet->type.cmd.id),sizeof(jint));
+    n = recv_fully(socketFD,(char *)&(packet->type.cmd.id), sizeof(jint));
     if (n < (int)sizeof(jint)) {
         RETURN_RECV_ERROR(n);
     }
 
     packet->type.cmd.id = (jint)dbgsysNetworkToHostLong(packet->type.cmd.id);
 
-    n = recv_fully(socketFD,(char *)&(packet->type.cmd.flags),sizeof(jbyte));
+    n = recv_fully(socketFD,(char *)&(packet->type.cmd.flags), sizeof(jbyte));
     if (n < (int)sizeof(jbyte)) {
         RETURN_RECV_ERROR(n);
     }
 
     if (packet->type.cmd.flags & JDWPTRANSPORT_FLAGS_REPLY) {
-        n = recv_fully(socketFD,(char *)&(packet->type.reply.errorCode),sizeof(jbyte));
+        n = recv_fully(socketFD,(char *)&(packet->type.reply.errorCode), sizeof(jbyte));
         if (n < (int)sizeof(jshort)) {
             RETURN_RECV_ERROR(n);
         }
@@ -765,12 +926,12 @@
 
 
     } else {
-        n = recv_fully(socketFD,(char *)&(packet->type.cmd.cmdSet),sizeof(jbyte));
+        n = recv_fully(socketFD,(char *)&(packet->type.cmd.cmdSet), sizeof(jbyte));
         if (n < (int)sizeof(jbyte)) {
             RETURN_RECV_ERROR(n);
         }
 
-        n = recv_fully(socketFD,(char *)&(packet->type.cmd.cmd),sizeof(jbyte));
+        n = recv_fully(socketFD,(char *)&(packet->type.cmd.cmd), sizeof(jbyte));
         if (n < (int)sizeof(jbyte)) {
             RETURN_RECV_ERROR(n);
         }
@@ -814,11 +975,44 @@
     return JDWPTRANSPORT_ERROR_NONE;
 }
 
+static jdwpTransportError JNICALL
+socketTransport_setConfiguration(jdwpTransportEnv* env, jdwpTransportConfiguration* cfg) {
+    const char* allowed_peers = NULL;
+
+    if (cfg == NULL) {
+        RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT,
+                     "NULL pointer to transport configuration is invalid");
+    }
+    allowed_peers = cfg->allowed_peers;
+    _peers_cnt = 0;
+    if (allowed_peers != NULL) {
+        size_t len = strlen(allowed_peers);
+        if (len == 0) { /* Impossible: parseOptions() would reject it */
+            fprintf(stderr, "Error in allow option: '%s'\n", allowed_peers);
+            RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT,
+                         "allow option should not be empty");
+        } else if (*allowed_peers == '*') {
+            if (len != 1) {
+                fprintf(stderr, "Error in allow option: '%s'\n", allowed_peers);
+                RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT,
+                             "allow option '*' cannot be expanded");
+            }
+        } else {
+            int err = parseAllowedPeers(allowed_peers);
+            if (err != JDWPTRANSPORT_ERROR_NONE) {
+                return err;
+            }
+        }
+    }
+    return JDWPTRANSPORT_ERROR_NONE;
+}
+
 jint JNICALL
 jdwpTransport_OnLoad(JavaVM *vm, jdwpTransportCallback* cbTablePtr,
-                     jint version, jdwpTransportEnv** result)
+                     jint version, jdwpTransportEnv** env)
 {
-    if (version != JDWPTRANSPORT_VERSION_1_0) {
+    if (version < JDWPTRANSPORT_VERSION_1_0 ||
+        version > JDWPTRANSPORT_VERSION_1_1) {
         return JNI_EVERSION;
     }
     if (initialized) {
@@ -842,7 +1036,10 @@
     interface.ReadPacket = &socketTransport_readPacket;
     interface.WritePacket = &socketTransport_writePacket;
     interface.GetLastError = &socketTransport_getLastError;
-    *result = &single_env;
+    if (version >= JDWPTRANSPORT_VERSION_1_1) {
+        interface.SetTransportConfiguration = &socketTransport_setConfiguration;
+    }
+    *env = &single_env;
 
     /* initialized TLS */
     tlsIndex = dbgsysTlsAlloc();
--- a/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c	Tue Sep 05 10:09:44 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -89,6 +89,7 @@
     char *name;
     char *address;
     long timeout;
+    char *allow;
 } TransportSpec;
 
 /*
@@ -564,7 +565,8 @@
 
     LOG_MISC(("Begin startTransport"));
     serror = transport_startTransport(enumArg->isServer, transport->name,
-                                     transport->address, transport->timeout);
+                                      transport->address, transport->timeout,
+                                      transport->allow);
     if (serror != JDWP_ERROR(NONE)) {
         ERROR_MESSAGE(("JDWP Transport %s failed to initialize, %s(%d)",
                 transport->name, jdwpErrorText(serror), serror));
@@ -1060,7 +1062,6 @@
         if (transports == NULL) {
             EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"transports");
         }
-
     }
 
     current = names;
@@ -1080,6 +1081,9 @@
                 goto syntax_error;
             }
             currentTransport->name = current;
+            currentTransport->address = NULL;
+            currentTransport->allow = NULL;
+            currentTransport->timeout = 0L;
             current += strlen(current) + 1;
         } else if (strcmp(buf, "address") == 0) {
             if (currentTransport == NULL) {
@@ -1092,7 +1096,18 @@
             }
             currentTransport->address = current;
             current += strlen(current) + 1;
-        } else if (strcmp(buf, "timeout") == 0) {
+        } else if (strcmp(buf, "allow") == 0) {
+            if (currentTransport == NULL) {
+                errmsg = "allow specified without transport";
+                goto bad_option_with_errmsg;
+            }
+            /*LINTED*/
+            if (!get_tok(&str, current, (int)(end - current), ',')) {
+                goto syntax_error;
+            }
+            currentTransport->allow = current;
+            current += strlen(current) + 1;
+         } else if (strcmp(buf, "timeout") == 0) {
             if (currentTransport == NULL) {
                 errmsg = "timeout specified without transport";
                 goto bad_option_with_errmsg;
--- a/src/jdk.jdwp.agent/share/native/libjdwp/transport.c	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/transport.c	Tue Sep 05 10:09:44 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, 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
@@ -29,7 +29,9 @@
 #include "debugLoop.h"
 #include "sys.h"
 
-static jdwpTransportEnv *transport;
+static jdwpTransportEnv *transport = NULL;
+static unsigned transportVersion = JDWPTRANSPORT_VERSION_1_0;
+
 static jrawMonitorID listenerLock;
 static jrawMonitorID sendLock;
 
@@ -41,6 +43,8 @@
     jdwpTransportEnv *transport;
     char *address;
     long timeout;
+    char *allowed_peers;
+    unsigned transportVersion;
 } TransportInfo;
 
 static struct jdwpTransportCallback callback = {jvmtiAllocate, jvmtiDeallocate};
@@ -135,7 +139,7 @@
  * JDK 1.2 javai.c v1.61
  */
 static jdwpError
-loadTransport(const char *name, jdwpTransportEnv **transportPtr)
+loadTransport(const char *name, TransportInfo *info)
 {
     JNIEnv                 *env;
     jdwpTransport_OnLoad_t  onLoad;
@@ -147,6 +151,10 @@
         ERROR_MESSAGE(("library name is empty"));
         return JDWP_ERROR(TRANSPORT_LOAD);
     }
+    if (info == NULL) {
+        ERROR_MESSAGE(("internal error: info should not be NULL"));
+        return JDWP_ERROR(TRANSPORT_LOAD);
+    }
 
     /* First, look in sun.boot.library.path. This should find the standard
      *  dt_socket and dt_shmem transport libraries, or any library
@@ -192,22 +200,34 @@
 
     /* Get transport interface */
     env = getEnv();
-    if ( env != NULL ) {
-        jdwpTransportEnv *t;
-        JavaVM           *jvm;
-        jint              ver;
+    if (env != NULL) {
+        jdwpTransportEnv *t = NULL;
+        JavaVM           *jvm = NULL;
+        jint              rc;
+        size_t            i;
+        /* If a new version is added here, update 'case JNI_EVERSION' below. */
+        jint supported_versions[2] = {JDWPTRANSPORT_VERSION_1_1, JDWPTRANSPORT_VERSION_1_0};
 
         JNI_FUNC_PTR(env,GetJavaVM)(env, &jvm);
-        ver = (*onLoad)(jvm, &callback, JDWPTRANSPORT_VERSION_1_0, &t);
-        if (ver != JNI_OK) {
-            switch (ver) {
+
+        /* Try version 1.1 first, fallback to 1.0 on error */
+        for (i = 0; i < sizeof(supported_versions); ++i) {
+            rc = (*onLoad)(jvm, &callback, supported_versions[i], &t);
+            if (rc != JNI_EVERSION) {
+                info->transportVersion = supported_versions[i];
+                break;
+            }
+        }
+
+        if (rc != JNI_OK) {
+            switch (rc) {
                 case JNI_ENOMEM :
                     ERROR_MESSAGE(("insufficient memory to complete initialization"));
                     break;
 
                 case JNI_EVERSION :
-                    ERROR_MESSAGE(("transport doesn't recognize version %x",
-                        JDWPTRANSPORT_VERSION_1_0));
+                    ERROR_MESSAGE(("transport doesn't recognize all supported versions: "
+                                   "{ 1_1, 1_0 }"));
                     break;
 
                 case JNI_EEXIST :
@@ -215,13 +235,19 @@
                     break;
 
                 default:
-                    ERROR_MESSAGE(("unrecognized error %d from transport", ver));
+                    ERROR_MESSAGE(("unrecognized error %d from transport", rc));
                     break;
             }
 
             return JDWP_ERROR(TRANSPORT_INIT);
         }
-        *transportPtr = t;
+
+        /* Store transport version to global variable to be able to
+         * set correct transport version for subsequent connect,
+         * even if info is already deallocated.
+         */
+        transportVersion = info->transportVersion;
+        info->transport = t;
     } else {
         return JDWP_ERROR(TRANSPORT_LOAD);
     }
@@ -314,7 +340,6 @@
 
     info = (TransportInfo*)(void*)arg;
     t = info->transport;
-
     rc = (*t)->Accept(t, info->timeout, 0);
 
     /* System property no longer needed */
@@ -339,8 +364,10 @@
 static void JNICALL
 attachThread(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg)
 {
+    TransportInfo *info = (TransportInfo*)(void*)arg;
+
     LOG_MISC(("Begin attach thread"));
-    connectionInitiated((jdwpTransportEnv *)(void*)arg);
+    connectionInitiated(info->transport);
     LOG_MISC(("End attach thread"));
 }
 
@@ -418,13 +445,26 @@
 
 jdwpError
 transport_startTransport(jboolean isServer, char *name, char *address,
-                         long timeout)
+                         long timeout, char *allowed_peers)
 {
     jvmtiStartFunction func;
-    jdwpTransportEnv *trans;
     char threadName[MAXPATHLEN + 100];
     jint err;
     jdwpError serror;
+    jdwpTransportConfiguration cfg = {0};
+    TransportInfo *info;
+    jdwpTransportEnv *trans;
+
+    info = jvmtiAllocate(sizeof(*info));
+    if (info == NULL) {
+        return JDWP_ERROR(OUT_OF_MEMORY);
+    }
+
+    info->transport = transport;
+    info->transportVersion = transportVersion;
+    info->name = NULL;
+    info->address = NULL;
+    info->allowed_peers = NULL;
 
     /*
      * If the transport is already loaded then use it
@@ -434,28 +474,24 @@
      * That probably means we have a bag a transport environments
      * to correspond to the transports bag.
      */
-    if (transport != NULL) {
-        trans = transport;
-    } else {
-        serror = loadTransport(name, &trans);
+    if (info->transport == NULL) {
+        serror = loadTransport(name, info);
         if (serror != JDWP_ERROR(NONE)) {
+            jvmtiDeallocate(info);
             return serror;
         }
     }
 
+    // Cache the value
+    trans = info->transport;
+
     if (isServer) {
-
         char *retAddress;
         char *launchCommand;
-        TransportInfo *info;
         jvmtiError error;
         int len;
         char* prop_value;
 
-        info = jvmtiAllocate(sizeof(*info));
-        if (info == NULL) {
-            return JDWP_ERROR(OUT_OF_MEMORY);
-        }
         info->timeout = timeout;
 
         info->name = jvmtiAllocate((int)strlen(name)+1);
@@ -465,7 +501,6 @@
         }
         (void)strcpy(info->name, name);
 
-        info->address = NULL;
         if (address != NULL) {
             info->address = jvmtiAllocate((int)strlen(address)+1);
             if (info->address == NULL) {
@@ -475,7 +510,32 @@
             (void)strcpy(info->address, address);
         }
 
-        info->transport = trans;
+        if (info->transportVersion == JDWPTRANSPORT_VERSION_1_0) {
+            if (allowed_peers != NULL) {
+                ERROR_MESSAGE(("Allow parameter is specified but transport doesn't support it"));
+                serror = JDWP_ERROR(TRANSPORT_INIT);
+                goto handleError;
+            }
+        } else {
+            /* Memory is allocated only for transport versions > 1.0
+             * as the version 1.0 does not support the 'allow' option.
+             */
+            if (allowed_peers != NULL) {
+                info->allowed_peers = jvmtiAllocate((int)strlen(allowed_peers) + 1);
+                if (info->allowed_peers == NULL) {
+                    serror = JDWP_ERROR(OUT_OF_MEMORY);
+                    goto handleError;
+                }
+                (void)strcpy(info->allowed_peers, allowed_peers);
+            }
+            cfg.allowed_peers = info->allowed_peers;
+            err = (*trans)->SetTransportConfiguration(trans, &cfg);
+            if (err != JDWPTRANSPORT_ERROR_NONE) {
+                printLastError(trans, err);
+                serror = JDWP_ERROR(TRANSPORT_INIT);
+                goto handleError;
+            }
+        }
 
         err = (*trans)->StartListening(trans, address, &retAddress);
         if (err != JDWPTRANSPORT_ERROR_NONE) {
@@ -527,6 +587,7 @@
 handleError:
         jvmtiDeallocate(info->name);
         jvmtiDeallocate(info->address);
+        jvmtiDeallocate(info->allowed_peers);
         jvmtiDeallocate(info);
     } else {
         /*
@@ -543,6 +604,10 @@
          if (err != JDWPTRANSPORT_ERROR_NONE) {
              printLastError(trans, err);
              serror = JDWP_ERROR(TRANSPORT_INIT);
+             /* The name, address and allowed_peers fields in 'info'
+              * are not allocated in the non-server case so
+              * they do not need to be freed. */
+             jvmtiDeallocate(info);
              return serror;
          }
 
@@ -553,7 +618,7 @@
          (void)strcat(threadName, name);
 
          func = &attachThread;
-         err = spawnNewThread(func, (void*)trans, threadName);
+         err = spawnNewThread(func, (void*)info, threadName);
          serror = map2jdwpError(err);
     }
     return serror;
--- a/src/jdk.jdwp.agent/share/native/libjdwp/transport.h	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/transport.h	Tue Sep 05 10:09:44 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,8 @@
 
 void transport_initialize(void);
 void transport_reset(void);
-jdwpError transport_startTransport(jboolean isServer, char *name, char *address, long timeout);
+jdwpError transport_startTransport(jboolean isServer, char *name, char *address,
+                                   long timeout, char *allowed_peers);
 
 jint transport_receivePacket(jdwpPacket *);
 jint transport_sendPacket(jdwpPacket *);
--- a/src/linux/doc/man/java.1	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/linux/doc/man/java.1	Tue Sep 05 10:09:44 2017 -0700
@@ -921,11 +921,6 @@
 at startup, the class objects in the application will be left untouched during GC and will always be considered live\&. This can result in more memory being permanently occupied which, if not used carefully, will throw an out of memory exception\&.
 .RE
 .PP
-\-Xprof
-.RS 4
-Profiles the running program and sends profiling data to standard output\&. This option is provided as a utility that is useful in program development and is not intended to be used in production systems\&.
-.RE
-.PP
 \-Xrs
 .RS 4
 Reduces the use of operating system signals by the JVM\&.
--- a/src/solaris/doc/sun/man/man1/java.1	Sun Sep 03 19:31:11 2017 +0530
+++ b/src/solaris/doc/sun/man/man1/java.1	Tue Sep 05 10:09:44 2017 -0700
@@ -921,11 +921,6 @@
 at startup, the class objects in the application will be left untouched during GC and will always be considered live\&. This can result in more memory being permanently occupied which, if not used carefully, will throw an out of memory exception\&.
 .RE
 .PP
-\-Xprof
-.RS 4
-Profiles the running program and sends profiling data to standard output\&. This option is provided as a utility that is useful in program development and is not intended to be used in production systems\&.
-.RE
-.PP
 \-Xrs
 .RS 4
 Reduces the use of operating system signals by the JVM\&.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/jdi/BasicJDWPConnectionTest.java	Tue Sep 05 10:09:44 2017 -0700
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Smoke test for JDWP hardening
+ * @library /lib/testlibrary
+ * @library /test/lib
+ * @run driver BasicJDWPConnectionTest
+ */
+
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+import java.net.Socket;
+import java.net.SocketException;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.testlibrary.Utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class BasicJDWPConnectionTest {
+
+    public static int handshake(int port) throws IOException {
+        // Connect to the debuggee and handshake
+        int res = -1;
+        Socket s = null;
+        try {
+            s = new Socket("localhost", port);
+            s.getOutputStream().write("JDWP-Handshake".getBytes("UTF-8"));
+            byte[] buffer = new byte[24];
+            res = s.getInputStream().read(buffer);
+        }
+        catch (SocketException ex) {
+            // pass
+        } finally {
+            if (s != null) {
+                s.close();
+            }
+        }
+        return res;
+    }
+
+    public static ArrayList<String> prepareCmd(int port, String allowOpt) {
+         String address = "*:" + String.valueOf(port);
+         ArrayList<String> cmd = new ArrayList<>();
+
+         String jdwpArgs = "-agentlib:jdwp=transport=dt_socket,server=y," +
+                           "suspend=n,address=" + address + allowOpt;
+         cmd.add(jdwpArgs);
+         return cmd;
+    }
+
+    public static void positiveTest(String testName, String allowOpt)
+        throws InterruptedException, IOException {
+        System.err.println("\nStarting " + testName);
+        int port = Utils.getFreePort();
+        ArrayList<String> cmd = prepareCmd(port, allowOpt);
+
+        LingeredApp a = LingeredApp.startApp(cmd);
+        int res = handshake(port);
+        a.stopApp();
+        if (res < 0) {
+            throw new RuntimeException(testName + " FAILED");
+        }
+        System.err.println(testName + " PASSED");
+    }
+
+    public static void negativeTest(String testName, String allowOpt)
+        throws InterruptedException, IOException {
+        System.err.println("\nStarting " + testName);
+        int port = Utils.getFreePort();
+        ArrayList<String> cmd = prepareCmd(port, allowOpt);
+
+        LingeredApp a = LingeredApp.startApp(cmd);
+        int res = handshake(port);
+        a.stopApp();
+        if (res > 0) {
+            System.err.println(testName + ": res=" + res);
+            throw new RuntimeException(testName + " FAILED");
+        }
+        System.err.println(testName + ": returned a negative code as expected: " + res);
+        System.err.println(testName + " PASSED");
+    }
+
+    public static void badAllowOptionTest(String testName, String allowOpt)
+        throws InterruptedException, IOException {
+        System.err.println("\nStarting " + testName);
+        int port = Utils.getFreePort();
+        ArrayList<String> cmd = prepareCmd(port, allowOpt);
+
+        try {
+            LingeredApp a = LingeredApp.startApp(cmd);
+        } catch (IOException ex) {
+            System.err.println(testName + ": caught expected IOException");
+            System.err.println(testName + " PASSED");
+            return;
+        }
+        throw new RuntimeException(testName + " FAILED");
+    }
+
+    public static void DefaultTest() throws InterruptedException, IOException {
+        // No allow option is the same as the allow option ',allow=*' is passed
+        String allowOpt = "";
+        positiveTest("DefaultTest", allowOpt);
+    }
+
+    static void ExplicitDefaultTest() throws InterruptedException, IOException {
+        // Explicit permission for connections from everywhere
+        String allowOpt = ",allow=*";
+        positiveTest("ExplicitDefaultTest" ,allowOpt);
+    }
+
+    public static void AllowTest() throws InterruptedException, IOException {
+        String allowOpt = ",allow=127.0.0.1";
+        positiveTest("AllowTest", allowOpt);
+    }
+
+    public static void MultiAllowTest() throws InterruptedException, IOException {
+        String allowOpt = ",allow=127.0.0.1+10.0.0.0/8+172.16.0.0/12+192.168.0.0/24";
+        positiveTest("MultiAllowTest", allowOpt);
+    }
+
+    public static void DenyTest() throws InterruptedException, IOException {
+        // Bad allow address
+        String allowOpt = ",allow=0.0.0.0";
+        negativeTest("DenyTest", allowOpt);
+    }
+
+    public static void MultiDenyTest() throws InterruptedException, IOException {
+        // Wrong separator ';' is used for allow option
+        String allowOpt = ",allow=127.0.0.1;192.168.0.0/24";
+        badAllowOptionTest("MultiDenyTest", allowOpt);
+    }
+
+    public static void EmptyAllowOptionTest() throws InterruptedException, IOException {
+        // Empty allow option
+        String allowOpt = ",allow=";
+        badAllowOptionTest("EmptyAllowOptionTest", allowOpt);
+    }
+
+    public static void ExplicitMultiDefault1Test() throws InterruptedException, IOException {
+        // Bad mix of allow option '*' with address value
+        String allowOpt = ",allow=*+allow=127.0.0.1";
+        badAllowOptionTest("ExplicitMultiDefault1Test", allowOpt);
+    }
+
+    public static void ExplicitMultiDefault2Test() throws InterruptedException, IOException {
+        // Bad mix of allow address value with '*'
+        String allowOpt = ",allow=allow=127.0.0.1+*";
+        badAllowOptionTest("ExplicitMultiDefault2Test", allowOpt);
+    }
+
+    public static void main(String[] args) {
+        try {
+            DefaultTest();
+            ExplicitDefaultTest();
+            AllowTest();
+            MultiAllowTest();
+            DenyTest();
+            MultiDenyTest();
+            EmptyAllowOptionTest();
+            ExplicitMultiDefault1Test();
+            ExplicitMultiDefault2Test();
+            System.err.println("\nTest PASSED");
+        } catch (InterruptedException ex) {
+            System.err.println("\nTest ERROR, getFreePort");
+            ex.printStackTrace();
+            System.exit(3);
+        } catch (IOException ex) {
+            System.err.println("\nTest ERROR");
+            ex.printStackTrace();
+            System.exit(3);
+        }
+    }
+}
--- a/test/java/net/MulticastSocket/TestInterfaces.java	Sun Sep 03 19:31:11 2017 +0530
+++ b/test/java/net/MulticastSocket/TestInterfaces.java	Tue Sep 05 10:09:44 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,15 @@
 /*
  * @test
  * @bug 4422122
- * @key intermittent
  * @summary Test that MulticastSocket.getInterface returns the
  *          same InetAddress set by MulticastSocket.setInterface
+ * @library /test/lib
+ * @build jdk.test.lib.NetworkConfiguration
+ *        jdk.test.lib.Platform
+ * @run main TestInterfaces
  */
+import jdk.test.lib.NetworkConfiguration;
+
 import java.net.*;
 import java.util.Arrays;
 import java.util.Collections;
@@ -52,6 +57,10 @@
             if (isWindows && dName != null && dName.contains("Teredo"))
                 continue;
 
+            // Skip those interfaces not up or not support multicast
+            if (!ni.isUp() || !ni.supportsMulticast())
+                continue;
+
             /*
              * Test MulticastSocket.getInterface
              */
@@ -115,6 +124,8 @@
         }
 
         if (failures > 0) {
+            System.err.println("********************************");
+            NetworkConfiguration.printSystemConfiguration(System.err);
             System.out.println("********************************");
             throw new Exception(failures + " test(s) failed!!!");
         }
--- a/test/java/net/httpclient/whitebox/Driver.java	Sun Sep 03 19:31:11 2017 +0530
+++ b/test/java/net/httpclient/whitebox/Driver.java	Tue Sep 05 10:09:44 2017 -0700
@@ -23,9 +23,10 @@
 
 /*
  * @test
- * @bug 8151299 8164704
- * @modules jdk.incubator.httpclient
+ * @bug 8151299 8164704 8187044
+ * @modules jdk.incubator.httpclient java.management
  * @run testng jdk.incubator.httpclient/jdk.incubator.http.SelectorTest
  * @run testng jdk.incubator.httpclient/jdk.incubator.http.RawChannelTest
  * @run testng jdk.incubator.httpclient/jdk.incubator.http.ResponseHeadersTest
+ * @run main/othervm --add-reads jdk.incubator.httpclient=java.management jdk.incubator.httpclient/jdk.incubator.http.ConnectionPoolTest
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/net/httpclient/whitebox/jdk.incubator.httpclient/jdk/incubator/http/ConnectionPoolTest.java	Tue Sep 05 10:09:44 2017 -0700
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.incubator.http;
+
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.net.Authenticator;
+import java.net.CookieManager;
+import java.net.InetSocketAddress;
+import java.net.ProxySelector;
+import java.nio.ByteBuffer;
+import java.nio.channels.SocketChannel;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executor;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLParameters;
+import jdk.incubator.http.internal.common.ByteBufferReference;
+
+/**
+ * @summary Verifies that the ConnectionPool won't prevent an HttpClient
+ *          from being GC'ed. Verifies that the ConnectionPool has at most
+ *          one CacheCleaner thread running.
+ * @bug 8187044
+ * @author danielfuchs
+ */
+public class ConnectionPoolTest {
+
+    static long getActiveCleaners() throws ClassNotFoundException {
+        // ConnectionPool.ACTIVE_CLEANER_COUNTER.get()
+        // ConnectionPoolTest.class.getModule().addReads(
+        //      Class.forName("java.lang.management.ManagementFactory").getModule());
+        return java.util.stream.Stream.of(ManagementFactory.getThreadMXBean()
+                .dumpAllThreads(false, false))
+              .filter(t -> t.getThreadName().startsWith("HTTP-Cache-cleaner"))
+              .count();
+    }
+
+    public static void main(String[] args) throws Exception {
+        testCacheCleaners();
+    }
+
+    public static void testCacheCleaners() throws Exception {
+        ConnectionPool pool = new ConnectionPool();
+        HttpClient client = new HttpClientStub(pool);
+        InetSocketAddress proxy = InetSocketAddress.createUnresolved("bar", 80);
+        System.out.println("Adding 10 connections to pool");
+        for (int i=0; i<10; i++) {
+            InetSocketAddress addr = InetSocketAddress.createUnresolved("foo"+i, 80);
+            HttpConnection c1 = new HttpConnectionStub(client, addr, proxy, true);
+            pool.returnToPool(c1);
+        }
+        while (getActiveCleaners() == 0) {
+            System.out.println("Waiting for cleaner to start");
+            Thread.sleep(10);
+        }
+        System.out.println("Active CacheCleaners: " + getActiveCleaners());
+        if (getActiveCleaners() > 1) {
+            throw new RuntimeException("Too many CacheCleaner active: "
+                    + getActiveCleaners());
+        }
+        System.out.println("Removing 9 connections from pool");
+        for (int i=0; i<9; i++) {
+            InetSocketAddress addr = InetSocketAddress.createUnresolved("foo"+i, 80);
+            HttpConnection c2 = pool.getConnection(true, addr, proxy);
+            if (c2 == null) {
+                throw new RuntimeException("connection not found for " + addr);
+            }
+        }
+        System.out.println("Active CacheCleaners: " + getActiveCleaners());
+        if (getActiveCleaners() != 1) {
+            throw new RuntimeException("Wrong number of CacheCleaner active: "
+                    + getActiveCleaners());
+        }
+        System.out.println("Removing last connection from pool");
+        for (int i=9; i<10; i++) {
+            InetSocketAddress addr = InetSocketAddress.createUnresolved("foo"+i, 80);
+            HttpConnection c2 = pool.getConnection(true, addr, proxy);
+            if (c2 == null) {
+                throw new RuntimeException("connection not found for " + addr);
+            }
+        }
+        System.out.println("Active CacheCleaners: " + getActiveCleaners()
+                + " (may be 0 or may still be 1)");
+        if (getActiveCleaners() > 1) {
+            throw new RuntimeException("Too many CacheCleaner active: "
+                    + getActiveCleaners());
+        }
+        InetSocketAddress addr = InetSocketAddress.createUnresolved("foo", 80);
+        HttpConnection c = new HttpConnectionStub(client, addr, proxy, true);
+        System.out.println("Adding/Removing one connection from pool 20 times in a loop");
+        for (int i=0; i<20; i++) {
+            pool.returnToPool(c);
+            HttpConnection c2 = pool.getConnection(true, addr, proxy);
+            if (c2 == null) {
+                throw new RuntimeException("connection not found for " + addr);
+            }
+            if (c2 != c) {
+                throw new RuntimeException("wrong connection found for " + addr);
+            }
+        }
+        if (getActiveCleaners() > 1) {
+            throw new RuntimeException("Too many CacheCleaner active: "
+                    + getActiveCleaners());
+        }
+        ReferenceQueue<HttpClient> queue = new ReferenceQueue<>();
+        WeakReference<HttpClient> weak = new WeakReference<>(client, queue);
+        System.gc();
+        Reference.reachabilityFence(pool);
+        client = null; pool = null; c = null;
+        while (true) {
+            long cleaners = getActiveCleaners();
+            System.out.println("Waiting for GC to release stub HttpClient;"
+                    + " active cache cleaners: " + cleaners);
+            System.gc();
+            Reference<?> ref = queue.remove(1000);
+            if (ref == weak) {
+                System.out.println("Stub HttpClient GC'ed");
+                break;
+            }
+        }
+        while (getActiveCleaners() > 0) {
+            System.out.println("Waiting for CacheCleaner to stop");
+            Thread.sleep(1000);
+        }
+        System.out.println("Active CacheCleaners: "
+                + getActiveCleaners());
+
+        if (getActiveCleaners() > 0) {
+            throw new RuntimeException("Too many CacheCleaner active: "
+                    + getActiveCleaners());
+        }
+    }
+    static <T> T error() {
+        throw new InternalError("Should not reach here: wrong test assumptions!");
+    }
+
+    // Emulates an HttpConnection that has a strong reference to its HttpClient.
+    static class HttpConnectionStub extends HttpConnection {
+
+        public HttpConnectionStub(HttpClient client,
+                InetSocketAddress address,
+                InetSocketAddress proxy,
+                boolean secured) {
+            super(address, null);
+            this.key = ConnectionPool.cacheKey(address, proxy);
+            this.address = address;
+            this.proxy = proxy;
+            this.secured = secured;
+            this.client = client;
+        }
+
+        InetSocketAddress proxy;
+        InetSocketAddress address;
+        boolean secured;
+        ConnectionPool.CacheKey key;
+        HttpClient client;
+
+        // All these return something
+        @Override boolean connected() {return true;}
+        @Override boolean isSecure() {return secured;}
+        @Override boolean isProxied() {return proxy!=null;}
+        @Override ConnectionPool.CacheKey cacheKey() {return key;}
+        @Override public void close() {}
+        @Override void shutdownInput() throws IOException {}
+        @Override void shutdownOutput() throws IOException {}
+        public String toString() {
+            return "HttpConnectionStub: " + address + " proxy: " + proxy;
+        }
+
+        // All these throw errors
+        @Override
+        public void connect() throws IOException, InterruptedException {error();}
+        @Override public CompletableFuture<Void> connectAsync() {return error();}
+        @Override SocketChannel channel() {return error();}
+        @Override void flushAsync() throws IOException {error();}
+        @Override
+        protected ByteBuffer readImpl() throws IOException {return error();}
+        @Override CompletableFuture<Void> whenReceivingResponse() {return error();}
+        @Override
+        long write(ByteBuffer[] buffers, int start, int number) throws IOException {
+            throw (Error)error();
+        }
+        @Override
+        long write(ByteBuffer buffer) throws IOException {throw (Error)error();}
+        @Override
+        void writeAsync(ByteBufferReference[] buffers) throws IOException {
+            error();
+        }
+        @Override
+        void writeAsyncUnordered(ByteBufferReference[] buffers)
+                throws IOException {
+            error();
+        }
+    }
+    // Emulates an HttpClient that has a strong reference to its connection pool.
+    static class HttpClientStub extends HttpClient {
+        public HttpClientStub(ConnectionPool pool) {
+            this.pool = pool;
+        }
+        final ConnectionPool pool;
+        @Override public Optional<CookieManager> cookieManager() {return error();}
+        @Override public HttpClient.Redirect followRedirects() {return error();}
+        @Override public Optional<ProxySelector> proxy() {return error();}
+        @Override public SSLContext sslContext() {return error();}
+        @Override public Optional<SSLParameters> sslParameters() {return error();}
+        @Override public Optional<Authenticator> authenticator() {return error();}
+        @Override public HttpClient.Version version() {return HttpClient.Version.HTTP_1_1;}
+        @Override public Executor executor() {return error();}
+        @Override
+        public <T> HttpResponse<T> send(HttpRequest req,
+                HttpResponse.BodyHandler<T> responseBodyHandler)
+                throws IOException, InterruptedException {
+            return error();
+        }
+        @Override
+        public <T> CompletableFuture<HttpResponse<T>> sendAsync(HttpRequest req,
+                HttpResponse.BodyHandler<T> responseBodyHandler) {
+            return error();
+        }
+        @Override
+        public <U, T> CompletableFuture<U> sendAsync(HttpRequest req,
+                HttpResponse.MultiProcessor<U, T> multiProcessor) {
+            return error();
+        }
+    }
+
+}
--- a/test/java/nio/charset/Charset/CharsetContainmentTest.java	Sun Sep 03 19:31:11 2017 +0530
+++ b/test/java/nio/charset/Charset/CharsetContainmentTest.java	Tue Sep 05 10:09:44 2017 -0700
@@ -32,9 +32,9 @@
 public class CharsetContainmentTest {
     static String[] encodings =
         { "US-ASCII", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-8",
-          "windows-1252", "ISO-8859-1", "ISO-8859-15", "ISO-8859-2",
-          "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6",
-          "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-13",
+          "windows-1252", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3",
+          "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7",
+          "ISO-8859-8", "ISO-8859-9", "ISO-8859-13", "ISO-8859-15", "ISO-8859-16",
           "ISO-2022-JP", "ISO-2022-KR",
 
           // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder
@@ -57,7 +57,6 @@
            encodings,
           {"US-ASCII", "windows-1252"},
           {"US-ASCII", "ISO-8859-1"},
-          {"US-ASCII", "ISO-8859-15"},
           {"US-ASCII", "ISO-8859-2"},
           {"US-ASCII", "ISO-8859-3"},
           {"US-ASCII", "ISO-8859-4"},
@@ -67,6 +66,8 @@
           {"US-ASCII", "ISO-8859-8"},
           {"US-ASCII", "ISO-8859-9"},
           {"US-ASCII", "ISO-8859-13"},
+          {"US-ASCII", "ISO-8859-15"},
+          {"US-ASCII", "ISO-8859-16"},
           {"ISO-2022-JP"},
           {"ISO-2022-KR"},
           // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder
--- a/test/java/nio/charset/Charset/RegisteredCharsets.java	Sun Sep 03 19:31:11 2017 +0530
+++ b/test/java/nio/charset/Charset/RegisteredCharsets.java	Tue Sep 05 10:09:44 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /* @test
  * @bug 4473201 4696726 4652234 4482298 4784385 4966197 4267354 5015668
-        6911753 8071447
+        6911753 8071447 8186751
  * @summary Check that registered charsets are actually registered
  * @modules jdk.charsets
  */
@@ -42,7 +42,8 @@
                             "ISO-8859-1", "ISO-8859-2", "ISO-8859-3",
                             "ISO-8859-4", "ISO-8859-5", "ISO-8859-6",
                             "ISO-8859-7", "ISO-8859-8", "ISO-8859-9",
-                            "ISO-8859-13", "ISO-8859-15", "windows-1251",
+                            "ISO-8859-13", "ISO-8859-15", "ISO-8859-16",
+                            "windows-1251",
                             "windows-1252", "windows-1253", "windows-1254",
                             "windows-1255", "windows-1256", "windows-31j",
                             "Shift_JIS", "JIS_X0201", "JIS_X0212-1990",
@@ -416,6 +417,8 @@
                 new String[] {
                     // IANA alias
                     "ISO_8859-15",
+                    "Latin-9",
+                    "csISO885915",
                     // JDK historical aliases
                     "8859_15",
                     "ISO-8859-15",
@@ -432,8 +435,17 @@
                     "csISOlatin0",
                     "csISOlatin9",
                     "ISO8859_15_FDIS"
+                });
 
-                });
+        aliasCheck("ISO-8859-16",
+                new String[] {
+                    "iso-ir-226",
+                    "ISO_8859-16:2001",
+                    "ISO_8859-16",
+                    "latin10",
+                    "l10",
+                    "csISO885916"
+                   });
 
         aliasCheck("JIS_X0212-1990",
                 new String[] {
--- a/test/sun/nio/cs/TestCharsetMapping.java	Sun Sep 03 19:31:11 2017 +0530
+++ b/test/sun/nio/cs/TestCharsetMapping.java	Tue Sep 05 10:09:44 2017 -0700
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 8186801
+ * @bug 8186801 8186751
  * @summary Test the charset mappings
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/pkcs11/Config/ReadConfInUTF16Env.java	Tue Sep 05 10:09:44 2017 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.security.Provider;
+import java.security.Security;
+
+public class ReadConfInUTF16Env {
+    public static void main(String argv[]) {
+        Provider p = Security.getProvider("SunPKCS11");
+        if (p == null) {
+            p = Security.getProvider("SunPKCS11-Solaris");
+            if (p == null) {
+                System.out.println("Skipping test - no PKCS11 provider available");
+                return;
+            }
+        }
+
+        System.out.println(p.getName());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/pkcs11/Config/ReadConfInUTF16Env.sh	Tue Sep 05 10:09:44 2017 -0700
@@ -0,0 +1,38 @@
+#
+# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# @test
+# @bug 8187023
+# @summary Pkcs11 config file should be assumed in ISO-8859-1
+# @build ReadConfInUTF16Env
+# @run shell ReadConfInUTF16Env.sh
+
+# jtreg does not like -Dfile.encoding=UTF-16 inside a @run main line,
+# testlibrary.ProcessTools.createJavaProcessBuilder() also had troubles
+# executing a subprocess with -Dfile.encoding=UTF-16 option added,
+# therefore a shell test is written.
+
+$TESTJAVA/bin/java $TESTVMOPTS -cp $TESTCLASSES \
+  -Dfile.encoding=UTF-16 \
+  ReadConfInUTF16Env
+