-
CSR
-
Resolution: Approved
-
P4
-
None
-
behavioral
-
low
-
-
Java API
-
SE
Summary
Specify that javax.swing.JInternalFrame.setDesktopIcon(JDesktopIcon) will throw NullPointerException when passed a null object reference for the parameter.
Problem
Method setDesktopIcon(JDesktopIcon) of the javax.swing.JInternalFrame class ia allowing null to be specified for JDesktopIcon object. This leads to random exceptions later on when getDesktopIcon.setVisible(), getDeskopIcon.getParent() etc are called since null is not supposed to be a valid value.
Solution
Update the implementation to throw NullPointerException if null is passed to setDesktopIcon() and document this as part of the specification. Further note that subclassers - which have direct access to the protected field holding the JDesktopIcon - should not set it to null.
Specification
Update public class javax.swing.JInternalFrame as follows :
/** * Sets the <code>JDesktopIcon</code> associated with this * <code>JInternalFrame</code>. * * @param d the <code>JDesktopIcon</code> to display on the desktop + * @throws NullPointerException if the {@code d} is {@code null} * @see #getDesktopIcon */ public void setDesktopIcon(JDesktopIcon d); /** * The icon that is displayed when this internal frame is iconified. + * Subclassers must ensure this is set to a non-null value + * during construction and not subsequently set this to null. * @see #iconable */ protected JDesktopIcon desktopIcon;
- csr of
-
JDK-5015261 NPE may be thrown if JDesktopIcon is set to null on a JInternalFrame
-
- Resolved
-