7170427: setGlobalCurrentFocusCycleRoot unexpectedly throws SecurityException
Reviewed-by: art
--- a/jdk/src/share/classes/java/awt/Component.java Mon May 21 18:55:36 2012 +0400
+++ b/jdk/src/share/classes/java/awt/Component.java Tue May 22 01:12:16 2012 +0400
@@ -7947,32 +7947,21 @@
if (rootAncestor != null) {
Container rootAncestorRootAncestor =
rootAncestor.getFocusCycleRootAncestor();
-
- final Container fcr = (rootAncestorRootAncestor != null) ?
+ Container fcr = (rootAncestorRootAncestor != null) ?
rootAncestorRootAncestor : rootAncestor;
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- KeyboardFocusManager.getCurrentKeyboardFocusManager().
- setGlobalCurrentFocusCycleRoot(fcr);
- return null;
- }
- });
+ KeyboardFocusManager.getCurrentKeyboardFocusManager().
+ setGlobalCurrentFocusCycleRootPriv(fcr);
rootAncestor.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_UP);
} else {
- final Window window = getContainingWindow();
+ Window window = getContainingWindow();
if (window != null) {
Component toFocus = window.getFocusTraversalPolicy().
getDefaultComponent(window);
if (toFocus != null) {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- KeyboardFocusManager.getCurrentKeyboardFocusManager().
- setGlobalCurrentFocusCycleRoot(window);
- return null;
- }
- });
+ KeyboardFocusManager.getCurrentKeyboardFocusManager().
+ setGlobalCurrentFocusCycleRootPriv(window);
toFocus.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_UP);
}
}
--- a/jdk/src/share/classes/java/awt/Container.java Mon May 21 18:55:36 2012 +0400
+++ b/jdk/src/share/classes/java/awt/Container.java Tue May 22 01:12:16 2012 +0400
@@ -3245,7 +3245,7 @@
if (root != currentFocusCycleRoot) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
- setGlobalCurrentFocusCycleRoot(root);
+ setGlobalCurrentFocusCycleRootPriv(root);
}
return root;
}
@@ -3302,7 +3302,7 @@
Container cont = kfm.getCurrentFocusCycleRoot();
if (cont == this || isParentOf(cont)) {
- kfm.setGlobalCurrentFocusCycleRoot(null);
+ kfm.setGlobalCurrentFocusCycleRootPriv(null);
}
}
@@ -3506,7 +3506,7 @@
public void transferFocusDownCycle() {
if (isFocusCycleRoot()) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
- setGlobalCurrentFocusCycleRoot(this);
+ setGlobalCurrentFocusCycleRootPriv(this);
Component toFocus = getFocusTraversalPolicy().
getDefaultComponent(this);
if (toFocus != null) {
--- a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java Mon May 21 18:55:36 2012 +0400
+++ b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java Tue May 22 01:12:16 2012 +0400
@@ -637,8 +637,8 @@
}
void clearGlobalFocusOwnerPriv() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
clearGlobalFocusOwner();
return null;
}
@@ -1287,6 +1287,15 @@
newFocusCycleRoot);
}
+ void setGlobalCurrentFocusCycleRootPriv(final Container newFocusCycleRoot) {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
+ setGlobalCurrentFocusCycleRoot(newFocusCycleRoot);
+ return null;
+ }
+ });
+ }
+
/**
* Adds a PropertyChangeListener to the listener list. The listener is
* registered for all bound properties of this class, including the