8011695: [tck-red] Application can not be run, the Security Warning dialog is gray.
Summary: EventQueue shouldn't use AppContext.getAppContext() to obtain its AppContext.
Reviewed-by: art
--- a/jdk/src/share/classes/java/awt/EventQueue.java Mon Apr 15 14:11:32 2013 +0400
+++ b/jdk/src/share/classes/java/awt/EventQueue.java Tue Apr 16 21:19:02 2013 +0400
@@ -179,6 +179,11 @@
*/
private volatile int waitForID;
+ /*
+ * AppContext corresponding to the queue.
+ */
+ private final AppContext appContext;
+
private final String name = "AWT-EventQueue-" + threadInitNumber.getAndIncrement();
private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventQueue");
@@ -225,8 +230,9 @@
* completes thus causing mess in thread group to appcontext mapping.
*/
- pushPopLock = (Lock)AppContext.getAppContext().get(AppContext.EVENT_QUEUE_LOCK_KEY);
- pushPopCond = (Condition)AppContext.getAppContext().get(AppContext.EVENT_QUEUE_COND_KEY);
+ appContext = AppContext.getAppContext();
+ pushPopLock = (Lock)appContext.get(AppContext.EVENT_QUEUE_LOCK_KEY);
+ pushPopCond = (Condition)appContext.get(AppContext.EVENT_QUEUE_COND_KEY);
}
/**
@@ -240,7 +246,7 @@
* @throws NullPointerException if <code>theEvent</code> is <code>null</code>
*/
public void postEvent(AWTEvent theEvent) {
- SunToolkit.flushPendingEvents();
+ SunToolkit.flushPendingEvents(appContext);
postEventPrivate(theEvent);
}
@@ -525,7 +531,7 @@
* of the synchronized block to avoid deadlock when
* event queues are nested with push()/pop().
*/
- SunToolkit.flushPendingEvents();
+ SunToolkit.flushPendingEvents(appContext);
pushPopLock.lock();
try {
AWTEvent event = getNextEventPrivate();
@@ -565,7 +571,7 @@
* of the synchronized block to avoid deadlock when
* event queues are nested with push()/pop().
*/
- SunToolkit.flushPendingEvents();
+ SunToolkit.flushPendingEvents(appContext);
pushPopLock.lock();
try {
for (int i = 0; i < NUM_PRIORITIES; i++) {
@@ -873,7 +879,6 @@
newEventQueue.previousQueue = topQueue;
topQueue.nextQueue = newEventQueue;
- AppContext appContext = AppContext.getAppContext();
if (appContext.get(AppContext.EVENT_QUEUE_KEY) == topQueue) {
appContext.put(AppContext.EVENT_QUEUE_KEY, newEventQueue);
}
@@ -934,7 +939,6 @@
topQueue.dispatchThread.setEventQueue(prevQueue);
}
- AppContext appContext = AppContext.getAppContext();
if (appContext.get(AppContext.EVENT_QUEUE_KEY) == this) {
appContext.put(AppContext.EVENT_QUEUE_KEY, prevQueue);
}
@@ -1027,7 +1031,6 @@
final void initDispatchThread() {
pushPopLock.lock();
try {
- AppContext appContext = AppContext.getAppContext();
if (dispatchThread == null && !threadGroup.isDestroyed() && !appContext.isDisposed()) {
dispatchThread = AccessController.doPrivileged(
new PrivilegedAction<EventDispatchThread>() {
@@ -1055,7 +1058,7 @@
/*
* Minimize discard possibility for non-posted events
*/
- SunToolkit.flushPendingEvents();
+ SunToolkit.flushPendingEvents(appContext);
/*
* This synchronized block is to secure that the event dispatch
* thread won't die in the middle of posting a new event to the
@@ -1114,7 +1117,7 @@
* <code>removeNotify</code> method.
*/
final void removeSourceEvents(Object source, boolean removeAllEvents) {
- SunToolkit.flushPendingEvents();
+ SunToolkit.flushPendingEvents(appContext);
pushPopLock.lock();
try {
for (int i = 0; i < NUM_PRIORITIES; i++) {
--- a/jdk/src/share/classes/javax/swing/RepaintManager.java Mon Apr 15 14:11:32 2013 +0400
+++ b/jdk/src/share/classes/javax/swing/RepaintManager.java Tue Apr 16 21:19:02 2013 +0400
@@ -354,7 +354,7 @@
// Queue a Runnable to invoke paintDirtyRegions and
// validateInvalidComponents.
- scheduleProcessingRunnable();
+ scheduleProcessingRunnable(SunToolkit.targetToAppContext(invalidComponent));
}
@@ -443,7 +443,7 @@
// Queue a Runnable to invoke paintDirtyRegions and
// validateInvalidComponents.
- scheduleProcessingRunnable();
+ scheduleProcessingRunnable(SunToolkit.targetToAppContext(c));
}
/**
@@ -1389,10 +1389,6 @@
return paintManager;
}
- private void scheduleProcessingRunnable() {
- scheduleProcessingRunnable(AppContext.getAppContext());
- }
-
private void scheduleProcessingRunnable(AppContext context) {
if (processingRunnable.markPending()) {
Toolkit tk = Toolkit.getDefaultToolkit();
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java Mon Apr 15 14:11:32 2013 +0400
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java Tue Apr 16 21:19:02 2013 +0400
@@ -97,6 +97,14 @@
*/
public final static int MAX_BUTTONS_SUPPORTED = 20;
+ /**
+ * Creates and initializes EventQueue instance for the specified
+ * AppContext.
+ * Note that event queue must be created from createNewAppContext()
+ * only in order to ensure that EventQueue constructor obtains
+ * the correct AppContext.
+ * @param appContext AppContext to associate with the event queue
+ */
private static void initEQ(AppContext appContext) {
EventQueue eventQueue;