Skip to content

Commit 22ef4f0

Browse files
committed
5015261: NPE may be thrown if JDesktopIcon is set to null on a JInternalFrame
Reviewed-by: serb, prr, aivanov
1 parent 9bc0232 commit 22ef4f0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/java.desktop/share/classes/javax/swing/JInternalFrame.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ public class JInternalFrame extends JComponent implements
188188
protected String title;
189189
/**
190190
* The icon that is displayed when this internal frame is iconified.
191+
* Subclassers must ensure this is set to a non-null value
192+
* during construction and not subsequently set this to null.
191193
* @see #iconable
192194
*/
193195
protected JDesktopIcon desktopIcon;
@@ -1307,11 +1309,15 @@ public JDesktopPane getDesktopPane() {
13071309
* <code>JInternalFrame</code>.
13081310
*
13091311
* @param d the <code>JDesktopIcon</code> to display on the desktop
1312+
* @throws NullPointerException if the {@code d} is {@code null}
13101313
* @see #getDesktopIcon
13111314
*/
13121315
@BeanProperty(description
13131316
= "The icon shown when this internal frame is minimized.")
13141317
public void setDesktopIcon(JDesktopIcon d) {
1318+
if (d == null) {
1319+
throw new NullPointerException("JDesktopIcon is null");
1320+
}
13151321
JDesktopIcon oldValue = getDesktopIcon();
13161322
desktopIcon = d;
13171323
firePropertyChange("desktopIcon", oldValue, d);

0 commit comments

Comments
 (0)