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

Unexpected NPE in GraphicsConfiguration.createVolatileImage

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 6
    • client-libs
    • None
    • 2d
    • 5.0
    • 5.0
    • b45
    • x86
    • linux

      There is undefined NullPointerException in method createCompatibleVolatileImage,
      when parameter transparency has illegal value.
      Note: I test this only on linux machine.
      See next example:
      -------------------------------------------------------------------------------
      import java.awt.*;
      import java.awt.image.*;
      class Test {

          public static void main(String[] args) {
              GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
              GraphicsDevice dsd = ge.getDefaultScreenDevice();
              GraphicsConfiguration gc = dsd.getDefaultConfiguration();

              int[] transparency = { Integer.MIN_VALUE, -1, 0, 4, Integer.MAX_VALUE };
              for (int t = 0; t < transparency.length; t++) {
                      try {
                          System.out.println("VolatileImage will be created with transparency = "
                                  + transparency[t]);
                          VolatileImage vi = gc.createCompatibleVolatileImage(
                                  10, 10, transparency[t]);
                          System.out.println("VolatileImage was created with transparency = "
                                  + transparency[t]);
                      } catch (IllegalArgumentException e) {
                      } catch (NullPointerException e) {
                          System.out.println("Unexpected NullPointer Exception ");
                      }
              }
          }
      }
      ###@###.### 10/28/04 14:17 GMT

            tdv Dmitri Trembovetski (Inactive)
            lmesnik Leonid Mesnik
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: