aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormlapshin <none@none>2008-04-18 18:21:02 +0400
committermlapshin <none@none>2008-04-18 18:21:02 +0400
commitfc0854bc0df74df00a2cf4d84af281b7e215d63d (patch)
treea84ebd48a608e366368fb582402d7e56127ca871
parentbae564c16677c3e2d00a9de0b46a9813f5d5a409 (diff)
6675802: Regression: heavyweight popups cause SecurityExceptions in applets
Summary: The problem code in Popup class is surrounded by AccessController.doPrivileged() Reviewed-by: alexp
-rw-r--r--src/share/classes/javax/swing/Popup.java9
-rw-r--r--test/javax/swing/JPopupMenu/6675802/bug6675802.java43
2 files changed, 51 insertions, 1 deletions
diff --git a/src/share/classes/javax/swing/Popup.java b/src/share/classes/javax/swing/Popup.java
index 02ab11610..b246b67f4 100644
--- a/src/share/classes/javax/swing/Popup.java
+++ b/src/share/classes/javax/swing/Popup.java
@@ -229,7 +229,14 @@ public class Popup {
// 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 --git a/test/javax/swing/JPopupMenu/6675802/bug6675802.java b/test/javax/swing/JPopupMenu/6675802/bug6675802.java
new file mode 100644
index 000000000..4c6f6442a
--- /dev/null
+++ b/test/javax/swing/JPopupMenu/6675802/bug6675802.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.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");
+ }
+}