JDK-4633887 : Frame.setIconImage(null) - inconsistent behaviour
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.5
  • CPU: sparc
  • Submitted: 2002-02-06
  • Updated: 2004-12-30
  • Resolved: 2004-12-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2 mantisFixed
Related Reports
Relates :  
Description

Name: apR10100			Date: 02/06/2002



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>
------

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

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis mantis-b02 FIXED IN: mantis mantis-b02 INTEGRATED IN: mantis mantis-b02
01-07-2004

SUGGESTED FIX Add a check for null in MFramePeer.java ###@###.### 2002-02-11 *************** *** 87,93 **** int width; int height; GraphicsConfiguration defaultGC; ! if (im instanceof X11Image) { ImageRepresentation ir = ((X11Image)im).getImageRep(); ir.reconstruct(ImageObserver.ALLBITS); --- 87,93 ---- int width; int height; GraphicsConfiguration defaultGC; ! if (im != null) { // 4633887 Avoid Null pointer exception. if (im instanceof X11Image) { ImageRepresentation ir = ((X11Image)im).getImageRep(); ir.reconstruct(ImageObserver.ALLBITS); *************** *** 166,171 **** --- 166,172 ---- pSetIconImage(bytedata, intdata, ushortdata, iconWidth, iconHeight); } + } } native boolean pGetIconSize(int widthHint, int heightHint); ###@###.### 2002-06-10
10-06-2002

EVALUATION Fix in Mantis ###@###.### 2002-02-11 The Motif version need to be fixed to check for null image. ###@###.### 2002-06-10
11-02-2002