-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
5.0
-
None
-
sparc
-
solaris_9
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)
------------
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)
------------
- duplicates
-
JDK-4867328 NPE is thrown by JColorChooser and toolkit.createImage() in Headless mode
- Resolved