JDK-6417505 : GraphicsDevice.getDisplayMode() returns null with ddraw disabled, Vista
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2006-04-25
  • Updated: 2011-01-19
  • Resolved: 2006-05-26
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.
Other Other JDK 6
1.4.2_19-revFixed 1.4.2_20Fixed 6 b86Fixed
Related Reports
Relates :  
Description
Use the attached testcase to reproduce the problem.

The results of the test running is following:

on Vista:
using -Dsun.java2d.noddraw=True returns null
using -Dsun.java2d.noddraw=False returns not null value

on XP:
returns not null value in both cases

============TESTCASE==================================

import java.awt.*;

public class GetDisplayModeTest{

	public static final void main(String args[]){
		GraphicsDevice gd = 
		    GraphicsEnvironment.getLocalGraphicsEnvironment().
		    getDefaultScreenDevice();
	        if (!gd.isFullScreenSupported()) {
		    System.out.println("Full Screen is not supported, test considered passed.");
		    return;
	    	}
		DisplayMode dm = gd.getDisplayMode();
		System.out.println("Display Mode = "+dm);
	}
}

Comments
SUGGESTED FIX http://javaweb.sfbay/jcg/1.6.0-mustang/2D/6417505
26-04-2006

SUGGESTED FIX removed
25-04-2006

EVALUATION The reason for the failure is that Vista by default has a non-attached device (with DISPLAY_DEVICE_MIRRORING_DRIVER flag) listed as the first device found by EnumDisplayDevices. Our code for getting the device name by the screen number wasn't checking if the device was attached. When we later tried to use EnumDisplaySettings with this mirroring virtual device, it would not find any display modes for it, thus the NPE. The fix is to correctly identify the attached devices.
25-04-2006

EVALUATION Looks like a Vista-specific problem, works fine on XP with ddraw disabled. I get the NPE on the latest Vista build-as well.
25-04-2006