-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.0
-
sparc
-
solaris_2.5
Name: apR10100 Date: 02/06/2002
This is companion bug for JDK bug: 4633887
PBP behaviour for this test:
--------- PBP output
~/bin/pp/pbptest TestImage
Set image to: 'null'
,~;
---------
Methods:
Frame.setIconImage incorrectly and
inconsistently handles null as parameter.
JDK1.4 spec states:
------------------
public Image getIconImage()
Gets the image to be displayed in the minimized icon for this frame.
Returns:
the icon image for this frame, or null if this frame doesn't have an icon image.
...
public void setIconImage(Image image)
Sets the image to be displayed in the minimized icon for this frame. Not
all platforms support the concept of minimizing a window.
Parameters:
image - the icon image to be displayed. If this parameter is null then the
icon image is set to the default image, which may vary with platform.
--------------------------------------------------------------------------------
According to this, setIconImage should accept null without
Exception and getIconImage() should return !null after
setIconImage(null) call. Behaviour of JDK1.4 is inconsistent
between solaris/windows and getIconImage() may return null
after setIconImage(null) call. Please, see the test example,
demonstrating this behaviour:
------ TestImage.java
import java.awt.*;
public class TestImage {
public static void main (String [] args) {
Frame f = new Frame();
f.show();
try {
f.setIconImage(null);
System.out.println("Set image to: '"+f.getIconImage()+"'");
} catch (NullPointerException npe) {
npe.printStackTrace();
} finally {
f.dispose();
}
}
}
------ Output solaris
3,~/tmp;
/set/java/jdk1.4/solaris/bin/java TestImage
java.lang.NullPointerException
at sun.awt.motif.MFramePeer.setIconImage(MFramePeer.java:98)
at java.awt.Frame.setIconImage(Frame.java:539)
at TestImage.main(TestImage.java:11)
3,~/tmp;
------ Output windows
Z:\tmp>C:\jdk1.4\bin\java.exe TestImage
Set image to: 'null'
Z:\tmp>
------
======================================================================
Changing the category of this bug to 'specification'. In both Basis and Personal, an implementation may prohibit iconification. In such a case, attempts to iconify the Frame will fail silently.
Hence, the spec should not enforce that getIconImage() will return a default icon image for the iconified frame once setIconImage(null) has been called.
###@###.### 2002-02-08
======================================================================
In fact, even in J2SE iconification doesn't have to work:
"Not all platforms support the concept of minimizing a window."
I believe that once setIconImage(null) has been called, getIconImage()
must return null. This is implied by the spec for getIconImage, but
setIconImage is contradicting.
In that sense, JDK 1.4 Windows implementation, as well as PBP implementation,
is perfectly reasonable.
Changing this to a spec bug in J2SE. Please see suggested fix.
###@###.### 2002-02-08
=====================================================================
This is companion bug for JDK bug: 4633887
PBP behaviour for this test:
--------- PBP output
~/bin/pp/pbptest TestImage
Set image to: 'null'
,~;
---------
Methods:
Frame.setIconImage incorrectly and
inconsistently handles null as parameter.
JDK1.4 spec states:
------------------
public Image getIconImage()
Gets the image to be displayed in the minimized icon for this frame.
Returns:
the icon image for this frame, or null if this frame doesn't have an icon image.
...
public void setIconImage(Image image)
Sets the image to be displayed in the minimized icon for this frame. Not
all platforms support the concept of minimizing a window.
Parameters:
image - the icon image to be displayed. If this parameter is null then the
icon image is set to the default image, which may vary with platform.
--------------------------------------------------------------------------------
According to this, setIconImage should accept null without
Exception and getIconImage() should return !null after
setIconImage(null) call. Behaviour of JDK1.4 is inconsistent
between solaris/windows and getIconImage() may return null
after setIconImage(null) call. Please, see the test example,
demonstrating this behaviour:
------ TestImage.java
import java.awt.*;
public class TestImage {
public static void main (String [] args) {
Frame f = new Frame();
f.show();
try {
f.setIconImage(null);
System.out.println("Set image to: '"+f.getIconImage()+"'");
} catch (NullPointerException npe) {
npe.printStackTrace();
} finally {
f.dispose();
}
}
}
------ Output solaris
3,~/tmp;
/set/java/jdk1.4/solaris/bin/java TestImage
java.lang.NullPointerException
at sun.awt.motif.MFramePeer.setIconImage(MFramePeer.java:98)
at java.awt.Frame.setIconImage(Frame.java:539)
at TestImage.main(TestImage.java:11)
3,~/tmp;
------ Output windows
Z:\tmp>C:\jdk1.4\bin\java.exe TestImage
Set image to: 'null'
Z:\tmp>
------
======================================================================
Changing the category of this bug to 'specification'. In both Basis and Personal, an implementation may prohibit iconification. In such a case, attempts to iconify the Frame will fail silently.
Hence, the spec should not enforce that getIconImage() will return a default icon image for the iconified frame once setIconImage(null) has been called.
###@###.### 2002-02-08
======================================================================
In fact, even in J2SE iconification doesn't have to work:
"Not all platforms support the concept of minimizing a window."
I believe that once setIconImage(null) has been called, getIconImage()
must return null. This is implied by the spec for getIconImage, but
setIconImage is contradicting.
In that sense, JDK 1.4 Windows implementation, as well as PBP implementation,
is perfectly reasonable.
Changing this to a spec bug in J2SE. Please see suggested fix.
###@###.### 2002-02-08
=====================================================================
- duplicates
-
JDK-6339074 Improve icon support
- Resolved
- relates to
-
JDK-4633887 Frame.setIconImage(null) - inconsistent behaviour
- Closed