-
Bug
-
Resolution: Fixed
-
P3
-
5.0, 6
-
b73
-
generic, x86
-
generic, windows_xp
FULL PRODUCT VERSION :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [version 5.1.2600]
Service Pack 2
EXTRA RELEVANT SYSTEM CONFIGURATION :
ATI Mobility radeon 9700 graphics card
A DESCRIPTION OF THE PROBLEM :
When AWT is active, switching display mode from the Windows control panel results in the following exception from the AWT thread:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.awt.Win32GraphicsEnvironment.displayChanged(Unknown Source)
at sun.awt.windows.WToolkit$4.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
This is especially annoying for us, since we're developing games using LWJGL (http://lwjgl.org) which switches display mode without using AWT. The exception occurs in that case too. Although the game seems to runs fine even after the exception, one never knows what internal invariant might be broken.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile and run the attached program
2. Go to the display properties control panel and select a different display mode.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception is thrown.
ACTUAL -
An exception is thrown:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.awt.Win32GraphicsEnvironment.displayChanged(Unknown Source)
at sun.awt.windows.WToolkit$4.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.awt.Win32GraphicsEnvironment.displayChanged(Unknown Source)
at sun.awt.windows.WToolkit$4.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
public class test {
public static void main(String[] args) throws Exception {
Toolkit.getDefaultToolkit();
System.out.println("AWT initialized, please switch mode now");
Thread.sleep(10000000);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't switch mode while java programs are running :)
Contribution by java.net member dmytro_sheyko:
A DESCRIPTION OF THE FIX :
Bug number : 6358034
Bug Description : NPE in Win32GraphicsEnvironment.displayChanged when switching display mode
Diff Baseline : Mustang b67.
Diff :
--- src\windows\classes\sun\awt\Win32GraphicsEnvironment.java Tue Jan 17 10:49:04 2006
+++ src\windows\classes\sun\awt\Win32GraphicsEnvironment.java Fri Jan 20 13:08:42 2006
@@ -125,9 +125,10 @@
/*
* Updates the array of screen devices to the current configuration.
- * Returns the previous array of screen devices.
+ * Returns the previous array of screen devices,
+ * which may be empty but never null.
*/
- public synchronized GraphicsDevice[] resetDisplays() {
+ private synchronized GraphicsDevice[] resetDisplays() {
// REMIND : We should go through the array and update any displays
// which may have been added or removed. Also, we should update
// any display state information which may now be different.
@@ -137,8 +138,10 @@
// changes, and because programs may keep references to those
// java objects.
GraphicsDevice[] ret = screens;
- return ret;
+ return (ret == null)? EMPTY_ARRAY_OF_GraphicsDevice: ret;
}
+ // where
+ private static final GraphicsDevice[] EMPTY_ARRAY_OF_GraphicsDevice = new GraphicsDevice[0];
/*
* ----END DISPLAY CHANGE SUPPORT----
JUnit TESTCASE :
import java.awt.GraphicsEnvironment;
import junit.framework.TestCase;
public class Bug6358034Test extends TestCase {
public void test() throws Exception {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
// NullPointerException does not have to be thrown
((sun.awt.Win32GraphicsEnvironment) ge).displayChanged();
}
public static void main(String[] args) {
junit.textui.TestRunner.run(Bug6358034Test.class);
}
}
FIX FOR BUG NUMBER:
6358034
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [version 5.1.2600]
Service Pack 2
EXTRA RELEVANT SYSTEM CONFIGURATION :
ATI Mobility radeon 9700 graphics card
A DESCRIPTION OF THE PROBLEM :
When AWT is active, switching display mode from the Windows control panel results in the following exception from the AWT thread:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.awt.Win32GraphicsEnvironment.displayChanged(Unknown Source)
at sun.awt.windows.WToolkit$4.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
This is especially annoying for us, since we're developing games using LWJGL (http://lwjgl.org) which switches display mode without using AWT. The exception occurs in that case too. Although the game seems to runs fine even after the exception, one never knows what internal invariant might be broken.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile and run the attached program
2. Go to the display properties control panel and select a different display mode.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception is thrown.
ACTUAL -
An exception is thrown:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.awt.Win32GraphicsEnvironment.displayChanged(Unknown Source)
at sun.awt.windows.WToolkit$4.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.awt.Win32GraphicsEnvironment.displayChanged(Unknown Source)
at sun.awt.windows.WToolkit$4.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
public class test {
public static void main(String[] args) throws Exception {
Toolkit.getDefaultToolkit();
System.out.println("AWT initialized, please switch mode now");
Thread.sleep(10000000);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't switch mode while java programs are running :)
Contribution by java.net member dmytro_sheyko:
A DESCRIPTION OF THE FIX :
Bug number : 6358034
Bug Description : NPE in Win32GraphicsEnvironment.displayChanged when switching display mode
Diff Baseline : Mustang b67.
Diff :
--- src\windows\classes\sun\awt\Win32GraphicsEnvironment.java Tue Jan 17 10:49:04 2006
+++ src\windows\classes\sun\awt\Win32GraphicsEnvironment.java Fri Jan 20 13:08:42 2006
@@ -125,9 +125,10 @@
/*
* Updates the array of screen devices to the current configuration.
- * Returns the previous array of screen devices.
+ * Returns the previous array of screen devices,
+ * which may be empty but never null.
*/
- public synchronized GraphicsDevice[] resetDisplays() {
+ private synchronized GraphicsDevice[] resetDisplays() {
// REMIND : We should go through the array and update any displays
// which may have been added or removed. Also, we should update
// any display state information which may now be different.
@@ -137,8 +138,10 @@
// changes, and because programs may keep references to those
// java objects.
GraphicsDevice[] ret = screens;
- return ret;
+ return (ret == null)? EMPTY_ARRAY_OF_GraphicsDevice: ret;
}
+ // where
+ private static final GraphicsDevice[] EMPTY_ARRAY_OF_GraphicsDevice = new GraphicsDevice[0];
/*
* ----END DISPLAY CHANGE SUPPORT----
JUnit TESTCASE :
import java.awt.GraphicsEnvironment;
import junit.framework.TestCase;
public class Bug6358034Test extends TestCase {
public void test() throws Exception {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
// NullPointerException does not have to be thrown
((sun.awt.Win32GraphicsEnvironment) ge).displayChanged();
}
public static void main(String[] args) {
junit.textui.TestRunner.run(Bug6358034Test.class);
}
}
FIX FOR BUG NUMBER:
6358034
- relates to
-
JDK-7117595 ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
- Resolved
-
JDK-6733718 test /java/awt/FullScreen/UninitializedDisplayModeChangeTest/ fails
- Resolved