8028285: RMI Thread can no longer call out to AWT
authorpchelko
Tue, 25 Feb 2014 19:48:47 +0400
changeset 25529 a6c103245f63
parent 25528 5c0c16556c1b
child 25530 eff82298a934
8028285: RMI Thread can no longer call out to AWT Reviewed-by: art, serb, ddehaven
jdk/src/share/classes/sun/awt/AppContext.java
--- a/jdk/src/share/classes/sun/awt/AppContext.java	Mon Feb 24 11:03:49 2014 -0800
+++ b/jdk/src/share/classes/sun/awt/AppContext.java	Tue Feb 25 19:48:47 2014 +0400
@@ -331,6 +331,20 @@
                     while (context == null) {
                         threadGroup = threadGroup.getParent();
                         if (threadGroup == null) {
+                            // We've got up to the root thread group and did not find an AppContext
+                            // Try to get it from the security manager
+                            SecurityManager securityManager = System.getSecurityManager();
+                            if (securityManager != null) {
+                                ThreadGroup smThreadGroup = securityManager.getThreadGroup();
+                                if (smThreadGroup != null) {
+                                    /*
+                                     * If we get this far then it's likely that
+                                     * the ThreadGroup does not actually belong
+                                     * to the applet, so do not cache it.
+                                     */
+                                    return threadGroup2appContext.get(smThreadGroup);
+                                }
+                            }
                             return null;
                         }
                         context = threadGroup2appContext.get(threadGroup);