Mercurial > hg > icedtea9-forest > jdk
changeset 5555:967b38bfd5c1
7170427: setGlobalCurrentFocusCycleRoot unexpectedly throws SecurityException
Reviewed-by: art
author | ant |
---|---|
date | Tue, 22 May 2012 01:12:16 +0400 |
parents | 1ee12bca4823 |
children | 5b2095d7a60b 5ff4693406ad |
files | src/share/classes/java/awt/Component.java src/share/classes/java/awt/Container.java src/share/classes/java/awt/KeyboardFocusManager.java |
diffstat | 3 files changed, 20 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/java/awt/Component.java Mon May 21 18:55:36 2012 +0400 +++ b/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/src/share/classes/java/awt/Container.java Mon May 21 18:55:36 2012 +0400 +++ b/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/src/share/classes/java/awt/KeyboardFocusManager.java Mon May 21 18:55:36 2012 +0400 +++ b/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