JDK-6880694 : GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris
  • CPU: generic
  • Submitted: 2009-09-10
  • Updated: 2012-03-22
  • Resolved: 2009-11-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u23Fixed 7 b77Fixed
Related Reports
Relates :  
Description
The following JCK tests fail due to this issue:
api/java_awt/GraphicsDevice/indexTGF.html#ShapeAndTranslucencyForFullScreen[nullShape]
api/java_awt/Window/indexTGF.html#BackgroundGeneral[testNoAlphaFullScreen]
api/java_awt/Window/indexTGF.html#ShapeGeneral[nullShapeForFullScreen]
The following code causes NPE on Solaris.
JDK: 7 build 74
Platform: Solaris x86
------------------------------------------------------------------------------------------
import java.awt.*;

public class NPE {

    public static void main(String[] args) {
        GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
        devices[0].setFullScreenWindow(new Frame());
        devices[0].setFullScreenWindow(null);
    }
}
------------------------------------------------------------------------------------------

<db158260@zenit(pts/28).278> /set/java/re/j2se/7/promoted/latest/binaries/solaris-i586/bin/java NPE
Exception in thread "main" java.lang.NullPointerException
        at sun.awt.X11GraphicsDevice.setDisplayMode(X11GraphicsDevice.java:388)
        at sun.awt.X11GraphicsDevice.setFullScreenWindow(X11GraphicsDevice.java:330)
        at NPE.main(NPE.java:10)

Comments
SUGGESTED FIX http://sa.sfbay.sun.com/projects/awt_data/7/6880694/
11-11-2009

EVALUATION Below is the complete version of the test to reproduce the bug: ----------------------------------------------------- import java.awt.*; public class test{ public static final void main(String args[]){ GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); devices[0].setFullScreenWindow(new Frame()); devices[0].setFullScreenWindow(null); } } ----------------------------------------------------- The problem is reproducible for me when I login to SunRay terminal (CDE environment) and run the test there. The test creates a simple frame, then sets this frame as the full-screen window and finally returns to windowed mode. During the last step AWT throws the following NPE exception: Exception in thread "main" java.lang.NullPointerException at sun.awt.X11GraphicsDevice.setDisplayMode(X11GraphicsDevice.java:390) at sun.awt.X11GraphicsDevice.setFullScreenWindow(X11GraphicsDevice.java:332) at test.main(test.java:16) The NPE exception happens because the native X11GraphicsDevice.getCurrentDisplayMode method returns null as the current display mode. The reason for the behaviour is that in our native code (awt_GraphicsEnv.c) we have the following check if ((sizes != NULL) && (curSizeIndex < nsizes) && (curRate > 0)) And if the current rate is zero (or negative), then the native method returns a null display mode. Here's some observations related to XRANDR extention (used by AWT to implement full-screen more). The extension seems to be installed correctly: ------------------------------------------------------ $xrandr --version Server reports RandR version 1.1 ------------------------------------------------------ Note this version of the xrandr seems quite outdated. Below is the current state of the system (according to xrandr -q): ------------------------------------------------------ $xrandr -q SZ: Pixels Physical Refresh 0 640 x 480 ( 180mm x 135mm ) 1 800 x 600 ( 225mm x 169mm ) 2 1024 x 768 ( 288mm x 216mm ) 3 1152 x 900 ( 324mm x 254mm ) *4 1280 x 1024 ( 361mm x 289mm ) Current rotation - normal Current reflection - none Rotations possible - normal Reflections possible - none ------------------------------------------------------ Note that the refresh rate is empty and any attempt to explicitly set the rate to 60Hz fails: ------------------------------------------------------ $xrandr -r 60 rate 60.0 Hz not available for this size ------------------------------------------------------ To proceed with the bug, we might want to 1. narrow down the xrandr issue. Is it a bug specific to version 1.1 of xrandr or a misconfigured environment (on client or server side)? 2. remove the check for the current rate to create non-null current display mode in any case. It looks like we should use DisplayMode.REFRESH_RATE_UNKNOWN as a value for the refresh rate field in this case. 3. lower the priority of the issue (so far it reproducible in quite an exotic case: CDE, xrandr 1.1, SunRay)
23-10-2009