# HG changeset patch
# User mlapshin
# Date 1208528462 -14400
# Node ID dd66920b2d51e33ca2157ab045117cc7c7f5f0c0
# Parent  147803acf437b81e72e50236030f2bc9ac37caee
6675802: Regression: heavyweight popups cause SecurityExceptions in applets
Summary: The problem code in Popup class is surrounded by AccessController.doPrivileged()
Reviewed-by: alexp

diff -r 147803acf437 -r dd66920b2d51 src/share/classes/javax/swing/Popup.java
--- openjdk.orig/jdk/src/share/classes/javax/swing/Popup.java	Mon Apr 14 16:41:00 2008 +0400
+++ openjdk/jdk/src/share/classes/javax/swing/Popup.java	Fri Apr 18 18:21:02 2008 +0400
@@ -229,7 +229,14 @@
             // Popups are typically transient and most likely won't benefit
             // from true double buffering.  Turn it off here.
             getRootPane().setUseTrueDoubleBuffering(false);
-            setAlwaysOnTop(true);
+            java.security.AccessController.doPrivileged(
+                    new java.security.PrivilegedAction<Object>() {
+                        public Object run() {
+                            setAlwaysOnTop(true);
+                            return null;
+                        }
+                    }
+            );
         }
 
         public void update(Graphics g) {
diff -r 147803acf437 -r dd66920b2d51 test/javax/swing/JPopupMenu/6675802/bug6675802.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ openjdk/jdk/test/javax/swing/JPopupMenu/6675802/bug6675802.java	Fri Apr 18 18:21:02 2008 +0400
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2008, 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 6675802
+ * @summary Checks that there is no AccessControlException when
+ * a heaviweight popup menu is shown from an applet.
+ * @author Mikhail Lapshin
+ * @run main bug6675802
+ */
+
+import javax.swing.*;
+
+public class bug6675802 {
+    public static void main(String[] args) {
+        System.setSecurityManager(new SecurityManager());
+        final JPopupMenu popupMenu = new JPopupMenu();
+        popupMenu.add(new JMenuItem("Click"));
+        popupMenu.show(null, 0, 0);
+        System.out.println("Test passed");
+    }
+}
