6759311: RepaintManager casts Tookit to SunToolkit without instanceof check
authorrkennke
Wed, 15 Oct 2008 15:55:19 +0200
changeset 1832 0a885bee1070
parent 1831 c9effd4226ea
child 1833 e4d8baed5336
6759311: RepaintManager casts Tookit to SunToolkit without instanceof check Summary: Check type of Toolkit before casting. Reviewed-by: alexp
jdk/src/share/classes/javax/swing/RepaintManager.java
--- a/jdk/src/share/classes/javax/swing/RepaintManager.java	Tue Oct 07 18:25:59 2008 +0900
+++ b/jdk/src/share/classes/javax/swing/RepaintManager.java	Wed Oct 15 15:55:19 2008 +0200
@@ -1305,9 +1305,12 @@
             if (doubleBufferingEnabled && !nativeDoubleBuffering) {
                 switch (bufferStrategyType) {
                 case BUFFER_STRATEGY_NOT_SPECIFIED:
-                    if (((SunToolkit)Toolkit.getDefaultToolkit()).
-                                                useBufferPerWindow()) {
-                        paintManager = new BufferStrategyPaintManager();
+                    Toolkit tk = Toolkit.getDefaultToolkit();
+                    if (tk instanceof SunToolkit) {
+                        SunToolkit stk = (SunToolkit) tk;
+                        if (stk.useBufferPerWindow()) {
+                            paintManager = new BufferStrategyPaintManager();
+                        }
                     }
                     break;
                 case BUFFER_STRATEGY_SPECIFIED_ON:
@@ -1329,9 +1332,16 @@
 
     private void scheduleProcessingRunnable(AppContext context) {
         if (processingRunnable.markPending()) {
-            SunToolkit.getSystemEventQueueImplPP(context).
-                postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(),
-                                              processingRunnable));
+            Toolkit tk = Toolkit.getDefaultToolkit();
+            if (tk instanceof SunToolkit) {
+                SunToolkit.getSystemEventQueueImplPP(context).
+                  postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(),
+                                                processingRunnable));
+            } else {
+                Toolkit.getDefaultToolkit().getSystemEventQueue().
+                      postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(),
+                                                    processingRunnable));
+            }
         }
     }