changeset 14137:a73004866eec

8245470: Fix JDK8 compatibility issues Reviewed-by: mbalao
author abakhtin
date Tue, 25 Aug 2020 08:39:43 +0300
parents 646e29e5330b
children 90d302484147
files src/share/classes/java/security/MessageDigest.java src/share/classes/sun/security/pkcs11/P11Digest.java src/share/classes/sun/security/ssl/BaseSSLSocketImpl.java src/share/classes/sun/security/ssl/CertSignAlgsExtension.java src/share/classes/sun/security/ssl/CertStatusExtension.java src/share/classes/sun/security/ssl/CertificateVerify.java src/share/classes/sun/security/ssl/CookieExtension.java src/share/classes/sun/security/ssl/DHClientKeyExchange.java src/share/classes/sun/security/ssl/DHServerKeyExchange.java src/share/classes/sun/security/ssl/ECDHClientKeyExchange.java src/share/classes/sun/security/ssl/ECDHServerKeyExchange.java src/share/classes/sun/security/ssl/Finished.java src/share/classes/sun/security/ssl/HandshakeContext.java src/share/classes/sun/security/ssl/KeyShareExtension.java src/share/classes/sun/security/ssl/PredefinedDHParameterSpecs.java src/share/classes/sun/security/ssl/RSAClientKeyExchange.java src/share/classes/sun/security/ssl/RSAServerKeyExchange.java src/share/classes/sun/security/ssl/RandomCookie.java src/share/classes/sun/security/ssl/RenegoInfoExtension.java src/share/classes/sun/security/ssl/SSLCipher.java src/share/classes/sun/security/ssl/SSLEngineInputRecord.java src/share/classes/sun/security/ssl/SSLExtension.java src/share/classes/sun/security/ssl/SSLExtensions.java src/share/classes/sun/security/ssl/SSLLogger.java src/share/classes/sun/security/ssl/SSLSessionContextImpl.java src/share/classes/sun/security/ssl/SSLSocketImpl.java src/share/classes/sun/security/ssl/SSLSocketInputRecord.java src/share/classes/sun/security/ssl/SignatureAlgorithmsExtension.java src/share/classes/sun/security/ssl/SunJSSE.java src/share/classes/sun/security/ssl/TransportContext.java src/share/classes/sun/security/ssl/Utilities.java src/share/classes/sun/security/util/MessageDigestSpi2.java src/share/classes/sun/security/util/SecurityConstants.java
diffstat 33 files changed, 184 insertions(+), 111 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/security/MessageDigest.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/java/security/MessageDigest.java	Tue Aug 25 08:39:43 2020 +0300
@@ -32,10 +32,13 @@
 import java.io.PrintStream;
 import java.io.InputStream;
 import java.io.ByteArrayInputStream;
-
+import java.security.InvalidKeyException;
 import java.nio.ByteBuffer;
 
 import sun.security.util.Debug;
+import sun.security.util.MessageDigestSpi2;
+
+import javax.crypto.SecretKey;
 
 /**
  * This MessageDigest class provides applications the functionality of a
@@ -549,7 +552,7 @@
      * and its original parent (Object).
      */
 
-    static class Delegate extends MessageDigest {
+    static class Delegate extends MessageDigest implements MessageDigestSpi2 {
 
         // The provider implementation (delegate)
         private MessageDigestSpi digestSpi;
@@ -602,6 +605,14 @@
             digestSpi.engineUpdate(input);
         }
 
+        public void engineUpdate(SecretKey key) throws InvalidKeyException {
+            if (digestSpi instanceof MessageDigestSpi2) {
+                ((MessageDigestSpi2)digestSpi).engineUpdate(key);
+            } else {
+                throw new UnsupportedOperationException
+                ("Digest does not support update of SecretKey object");
+            }
+        }
         protected byte[] engineDigest() {
             return digestSpi.engineDigest();
         }
--- a/src/share/classes/sun/security/pkcs11/P11Digest.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/pkcs11/P11Digest.java	Tue Aug 25 08:39:43 2020 +0300
@@ -34,6 +34,8 @@
 
 import sun.nio.ch.DirectBuffer;
 
+import sun.security.util.MessageDigestSpi2;
+
 import sun.security.pkcs11.wrapper.*;
 import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
 
@@ -49,7 +51,8 @@
  * @author  Andreas Sterbenz
  * @since   1.5
  */
-final class P11Digest extends MessageDigestSpi implements Cloneable {
+final class P11Digest extends MessageDigestSpi implements Cloneable,
+    MessageDigestSpi2 {
 
     /* fields initialized, no session acquired */
     private final static int S_BLANK    = 1;
@@ -234,10 +237,11 @@
     }
 
     // Called by SunJSSE via reflection during the SSL 3.0 handshake if
-    // the master secret is sensitive. We may want to consider making this
-    // method public in a future release.
-    protected void implUpdate(SecretKey key) throws InvalidKeyException {
-
+    // the master secret is sensitive.
+    // Note: Change to protected after this method is moved from
+    // sun.security.util.MessageSpi2 interface to
+    // java.security.MessageDigestSpi class
+    public void engineUpdate(SecretKey key) throws InvalidKeyException {
         // SunJSSE calls this method only if the key does not have a RAW
         // encoding, i.e. if it is sensitive. Therefore, no point in calling
         // SecretKeyFactory to try to convert it. Just verify it ourselves.
--- a/src/share/classes/sun/security/ssl/BaseSSLSocketImpl.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/BaseSSLSocketImpl.java	Tue Aug 25 08:39:43 2020 +0300
@@ -640,34 +640,6 @@
         }
     }
 
-    @Override
-    public <T> Socket setOption(SocketOption<T> name,
-            T value) throws IOException {
-        if (self == this) {
-            return super.setOption(name, value);
-        } else {
-            return self.setOption(name, value);
-        }
-    }
-
-    @Override
-    public <T> T getOption(SocketOption<T> name) throws IOException {
-        if (self == this) {
-            return super.getOption(name);
-        } else {
-            return self.getOption(name);
-        }
-    }
-
-    @Override
-    public Set<SocketOption<?>> supportedOptions() {
-        if (self == this) {
-            return super.supportedOptions();
-        } else {
-            return self.supportedOptions();
-        }
-    }
-
     boolean isLayered() {
         return (self != this);
     }
--- a/src/share/classes/sun/security/ssl/CertSignAlgsExtension.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/CertSignAlgsExtension.java	Tue Aug 25 08:39:43 2020 +0300
@@ -27,6 +27,8 @@
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import sun.security.ssl.SSLExtension.ExtensionConsumer;
 import sun.security.ssl.SSLHandshake.HandshakeMessage;
@@ -242,10 +244,11 @@
             }
 
             // Produce the extension.
+            List<ProtocolVersion> protocols = Arrays.asList(shc.negotiatedProtocol);
+            protocols = Collections.unmodifiableList(protocols);
             List<SignatureScheme> sigAlgs =
                     SignatureScheme.getSupportedAlgorithms(
-                            shc.algorithmConstraints,
-                            List.of(shc.negotiatedProtocol));
+                            shc.algorithmConstraints, protocols);
 
             int vectorLen = SignatureScheme.sizeInRecord() * sigAlgs.size();
             byte[] extData = new byte[vectorLen + 2];
--- a/src/share/classes/sun/security/ssl/CertStatusExtension.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/CertStatusExtension.java	Tue Aug 25 08:39:43 2020 +0300
@@ -44,7 +44,7 @@
 import sun.security.ssl.SSLHandshake.HandshakeMessage;
 import sun.security.util.DerInputStream;
 import sun.security.util.DerValue;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 
 /**
  * Pack of "status_request" and "status_request_v2" extensions.
--- a/src/share/classes/sun/security/ssl/CertificateVerify.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/CertificateVerify.java	Tue Aug 25 08:39:43 2020 +0300
@@ -34,7 +34,7 @@
 import sun.security.ssl.SSLHandshake.HandshakeMessage;
 import sun.security.ssl.X509Authentication.X509Credentials;
 import sun.security.ssl.X509Authentication.X509Possession;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 
 /**
  * Pack of the CertificateVerify handshake message.
--- a/src/share/classes/sun/security/ssl/CookieExtension.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/CookieExtension.java	Tue Aug 25 08:39:43 2020 +0300
@@ -36,7 +36,7 @@
 import sun.security.ssl.SSLHandshake.HandshakeMessage;
 import sun.security.ssl.SSLExtension.SSLExtensionSpec;
 import sun.security.ssl.ServerHello.ServerHelloMessage;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 
 public class CookieExtension {
     static final HandshakeProducer chNetworkProducer =
--- a/src/share/classes/sun/security/ssl/DHClientKeyExchange.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/DHClientKeyExchange.java	Tue Aug 25 08:39:43 2020 +0300
@@ -43,7 +43,7 @@
 import sun.security.ssl.DHKeyExchange.DHEPossession;
 import sun.security.ssl.SSLHandshake.HandshakeMessage;
 import sun.security.ssl.SupportedGroupsExtension.NamedGroup;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 
 /**
  * Pack of the "ClientKeyExchange" handshake message.
--- a/src/share/classes/sun/security/ssl/DHServerKeyExchange.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/DHServerKeyExchange.java	Tue Aug 25 08:39:43 2020 +0300
@@ -51,7 +51,7 @@
 import sun.security.ssl.SupportedGroupsExtension.NamedGroup;
 import sun.security.ssl.X509Authentication.X509Credentials;
 import sun.security.ssl.X509Authentication.X509Possession;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 import sun.security.util.KeyUtil;
 
 /**
--- a/src/share/classes/sun/security/ssl/ECDHClientKeyExchange.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/ECDHClientKeyExchange.java	Tue Aug 25 08:39:43 2020 +0300
@@ -47,7 +47,7 @@
 import sun.security.ssl.SupportedGroupsExtension.NamedGroup;
 import sun.security.ssl.X509Authentication.X509Credentials;
 import sun.security.ssl.X509Authentication.X509Possession;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 
 /**
  * Pack of the "ClientKeyExchange" handshake message.
--- a/src/share/classes/sun/security/ssl/ECDHServerKeyExchange.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/ECDHServerKeyExchange.java	Tue Aug 25 08:39:43 2020 +0300
@@ -52,7 +52,7 @@
 import sun.security.ssl.SupportedGroupsExtension.SupportedGroups;
 import sun.security.ssl.X509Authentication.X509Credentials;
 import sun.security.ssl.X509Authentication.X509Possession;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 
 /**
  * Pack of the ServerKeyExchange handshake message.
--- a/src/share/classes/sun/security/ssl/Finished.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/Finished.java	Tue Aug 25 08:39:43 2020 +0300
@@ -51,7 +51,7 @@
 import sun.security.ssl.SSLCipher.SSLReadCipher;
 import sun.security.ssl.SSLCipher.SSLWriteCipher;
 import sun.security.ssl.SSLHandshake.HandshakeMessage;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 
 /**
  * Pack of the Finished handshake message.
--- a/src/share/classes/sun/security/ssl/HandshakeContext.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/HandshakeContext.java	Tue Aug 25 08:39:43 2020 +0300
@@ -409,7 +409,7 @@
                 ByteBuffer fragment = ByteBuffer.wrap(
                         new byte[plaintext.fragment.remaining()]);
                 fragment.put(plaintext.fragment);
-                fragment = fragment.rewind();
+                fragment = (ByteBuffer)fragment.rewind();
 
                 delegatedActions.add(new SimpleImmutableEntry<>(
                         handshakeType,
--- a/src/share/classes/sun/security/ssl/KeyShareExtension.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/KeyShareExtension.java	Tue Aug 25 08:39:43 2020 +0300
@@ -49,7 +49,7 @@
 import sun.security.ssl.SupportedGroupsExtension.NamedGroup;
 import sun.security.ssl.SupportedGroupsExtension.NamedGroupType;
 import sun.security.ssl.SupportedGroupsExtension.SupportedGroups;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 
 /**
  * Pack of the "key_share" extensions.
--- a/src/share/classes/sun/security/ssl/PredefinedDHParameterSpecs.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/PredefinedDHParameterSpecs.java	Tue Aug 25 08:39:43 2020 +0300
@@ -288,11 +288,12 @@
                         PROPERTY_NAME + ", definition");
             }
         }
+        BigInteger TWO = BigInteger.valueOf(2);
 
         Map<Integer,DHParameterSpec> tempFFDHEs = new HashMap<>();
         for (BigInteger p : ffdhePrimes) {
             int primeLen = p.bitLength();
-            DHParameterSpec dhps = new DHParameterSpec(p, BigInteger.TWO);
+            DHParameterSpec dhps = new DHParameterSpec(p, TWO);
             tempFFDHEs.put(primeLen, dhps);
             defaultParams.putIfAbsent(primeLen, dhps);
         }
@@ -301,7 +302,7 @@
             int primeLen = p.bitLength();
             if (defaultParams.get(primeLen) == null) {
                 defaultParams.put(primeLen,
-                    new DHParameterSpec(p, BigInteger.TWO));
+                    new DHParameterSpec(p, TWO));
             }
         }
 
--- a/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java	Tue Aug 25 08:39:43 2020 +0300
@@ -39,7 +39,7 @@
 import sun.security.ssl.SSLHandshake.HandshakeMessage;
 import sun.security.ssl.X509Authentication.X509Credentials;
 import sun.security.ssl.X509Authentication.X509Possession;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 
 /**
  * Pack of the "ClientKeyExchange" handshake message.
--- a/src/share/classes/sun/security/ssl/RSAServerKeyExchange.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/RSAServerKeyExchange.java	Tue Aug 25 08:39:43 2020 +0300
@@ -45,7 +45,7 @@
 import sun.security.ssl.SSLHandshake.HandshakeMessage;
 import sun.security.ssl.X509Authentication.X509Credentials;
 import sun.security.ssl.X509Authentication.X509Possession;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 
 /**
  * Pack of the ServerKeyExchange handshake message.
--- a/src/share/classes/sun/security/ssl/RandomCookie.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/RandomCookie.java	Tue Aug 25 08:39:43 2020 +0300
@@ -130,10 +130,10 @@
     }
 
     private boolean isT12Downgrade() {
-        return Arrays.equals(randomBytes, 24, 32, t12Protection, 0, 8);
+        return Utilities.equals(randomBytes, 24, 32, t12Protection, 0, 8);
     }
 
     private boolean isT11Downgrade() {
-        return Arrays.equals(randomBytes, 24, 32, t11Protection, 0, 8);
+        return Utilities.equals(randomBytes, 24, 32, t11Protection, 0, 8);
     }
 }
--- a/src/share/classes/sun/security/ssl/RenegoInfoExtension.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/RenegoInfoExtension.java	Tue Aug 25 08:39:43 2020 +0300
@@ -470,14 +470,14 @@
                 }
 
                 byte[] cvd = chc.conContext.clientVerifyData;
-                if (!Arrays.equals(spec.renegotiatedConnection,
+                if (!Utilities.equals(spec.renegotiatedConnection,
                         0, cvd.length, cvd, 0, cvd.length)) {
                     throw chc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
                         "Invalid renegotiation_info in ServerHello: " +
                         "unmatched client_verify_data value");
                 }
                 byte[] svd = chc.conContext.serverVerifyData;
-                if (!Arrays.equals(spec.renegotiatedConnection,
+                if (!Utilities.equals(spec.renegotiatedConnection,
                         cvd.length, infoLen, svd, 0, svd.length)) {
                     throw chc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
                         "Invalid renegotiation_info in ServerHello: " +
--- a/src/share/classes/sun/security/ssl/SSLCipher.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/SSLCipher.java	Tue Aug 25 08:39:43 2020 +0300
@@ -2307,7 +2307,7 @@
 
         // The padding data should be filled with the padding length value.
         int[] results = checkPadding(
-                bb.duplicate().position(offset + newLen),
+                (ByteBuffer)(bb.duplicate()).position(offset + newLen),
                 (byte)(padLen & 0xFF));
         if (protocolVersion.useTLS10PlusSpec()) {
             if (results[0] != 0) {          // padding data has invalid bytes
--- a/src/share/classes/sun/security/ssl/SSLEngineInputRecord.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/SSLEngineInputRecord.java	Tue Aug 25 08:39:43 2020 +0300
@@ -272,7 +272,7 @@
                         handshakeBuffer.remaining() + fragment.remaining()]);
                 bb.put(handshakeBuffer);
                 bb.put(fragment);
-                handshakeFrag = bb.rewind();
+                handshakeFrag = (ByteBuffer)bb.rewind();
                 handshakeBuffer = null;
             }
 
--- a/src/share/classes/sun/security/ssl/SSLExtension.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/SSLExtension.java	Tue Aug 25 08:39:43 2020 +0300
@@ -33,7 +33,7 @@
 import java.util.LinkedList;
 import java.util.Locale;
 import sun.security.ssl.SSLHandshake.HandshakeMessage;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 
 enum SSLExtension implements SSLStringizer {
     // Extensions defined in RFC 6066
--- a/src/share/classes/sun/security/ssl/SSLExtensions.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/SSLExtensions.java	Tue Aug 25 08:39:43 2020 +0300
@@ -31,7 +31,7 @@
 import java.util.*;
 
 import sun.security.ssl.SSLHandshake.HandshakeMessage;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 
 /**
  * SSL/TLS extensions in a handshake message.
--- a/src/share/classes/sun/security/ssl/SSLLogger.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/SSLLogger.java	Tue Aug 25 08:39:43 2020 +0300
@@ -29,8 +29,6 @@
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
-import java.lang.System.Logger;
-import java.lang.System.Logger.Level;
 import java.nio.ByteBuffer;
 import java.security.cert.Certificate;
 import java.security.cert.Extension;
@@ -39,10 +37,13 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Locale;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+import java.util.logging.Level;
 import java.util.Map;
 import java.util.ResourceBundle;
 import sun.security.action.GetPropertyAction;
-import sun.security.util.HexDumpEncoder;
+import sun.misc.HexDumpEncoder;
 import sun.security.x509.*;
 
 /**
@@ -56,7 +57,7 @@
  * and non-empty, a private debug logger implemented in this class is used.
  */
 public final class SSLLogger {
-    private static final System.Logger logger;
+    private static final Logger logger;
     private static final String property;
     public static final boolean isOn;
 
@@ -65,7 +66,7 @@
         if (p != null) {
             if (p.isEmpty()) {
                 property = "";
-                logger = System.getLogger("javax.net.ssl");
+                logger = Logger.getLogger("javax.net.ssl");
             } else {
                 property = p.toLowerCase(Locale.ENGLISH);
                 if (property.equals("help")) {
@@ -155,7 +156,7 @@
     }
 
     public static void severe(String msg, Object... params) {
-        SSLLogger.log(Level.ERROR, msg, params);
+        SSLLogger.log(Level.SEVERE, msg, params);
     }
 
     public static void warning(String msg, Object... params) {
@@ -167,11 +168,11 @@
     }
 
     public static void fine(String msg, Object... params) {
-        SSLLogger.log(Level.DEBUG, msg, params);
+        SSLLogger.log(Level.FINE, msg, params);
     }
 
     public static void finer(String msg, Object... params) {
-        SSLLogger.log(Level.TRACE, msg, params);
+        SSLLogger.log(Level.FINER, msg, params);
     }
 
     public static void finest(String msg, Object... params) {
@@ -202,53 +203,47 @@
         }
     }
 
-    private static class SSLConsoleLogger implements Logger {
+    private static class SSLConsoleLogger extends Logger {
         private final String loggerName;
         private final boolean useCompactFormat;
 
         SSLConsoleLogger(String loggerName, String options) {
+            super(loggerName, null);
             this.loggerName = loggerName;
             options = options.toLowerCase(Locale.ENGLISH);
             this.useCompactFormat = !options.contains("expand");
         }
 
-        @Override
         public String getName() {
             return loggerName;
         }
 
-        @Override
         public boolean isLoggable(Level level) {
             return (level != Level.OFF);
         }
 
         @Override
-        public void log(Level level,
-                ResourceBundle rb, String message, Throwable thrwbl) {
-            if (isLoggable(level)) {
+        public void log(LogRecord record) {
+            if (isLoggable(record.getLevel())) {
                 try {
-                    String formatted =
-                        SSLSimpleFormatter.format(this, level, message, thrwbl);
+                    String formatted = null;
+                    if (record.getThrown() != null) {
+                        formatted =
+                                SSLSimpleFormatter.format(this, record.getLevel(),
+                                        record.getMessage(),
+                                        record.getThrown());
+                    } else {
+                        formatted =
+                                SSLSimpleFormatter.format(this, record.getLevel(),
+                                        record.getMessage(),
+                                        record.getParameters());
+                    }
                     System.err.write(formatted.getBytes("UTF-8"));
                 } catch (Exception exp) {
                     // ignore it, just for debugging.
                 }
             }
-        }
-
-        @Override
-        public void log(Level level,
-                ResourceBundle rb, String message, Object... params) {
-            if (isLoggable(level)) {
-                try {
-                    String formatted =
-                        SSLSimpleFormatter.format(this, level, message, params);
-                    System.err.write(formatted.getBytes("UTF-8"));
-                } catch (Exception exp) {
-                    // ignore it, just for debugging.
-                }
-            }
-        }
+        };
     }
 
     private static class SSLSimpleFormatter {
@@ -388,12 +383,15 @@
         }
 
         private static String formatCaller() {
-            return StackWalker.getInstance().walk(s ->
-                s.dropWhile(f ->
-                    f.getClassName().startsWith("sun.security.ssl.SSLLogger") ||
-                    f.getClassName().startsWith("java.lang.System"))
-                .map(f -> f.getFileName() + ":" + f.getLineNumber())
-                .findFirst().orElse("unknown caller"));
+            StackTraceElement[] stElements = Thread.currentThread().getStackTrace();
+            for (int i=1; i<stElements.length; i++) {
+                StackTraceElement ste = stElements[i];
+                if (!ste.getClassName().startsWith(SSLLogger.class.getName()) &&
+                    !ste.getClassName().startsWith("java.lang.System")) {
+                   return ste.getFileName() + ":" + ste.getLineNumber();
+                }
+            }
+            return "unknown caller";
         }
 
         private static String formatParameters(Object ... parameters) {
--- a/src/share/classes/sun/security/ssl/SSLSessionContextImpl.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/SSLSessionContextImpl.java	Tue Aug 25 08:39:43 2020 +0300
@@ -25,6 +25,7 @@
 
 package sun.security.ssl;
 
+import java.security.AccessController;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -199,9 +200,9 @@
 
     private static int getDefaultCacheLimit() {
         try {
-            int defaultCacheLimit = GetIntegerAction.privilegedGetProperty(
-                    "javax.net.ssl.sessionCacheSize", DEFAULT_MAX_CACHE_SIZE);
-
+            int defaultCacheLimit = AccessController.doPrivileged(
+                    new GetIntegerAction("javax.net.ssl.sessionCacheSize",
+                            DEFAULT_MAX_CACHE_SIZE));
             if (defaultCacheLimit >= 0) {
                 return defaultCacheLimit;
             } else if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
--- a/src/share/classes/sun/security/ssl/SSLSocketImpl.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/SSLSocketImpl.java	Tue Aug 25 08:39:43 2020 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2020, 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
@@ -47,8 +47,7 @@
 import javax.net.ssl.SSLServerSocket;
 import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLSocket;
-import jdk.internal.misc.JavaNetInetAddressAccess;
-import jdk.internal.misc.SharedSecrets;
+import sun.misc.SharedSecrets;
 
 /**
  * Implementation of an SSL socket.
@@ -1228,9 +1227,7 @@
             return;
         }
 
-        JavaNetInetAddressAccess jna =
-                SharedSecrets.getJavaNetInetAddressAccess();
-        String originalHostname = jna.getOriginalHostName(inetAddress);
+        String originalHostname = SharedSecrets.getJavaNetAccess().getOriginalHostName(inetAddress);
         if (originalHostname != null && !originalHostname.isEmpty()) {
 
             this.peerHost = originalHostname;
--- a/src/share/classes/sun/security/ssl/SSLSocketInputRecord.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/SSLSocketInputRecord.java	Tue Aug 25 08:39:43 2020 +0300
@@ -287,7 +287,7 @@
                         handshakeBuffer.remaining() + fragment.remaining()]);
                 bb.put(handshakeBuffer);
                 bb.put(fragment);
-                handshakeFrag = bb.rewind();
+                handshakeFrag = (ByteBuffer)bb.rewind();
                 handshakeBuffer = null;
             }
 
--- a/src/share/classes/sun/security/ssl/SignatureAlgorithmsExtension.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/SignatureAlgorithmsExtension.java	Tue Aug 25 08:39:43 2020 +0300
@@ -29,6 +29,7 @@
 import java.nio.ByteBuffer;
 import java.text.MessageFormat;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
@@ -408,10 +409,11 @@
             }
 
             // Produce the extension.
+            List<ProtocolVersion> protocols = Arrays.asList(shc.negotiatedProtocol);
+            protocols = Collections.unmodifiableList(protocols);
             List<SignatureScheme> sigAlgs =
                     SignatureScheme.getSupportedAlgorithms(
-                            shc.algorithmConstraints,
-                            List.of(shc.negotiatedProtocol));
+                            shc.algorithmConstraints, protocols);
 
             int vectorLen = SignatureScheme.sizeInRecord() * sigAlgs.size();
             byte[] extData = new byte[vectorLen + 2];
--- a/src/share/classes/sun/security/ssl/SunJSSE.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/SunJSSE.java	Tue Aug 25 08:39:43 2020 +0300
@@ -26,6 +26,8 @@
 
 package sun.security.ssl;
 
+import static sun.security.util.SecurityConstants.PROVIDER_VER;
+
 import java.security.*;
 
 /**
@@ -132,7 +134,7 @@
 
     private SunJSSE(java.security.Provider cryptoProvider,
             String providerName) {
-        super("SunJSSE", 1.8d, fipsInfo + providerName + ")");
+        super("SunJSSE", PROVIDER_VER, fipsInfo + providerName + ")");
         subclassCheck();
         if (cryptoProvider == null) {
             // Calling Security.getProvider() will cause other providers to be
--- a/src/share/classes/sun/security/ssl/TransportContext.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/TransportContext.java	Tue Aug 25 08:39:43 2020 +0300
@@ -613,8 +613,7 @@
                 null,
                 new NotifyHandshake(sslConfig.handshakeListeners, hce),
                 "HandshakeCompletedNotify-Thread",
-                0,
-                false);
+                0);
             thread.start();
         }
 
--- a/src/share/classes/sun/security/ssl/Utilities.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/ssl/Utilities.java	Tue Aug 25 08:39:43 2020 +0300
@@ -232,4 +232,41 @@
         }
         return b;
     }
+
+    /**
+     * Checks that {@code fromIndex} and {@code toIndex} are in
+     * the range and throws an exception if they aren't.
+     */
+    private static void rangeCheck(int arrayLength, int fromIndex, int toIndex) {
+        if (fromIndex > toIndex) {
+            throw new IllegalArgumentException(
+                    "fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")");
+        }
+        if (fromIndex < 0) {
+            throw new ArrayIndexOutOfBoundsException(fromIndex);
+        }
+        if (toIndex > arrayLength) {
+            throw new ArrayIndexOutOfBoundsException(toIndex);
+        }
+    }
+
+    /**
+     * Returns true if the two specified arrays of bytes, over the specified
+     * ranges, are <i>equal</i> to one another.
+     */
+    static boolean equals(byte[] arr1, int st1, int end1, byte[] arr2, int st2, int end2) {
+        rangeCheck(arr1.length, st1, end1);
+        rangeCheck(arr2.length, st2, end2);
+
+        int aLength = end1 - st1;
+        int bLength = end2 - st2;
+        if (aLength != bLength)
+            return false;
+
+        for(int i=0; i<aLength; i++)
+            if(arr1[i + st1] != arr2[i + st2])
+                return false;
+        return true;
+    }
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/security/util/MessageDigestSpi2.java	Tue Aug 25 08:39:43 2020 +0300
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.util;
+
+import java.security.InvalidKeyException;
+import javax.crypto.SecretKey;
+
+/**
+ * Special interface for additional MessageDigestSpi method(s).
+ */
+public interface MessageDigestSpi2 {
+
+    /**
+     * Updates the digest using the specified key.
+     * This is used for SSL 3.0 only, we may deprecate and remove the support
+     * of this in the future
+     *
+     * @param key  the key whose value is to be digested.
+     */
+    void engineUpdate(SecretKey key) throws InvalidKeyException;
+}
--- a/src/share/classes/sun/security/util/SecurityConstants.java	Tue Aug 25 08:35:10 2020 +0300
+++ b/src/share/classes/sun/security/util/SecurityConstants.java	Tue Aug 25 08:39:43 2020 +0300
@@ -227,4 +227,6 @@
     // java.lang.SecurityManager
     public static final SocketPermission LOCAL_LISTEN_PERMISSION =
         new SocketPermission("localhost:0", SOCKET_LISTEN_ACTION);
+
+    public static final Double PROVIDER_VER = 1.8d;
 }