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

Toolkit.createImage and getImage work incorrectly in headless mode.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Duplicate
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
      None
    • Subcomponent:
      2d
    • CPU:
      sparc
    • OS:
      solaris_9

      Description

      The methods of class java.awt.Toolkit
      public abstract Image createImage
      public abstract Image getImage
      work incorrectly in headless mode under jdk 1.5.0

      getImage method returns null for valid image in this case, createImage throws
      NullPointerException.

      Here is example:
      import java.awt.*;

      public class test02 {
          public static void main (String[] args) {
              Image im = Toolkit.getDefaultToolkit().getImage("im.gif");
              if (im == null) {
                  System.out.println("Failed: im == null");
              }
              Toolkit.getDefaultToolkit().createImage("im.gif");
              System.out.println("OKAY");
              System.exit(0);
          }
      }


      --- Output: ---
      % java -version
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b07)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b07, mixed mode)
      % java test02
      OKAY
      % java -Djava.awt.headless=true test02
      Failed: im == null
      Exception in thread "main" java.lang.NullPointerException
              at sun.awt.motif.MToolkit.createImage(MToolkit.java:395)
              at sun.awt.SunToolkit.createImage(SunToolkit.java:498)
              at sun.awt.HeadlessToolkit.createImage(HeadlessToolkit.java:333)
              at test02.main(test02.java:9)
      ------------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              campbell Christopher Campbell (Inactive)
              Reporter:
              sdasunw Sda Sda (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: