src/share/classes/sun/awt/AppContext.java
Print this page
*** 169,179 ****
* The hash map associated with this AppContext. A private delegate
* is used instead of subclassing HashMap so as to avoid all of
* HashMap's potentially risky methods, such as clear(), elements(),
* putAll(), etc.
*/
! private final HashMap table = new HashMap();
private final ThreadGroup threadGroup;
/**
* If any <code>PropertyChangeListeners</code> have been registered,
--- 169,179 ----
* The hash map associated with this AppContext. A private delegate
* is used instead of subclassing HashMap so as to avoid all of
* HashMap's potentially risky methods, such as clear(), elements(),
* putAll(), etc.
*/
! private final Map<Object, Object> table = new HashMap<>();
private final ThreadGroup threadGroup;
/**
* If any <code>PropertyChangeListeners</code> have been registered,
*** 196,218 ****
static {
// On the main Thread, we get the ThreadGroup, make a corresponding
// AppContext, and instantiate the Java EventQueue. This way, legacy
// code is unaffected by the move to multiple AppContext ability.
! AccessController.doPrivileged(new PrivilegedAction() {
! public Object run() {
ThreadGroup currentThreadGroup =
Thread.currentThread().getThreadGroup();
ThreadGroup parentThreadGroup = currentThreadGroup.getParent();
while (parentThreadGroup != null) {
// Find the root ThreadGroup to construct our main AppContext
currentThreadGroup = parentThreadGroup;
parentThreadGroup = currentThreadGroup.getParent();
}
mainAppContext = new AppContext(currentThreadGroup);
numAppContexts = 1;
! return mainAppContext;
}
});
}
/*
--- 196,218 ----
static {
// On the main Thread, we get the ThreadGroup, make a corresponding
// AppContext, and instantiate the Java EventQueue. This way, legacy
// code is unaffected by the move to multiple AppContext ability.
! AccessController.doPrivileged(new PrivilegedAction<Void>() {
! public Void run() {
ThreadGroup currentThreadGroup =
Thread.currentThread().getThreadGroup();
ThreadGroup parentThreadGroup = currentThreadGroup.getParent();
while (parentThreadGroup != null) {
// Find the root ThreadGroup to construct our main AppContext
currentThreadGroup = parentThreadGroup;
parentThreadGroup = currentThreadGroup.getParent();
}
mainAppContext = new AppContext(currentThreadGroup);
numAppContexts = 1;
! return null;
}
});
}
/*
*** 397,408 ****
w.dispose();
} catch (Throwable t) {
log.finer("exception occured while disposing app context", t);
}
}
! AccessController.doPrivileged(new PrivilegedAction() {
! public Object run() {
if (!GraphicsEnvironment.isHeadless() && SystemTray.isSupported())
{
SystemTray systemTray = SystemTray.getSystemTray();
TrayIcon[] trayIconsToDispose = systemTray.getTrayIcons();
for (TrayIcon ti : trayIconsToDispose) {
--- 397,408 ----
w.dispose();
} catch (Throwable t) {
log.finer("exception occured while disposing app context", t);
}
}
! AccessController.doPrivileged(new PrivilegedAction<Void>() {
! public Void run() {
if (!GraphicsEnvironment.isHeadless() && SystemTray.isSupported())
{
SystemTray systemTray = SystemTray.getSystemTray();
TrayIcon[] trayIconsToDispose = systemTray.getTrayIcons();
for (TrayIcon ti : trayIconsToDispose) {
*** 521,540 ****
eq.postEvent(AWTAutoShutdown.getShutdownEvent());
}
}
}
! static final class CreateThreadAction implements PrivilegedAction {
private final AppContext appContext;
private final Runnable runnable;
public CreateThreadAction(AppContext ac, Runnable r) {
appContext = ac;
runnable = r;
}
! public Object run() {
Thread t = new Thread(appContext.getThreadGroup(), runnable);
t.setContextClassLoader(appContext.getContextClassLoader());
t.setPriority(Thread.NORM_PRIORITY + 1);
t.setDaemon(true);
return t;
--- 521,540 ----
eq.postEvent(AWTAutoShutdown.getShutdownEvent());
}
}
}
! static final class CreateThreadAction implements PrivilegedAction<Thread> {
private final AppContext appContext;
private final Runnable runnable;
public CreateThreadAction(AppContext ac, Runnable r) {
appContext = ac;
runnable = r;
}
! public Thread run() {
Thread t = new Thread(appContext.getThreadGroup(), runnable);
t.setContextClassLoader(appContext.getContextClassLoader());
t.setPriority(Thread.NORM_PRIORITY + 1);
t.setDaemon(true);
return t;
*** 550,561 ****
// For security reasons EventQueue.postEvent should only be called
// on a thread that belongs to the corresponding thread group.
if (appContext != AppContext.getAppContext()) {
// Create a thread that belongs to the thread group associated
// with the AppContext and invokes EventQueue.postEvent.
! PrivilegedAction action = new CreateThreadAction(appContext, r);
! Thread thread = (Thread)AccessController.doPrivileged(action);
thread.start();
} else {
r.run();
}
}
--- 550,561 ----
// For security reasons EventQueue.postEvent should only be called
// on a thread that belongs to the corresponding thread group.
if (appContext != AppContext.getAppContext()) {
// Create a thread that belongs to the thread group associated
// with the AppContext and invokes EventQueue.postEvent.
! PrivilegedAction<Thread> action = new CreateThreadAction(appContext, r);
! Thread thread = AccessController.doPrivileged(action);
thread.start();
} else {
r.run();
}
}