JDK-4713937 : Null pointer exeption thrown when trying to get a volatile image which has gone
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2002-07-12
  • Updated: 2003-07-03
  • Resolved: 2003-06-18
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
1.4.1_05 05Fixed
Description

Name: dk106046			Date: 07/12/2002

1.4.0-rc-b91

Problem found running the IBM Host On Demand application. The problem is occasional, on NT 4 operating system.  The stack dump shows that the volatile image is in the process of going away, and the code is designed to handle this case by creating a new one. However the failure is not the expected one, but an earlier null pointer exception caused by the image being present, but the graphicsconfig within it being null.

java.lang.NullPointerException
       at sun/awt/windows/WVolatileImage.getDeviceColorModel(WVolatileImage.java:161)
       at sun/awt/windows/WVolatileImage.createHWData(WVolatileImage.java:116)
       at sun/awt/windows/WVolatileImage.initAcceleratedBackground(WVolatileImage.java:129)
       at sun/awt/image/SunVolatileImage.validate(SunVolatileImage.java:291)
       at javax/swing/JComponent.paintDoubleBuffered(JComponent.java:4730)

The proposed solution is to add code in WVolatileImage to handle the null pointer exception, and allow the expected failure to happen later:

   protected ColorModel getDeviceColorModel() {
       if (comp != null) {
           Win32GraphicsConfig gc = 
              (Win32GraphicsConfig)comp.getGraphicsConfiguration();
            if (gc != null) {                                /*ibm@52938*/
                try {                                        /*ibm@52938*/
                    return gc.getDeviceColorModel();
                }                                            /*ibm@52938*/
                catch (NullPointerException e) {             /*ibm@52938*/
                  /* fall through to return the default */   /*ibm@52938*/
                }                                            /*ibm@52938*/
            }                                                /*ibm@52938*/
        }
        return ((Win32GraphicsConfig)graphicsConfig).getDeviceColorModel();
    }


In this 'belt and braces' approach we are testing both for a null gc, and any failure in getDeviceColorModel - this is probably overkill, as the error found is gc being null.

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.1_05 FIXED IN: 1.4.1_05 INTEGRATED IN: 1.4.1_05
14-06-2004

EVALUATION I think this is an issue 2D would prefer to take. ###@###.### 2002-07-12 I'm able to reproduce the problem with this config: - ATI 3D RAGE PRO AGP 2X video card - Win 2K sp3 - Netscape 7.02 - JRE 1.4.1_02 So far, this problem can only be reproduced with the above video card. I couldn't reproduce it with the following video cards: ATI Radeon VE NVIDIA GeForce2 MX100/200 The suggested fix in the description seems to have fixed the NPE problem. Although the suggested fix isn't in Mantis, I couldn't reproduce the problem using Mantis b18. Therefore, I'm adding mantis-na to the keywords. ###@###.### 2003-03-21 Attaching the test case to this bug report. Enable java plugin console and run the swingsetframe.html applet with the config. as mentioned above. Reload the applet. You'll see NPE at the console and the graphics won't get displayed in the browser. You'll see ###@###.### 2003-03-21
21-03-2003