6759311: RepaintManager casts Tookit to SunToolkit without instanceof check

Check type of Toolkit before casting.

Reviewed-by: alexp
This commit is contained in:
Roman Kennke 2008-10-15 15:55:19 +02:00
parent 671a2de6c7
commit 5c08fa0e79

View File

@ -1305,9 +1305,12 @@ public class RepaintManager
if (doubleBufferingEnabled && !nativeDoubleBuffering) { if (doubleBufferingEnabled && !nativeDoubleBuffering) {
switch (bufferStrategyType) { switch (bufferStrategyType) {
case BUFFER_STRATEGY_NOT_SPECIFIED: case BUFFER_STRATEGY_NOT_SPECIFIED:
if (((SunToolkit)Toolkit.getDefaultToolkit()). Toolkit tk = Toolkit.getDefaultToolkit();
useBufferPerWindow()) { if (tk instanceof SunToolkit) {
paintManager = new BufferStrategyPaintManager(); SunToolkit stk = (SunToolkit) tk;
if (stk.useBufferPerWindow()) {
paintManager = new BufferStrategyPaintManager();
}
} }
break; break;
case BUFFER_STRATEGY_SPECIFIED_ON: case BUFFER_STRATEGY_SPECIFIED_ON:
@ -1329,9 +1332,16 @@ public class RepaintManager
private void scheduleProcessingRunnable(AppContext context) { private void scheduleProcessingRunnable(AppContext context) {
if (processingRunnable.markPending()) { if (processingRunnable.markPending()) {
SunToolkit.getSystemEventQueueImplPP(context). Toolkit tk = Toolkit.getDefaultToolkit();
postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(), if (tk instanceof SunToolkit) {
processingRunnable)); SunToolkit.getSystemEventQueueImplPP(context).
postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(),
processingRunnable));
} else {
Toolkit.getDefaultToolkit().getSystemEventQueue().
postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(),
processingRunnable));
}
} }
} }