Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4713937

Null pointer exeption thrown when trying to get a volatile image which has gone

XMLWordPrintable

    • 2d
    • 05
    • x86
    • windows_nt



      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.

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

            chaasesunw Chet Haase (Inactive)
            dkorbel David Korbel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: