# HG changeset patch # User ant # Date 1337634736 -14400 # Node ID 0799075de9d69cbdeb5c4b6209e628939ec424b6 # Parent 7ca53adedb3169bdbb0abd95fdaeaa858875b3ee 7170427: setGlobalCurrentFocusCycleRoot unexpectedly throws SecurityException Reviewed-by: art diff -r 7ca53adedb31 -r 0799075de9d6 jdk/src/share/classes/java/awt/Component.java --- 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); } } diff -r 7ca53adedb31 -r 0799075de9d6 jdk/src/share/classes/java/awt/Container.java --- 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) { diff -r 7ca53adedb31 -r 0799075de9d6 jdk/src/share/classes/java/awt/KeyboardFocusManager.java --- 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() { + public Void run() { clearGlobalFocusOwner(); return null; } @@ -1287,6 +1287,15 @@ newFocusCycleRoot); } + void setGlobalCurrentFocusCycleRootPriv(final Container newFocusCycleRoot) { + AccessController.doPrivileged(new PrivilegedAction() { + 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