changeset 14454:ba0e36b4275f

Merge
author andrew
date Wed, 19 May 2021 16:12:33 +0100
parents 9cd22f676a66 (current diff) 79198fff6d1d (diff)
children 821ac4be0e8f
files
diffstat 13 files changed, 121 insertions(+), 126 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/security/jca/Providers.java	Mon May 17 05:47:13 2021 +0100
+++ b/src/share/classes/sun/security/jca/Providers.java	Wed May 19 16:12:33 2021 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -86,6 +86,7 @@
         // Note: SunEC *is* in a signed JAR file, but it's not signed
         // by EC itself. So it's still safe to be listed here.
         "sun.security.ec.SunEC",
+        "com.sun.crypto.provider.SunJCE",
         BACKUP_PROVIDER_CLASSNAME,
     };
 
--- a/src/share/classes/sun/security/ssl/SSLEngineInputRecord.java	Mon May 17 05:47:13 2021 +0100
+++ b/src/share/classes/sun/security/ssl/SSLEngineInputRecord.java	Wed May 19 16:12:33 2021 +0100
@@ -287,8 +287,15 @@
                 }
 
                 handshakeFrag.mark();
-                // skip the first byte: handshake type
+
+                // Fail fast for unknown handshake message.
                 byte handshakeType = handshakeFrag.get();
+                if (!SSLHandshake.isKnown(handshakeType)) {
+                    throw new SSLProtocolException(
+                        "Unknown handshake type size, Handshake.msg_type = " +
+                        (handshakeType & 0xFF));
+                }
+
                 int handshakeBodyLen = Record.getInt24(handshakeFrag);
                 if (handshakeBodyLen > SSLConfiguration.maxHandshakeMessageSize) {
                     throw new SSLProtocolException(
--- a/src/share/classes/sun/security/ssl/SSLHandshake.java	Mon May 17 05:47:13 2021 +0100
+++ b/src/share/classes/sun/security/ssl/SSLHandshake.java	Wed May 19 16:12:33 2021 +0100
@@ -478,6 +478,16 @@
         return "UNKNOWN-HANDSHAKE-MESSAGE(" + id + ")";
     }
 
+    static boolean isKnown(byte id) {
+        for (SSLHandshake hs : SSLHandshake.values()) {
+            if (hs.id == id && id != NOT_APPLICABLE.id) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     static final void kickstart(HandshakeContext context) throws IOException {
         if (context instanceof ClientHandshakeContext) {
             // For initial handshaking, including session resumption,
--- a/src/share/classes/sun/security/ssl/SSLSocketInputRecord.java	Mon May 17 05:47:13 2021 +0100
+++ b/src/share/classes/sun/security/ssl/SSLSocketInputRecord.java	Wed May 19 16:12:33 2021 +0100
@@ -302,8 +302,15 @@
                 }
 
                 handshakeFrag.mark();
-                // skip the first byte: handshake type
+
+                // Fail fast for unknown handshake message.
                 byte handshakeType = handshakeFrag.get();
+                if (!SSLHandshake.isKnown(handshakeType)) {
+                    throw new SSLProtocolException(
+                        "Unknown handshake type size, Handshake.msg_type = " +
+                        (handshakeType & 0xFF));
+                }
+
                 int handshakeBodyLen = Record.getInt24(handshakeFrag);
                 if (handshakeBodyLen > SSLConfiguration.maxHandshakeMessageSize) {
                     throw new SSLProtocolException(
--- a/src/share/classes/sun/security/tools/KeyStoreUtil.java	Mon May 17 05:47:13 2021 +0100
+++ b/src/share/classes/sun/security/tools/KeyStoreUtil.java	Wed May 19 16:12:33 2021 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@
 import java.text.Collator;
 
 import java.util.Locale;
+import java.util.ResourceBundle;
 
 /**
  * <p> This class provides several utilities to <code>KeyStore</code>.
@@ -53,12 +54,6 @@
 
     private static final String JKS = "jks";
 
-    private static final Collator collator = Collator.getInstance();
-    static {
-        // this is for case insensitive string comparisons
-        collator.setStrength(Collator.PRIMARY);
-    };
-
     /**
      * Returns true if the certificate is self-signed, false otherwise.
      */
@@ -123,7 +118,8 @@
     }
 
     public static char[] getPassWithModifier(String modifier, String arg,
-                                             java.util.ResourceBundle rb) {
+                                             ResourceBundle rb,
+                                             Collator collator) {
         if (modifier == null) {
             return arg.toCharArray();
         } else if (collator.compare(modifier, "env") == 0) {
--- a/src/share/classes/sun/security/tools/jarsigner/Main.java	Mon May 17 05:47:13 2021 +0100
+++ b/src/share/classes/sun/security/tools/jarsigner/Main.java	Wed May 19 16:12:33 2021 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -521,7 +521,8 @@
     }
 
     static char[] getPass(String modifier, String arg) {
-        char[] output = KeyStoreUtil.getPassWithModifier(modifier, arg, rb);
+        char[] output =
+            KeyStoreUtil.getPassWithModifier(modifier, arg, rb, collator);
         if (output != null) return output;
         usage();
         return null;    // Useless, usage() already exit
--- a/src/share/classes/sun/security/tools/keytool/Main.java	Mon May 17 05:47:13 2021 +0100
+++ b/src/share/classes/sun/security/tools/keytool/Main.java	Wed May 19 16:12:33 2021 +0100
@@ -4526,7 +4526,8 @@
     }
 
     private char[] getPass(String modifier, String arg) {
-        char[] output = KeyStoreUtil.getPassWithModifier(modifier, arg, rb);
+        char[] output =
+            KeyStoreUtil.getPassWithModifier(modifier, arg, rb, collator);
         if (output != null) return output;
         tinyHelp();
         return null;    // Useless, tinyHelp() already exits.
--- a/src/windows/native/sun/windows/awt_DnDDT.cpp	Mon May 17 05:47:13 2021 +0100
+++ b/src/windows/native/sun/windows/awt_DnDDT.cpp	Wed May 19 16:12:33 2021 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2021, 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
@@ -133,6 +133,7 @@
 
 HRESULT __stdcall AwtDropTarget::DragEnter(IDataObject __RPC_FAR *pDataObj, DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect) {
     TRY;
+    AwtToolkit::GetInstance().isInDoDragDropLoop = TRUE;
     if (NULL != m_pIDropTargetHelper) {
         m_pIDropTargetHelper->DragEnter(
             m_window,
@@ -152,6 +153,7 @@
         (IsLocalDnD()  && !IsLocalDataObject(pDataObj)))
     {
         *pdwEffect = retEffect;
+        AwtToolkit::GetInstance().isInDoDragDropLoop = FALSE;
         return ret;
     }
 
@@ -163,6 +165,7 @@
     }
 
     if (JNU_IsNull(env, m_dtcp) || !JNU_IsNull(env, safe_ExceptionOccurred(env))) {
+        AwtToolkit::GetInstance().isInDoDragDropLoop = FALSE;
         return ret;
     }
 
@@ -188,10 +191,12 @@
                 env->ExceptionDescribe();
                 env->ExceptionClear();
                 actions = java_awt_dnd_DnDConstants_ACTION_NONE;
+                AwtToolkit::GetInstance().isInDoDragDropLoop = FALSE;
             }
         } catch (std::bad_alloc&) {
             retEffect = ::convertActionsToDROPEFFECT(actions);
             *pdwEffect = retEffect;
+            AwtToolkit::GetInstance().isInDoDragDropLoop = FALSE;
             throw;
         }
 
@@ -405,6 +410,7 @@
     m_dropSuccess = success;
     m_dropActions = action;
     AwtToolkit::GetInstance().QuitMessageLoop(AwtToolkit::EXIT_ENCLOSING_LOOP);
+    AwtToolkit::GetInstance().isInDoDragDropLoop = FALSE;
 }
 
 /**
@@ -1119,6 +1125,7 @@
 
 void AwtDropTarget::DragCleanup(void) {
     UnloadCache();
+    AwtToolkit::GetInstance().isInDoDragDropLoop = FALSE;
 }
 
 BOOL AwtDropTarget::IsLocalDataObject(IDataObject __RPC_FAR *pDataObject) {
--- a/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java	Mon May 17 05:47:13 2021 +0100
+++ b/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java	Wed May 19 16:12:33 2021 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4183169
+ * @bug 4183169 8032050
  * @summary Minor problem with the way ReliableLog handles IOExceptions.
  *
  * @author Laird Dornin; code borrowed from Ann Wollrath
@@ -36,6 +36,7 @@
 import java.rmi.activation.*;
 import java.rmi.*;
 import java.util.Properties;
+import java.util.concurrent.TimeoutException;
 
 /**
  * The test creates an rmid with a special security manager.  After
@@ -51,7 +52,7 @@
  * (after that time, the test will fail).
  */
 public class ShutdownGracefully
-    extends Activatable implements Runnable, RegisteringActivatable
+    extends Activatable implements RegisteringActivatable
 {
     private static RegisteringActivatable registering = null;
 
@@ -61,6 +62,8 @@
 
         RMID rmid = null;
 
+        // Save exception if there is a exception or expected behavior
+        Exception exception = null;
         System.err.println("\nRegression test for bug/rfe 4183169\n");
 
         try {
@@ -132,101 +135,37 @@
             desc = new ActivationDesc(secondGroupID,
                 "ShutdownGracefully", null, null);
 
+            /*
+             * registration request is expected to be failed. succeeded case
+             * should be recorded. And raise error after clean up  rmid.
+             */
             try {
                 registering = (RegisteringActivatable)
                     Activatable.register(desc);
-
-                System.err.println("second activate and deactivate " +
-                                   "object via method call");
+                System.err.println("The registration request succeeded unexpectedly");
+                exception = new RuntimeException("The registration request succeeded unexpectedly");
             } catch (ActivationException e) {
                 System.err.println("received exception from registration " +
                                    "call that should have failed...");
-            }
-
-            /*
-             * no longer needed because the security manager
-             * throws an exception during snapshot
-             */
-            /*
-            try {
-                registering.shutdown();
-
-                System.err.println("received exception from remote " +
-                                   "call that should have failed...");
-            } catch (RemoteException e) {
-            }
-            */
-
-        } catch (Exception e) {
-            TestLibrary.bomb("\nfailure: unexpected exception ", e);
-        } finally {
-            try {
-                Thread.sleep(4000);
-            } catch (InterruptedException e) {
-            }
-
-            registering = null;
-
-            // Need to make sure that rmid goes away by itself
-            JavaVM rmidProcess = rmid;
-            if (rmidProcess != null) {
+                // Need wait rmid process terminates.
                 try {
-                    Runnable waitThread =
-                        new ShutdownDetectThread(rmidProcess);
-
-                    synchronized (waitThread) {
-                        (new Thread(waitThread)).start();
-                        waitThread.wait(SHUTDOWN_TIMEOUT);
-                        System.err.println("rmid has shutdown");
-
-                        if (!rmidDone) {
-                            // ensure that this rmid does not infect
-                            // other tests.
-                            rmidProcess.destroy();
-                            TestLibrary.bomb("rmid did not shutdown " +
-                                             "gracefully in time");
-                        }
-                    }
-                } catch (Exception e) {
-                    TestLibrary.bomb("exception waiting for rmid " +
-                                     "to shut down");
+                    int exitCode = rmid.waitFor(SHUTDOWN_TIMEOUT);
+                    System.err.println("RMID has exited gracefully with exitcode:" + exitCode);
+                    rmid = null;
+                } catch (TimeoutException te) {
+                    System.err.println("RMID process has not exited in given time");
+                    exception = te;
                 }
             }
-            // else rmid should be down
-        }
-
-        System.err.println
-            ("\nsuccess: ShutdownGracefully test passed ");
-    }
-
-    private static boolean rmidDone = false;
-
-    /**
-     * class that waits for rmid to exit
-     */
-    private static class ShutdownDetectThread implements Runnable {
-        private JavaVM rmidProcess = null;
-
-        ShutdownDetectThread(JavaVM rmidProcess) {
-            this.rmidProcess = rmidProcess;
+        } catch (Exception e) {
+            System.err.println("Exception thrown:" + e);
+            exception = e;
+        } finally {
+            if (rmid != null)
+                rmid.destroy();
         }
-        public void run() {
-            System.err.println("waiting for rmid to shutdown");
-
-            try {
-                rmidProcess.waitFor();
-            } catch (InterruptedException e) {
-                // should not happen
-            }
-
-            synchronized (this) {
-                // notify parent thread when rmid has exited
-                this.notify();
-                rmidDone = true;
-            }
-
-            RMID.removeLog();
-        }
+        if (exception != null)
+            TestLibrary.bomb("\nexception thrown in test: ", exception);
     }
 
     /**
@@ -240,23 +179,12 @@
     }
 
     /**
-     * Spawns a thread to deactivate the object.
+     * Deactivates the object. We need to unexport forcibly because this call
+     * in-progress on this object, which is the same object that we are trying
+     * to deactivate.
      */
     public void shutdown() throws Exception {
-        (new Thread(this, "ShutdownGracefully")).start();
-    }
-
-    /**
-     * Thread to deactivate object. First attempts to make object
-     * inactive (via the inactive method).  If that fails (the
-     * object may still have pending/executing calls), then
-     * unexport the object forcibly.
-     */
-    public void run() {
-        try {
-            Thread.sleep(50 * 1000);
-        } catch (InterruptedException e) {
-        }
+        Activatable.unexportObject(this, true);
         ActivationLibrary.deactivate(this, getID());
     }
 }
--- a/test/java/rmi/testlibrary/JavaVM.java	Mon May 17 05:47:13 2021 +0100
+++ b/test/java/rmi/testlibrary/JavaVM.java	Wed May 19 16:12:33 2021 +0100
@@ -26,6 +26,7 @@
 import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.StringTokenizer;
+import java.util.concurrent.TimeoutException;
 
 /**
  * RMI regression test utility class that uses Runtime.exec to spawn a
@@ -189,6 +190,40 @@
     }
 
     /**
+     * Causes the current thread to wait the vm process to exit, if necessary,
+     * wait until the vm process has terminated, or the specified waiting time
+     * elapses. Release allocated input/output after vm process has terminated.
+     * @param timeout the maximum milliseconds to wait.
+     * @return exit value for vm process.
+     * @throws InterruptedException if the current thread is interrupted
+     *         while waiting.
+     * @throws TimeoutException if subprocess does not end after timeout
+     *         milliseconds passed
+     */
+    public int waitFor(long timeout)
+            throws InterruptedException, TimeoutException {
+        if (vm == null)
+            throw new IllegalStateException("can't wait for JavaVM that isn't running");
+        long startTime = System.currentTimeMillis();
+        long rem = timeout;
+
+        do {
+            try {
+                int status = vm.exitValue();
+                outPipe.join();
+                errPipe.join();
+                return status;
+            } catch (IllegalThreadStateException ex) {
+                if (rem > 0) {
+                    Thread.sleep(Math.min(rem, 100));
+                }
+            }
+            rem = timeout - (System.currentTimeMillis() - startTime);
+        } while (rem > 0);
+        throw new TimeoutException();
+    }
+
+    /**
      * Starts the subprocess, waits for it to exit, and returns its exit status.
      */
     public int execute() throws IOException, InterruptedException {
--- a/test/java/security/Policy/SignedJar/SignedJarTest.java	Mon May 17 05:47:13 2021 +0100
+++ b/test/java/security/Policy/SignedJar/SignedJarTest.java	Wed May 19 16:12:33 2021 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -32,7 +32,7 @@
 
 /**
  * @test
- * @bug 8048360
+ * @bug 8048360 8242565
  * @summary test policy entry with signedBy alias
  * @library /lib/testlibrary
  * @run main/othervm SignedJarTest
@@ -52,6 +52,7 @@
     private static final String POLICY2 = "SignedJarTest_2.policy";
     private static final String KEYSTORE1 = "both.jks";
     private static final String KEYSTORE2 = "first.jks";
+    private static final String SECPROPS = TESTSRC + FS + "java.security";
 
     public static void main(String args[]) throws Throwable {
         //copy PrivilegeTest.class, policy files and keystore password file into current direcotry
@@ -147,6 +148,7 @@
             "-classpath", classpath,
             "-Djava.security.manager",
             "-Djava.security.policy=" + policy,
+            "-Djava.security.properties=" + SECPROPS,
             "PrivilegeTest",
             arg1, arg2};
         return cmd;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/security/Policy/SignedJar/java.security	Wed May 19 16:12:33 2021 +0100
@@ -0,0 +1,3 @@
+jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, \
+      DSA keySize < 1024, include jdk.disabled.namedCurves, \
+      SHA1 jdkCA & denyAfter 2019-01-01
--- a/test/javax/swing/JRadioButton/8075609/bug8075609.java	Mon May 17 05:47:13 2021 +0100
+++ b/test/javax/swing/JRadioButton/8075609/bug8075609.java	Wed May 19 16:12:33 2021 +0100
@@ -35,11 +35,9 @@
 import javax.swing.event.*;
 import java.awt.event.*;
 import java.awt.*;
-import sun.awt.SunToolkit;
 
 public class bug8075609 {
     private static Robot robot;
-    private static SunToolkit toolkit;
     private static JTextField textField;
 
     public static void main(String args[]) throws Throwable {
@@ -53,7 +51,6 @@
         Thread.sleep(100);
 
         robot.setAutoDelay(100);
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
 
         // Radio button group tab key test
         runTest1();
@@ -96,10 +93,10 @@
     private static void runTest1() throws Exception{
         hitKey(robot, KeyEvent.VK_TAB);
 
-        robot.setAutoDelay(1000 );
+        robot.delay(1000 );
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
-                if (textField.hasFocus()) {
+                if (!textField.hasFocus()) {
                     System.out.println("Radio Button Group Go To Next Component through Tab Key failed");
                     throw new RuntimeException("Focus is not on textField as Expected");
                 }
@@ -110,6 +107,6 @@
     private static void hitKey(Robot robot, int keycode) {
         robot.keyPress(keycode);
         robot.keyRelease(keycode);
-        toolkit.realSync();
+        robot.waitForIdle();
     }
 }