-
Bug
-
Resolution: Fixed
-
P2
-
7
-
b04
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2212678 | 7u2 | Denis Fokin | P2 | Resolved | Fixed | b06 |
Method java.awt.Toolkit.addPropertyChangeListener() says:
/**
...
* If {@code name} is {@code null} or {@code pcl} is {@code null},
* no exception is thrown and no action is performed.
...
*/
public void addPropertyChangeListener(String name, PropertyChangeListener pcl)
The assertion about null name is not satisfied by Windows/XToolkits.
The following code sample:
--------------------------------------------------------------------------------------------------
import java.awt.*;
import java.beans.*;
public class AddPCL_NPE {
public static void main(String[] args) {
Toolkit.getDefaultToolkit().addPropertyChangeListener(null, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) { }
});
}
}
--------------------------------------------------------------------------------------------------
will produce output like:
Exception in thread "main" java.lang.NullPointerException
at sun.awt.windows.WDesktopProperties.isWindowsProperty(WDesktopProperties.java:77)
at sun.awt.windows.WToolkit.addPropertyChangeListener(WToolkit.java:882)
or
java.lang.NullPointerException
at sun.awt.X11.XToolkit.initXSettingsIfNeeded(XToolkit.java:1546)
at sun.awt.X11.XToolkit.addPropertyChangeListener(XToolkit.java:1535)
/**
...
* If {@code name} is {@code null} or {@code pcl} is {@code null},
* no exception is thrown and no action is performed.
...
*/
public void addPropertyChangeListener(String name, PropertyChangeListener pcl)
The assertion about null name is not satisfied by Windows/XToolkits.
The following code sample:
--------------------------------------------------------------------------------------------------
import java.awt.*;
import java.beans.*;
public class AddPCL_NPE {
public static void main(String[] args) {
Toolkit.getDefaultToolkit().addPropertyChangeListener(null, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) { }
});
}
}
--------------------------------------------------------------------------------------------------
will produce output like:
Exception in thread "main" java.lang.NullPointerException
at sun.awt.windows.WDesktopProperties.isWindowsProperty(WDesktopProperties.java:77)
at sun.awt.windows.WToolkit.addPropertyChangeListener(WToolkit.java:882)
or
java.lang.NullPointerException
at sun.awt.X11.XToolkit.initXSettingsIfNeeded(XToolkit.java:1546)
at sun.awt.X11.XToolkit.addPropertyChangeListener(XToolkit.java:1535)
- backported by
-
JDK-2212678 Toolkit.addPropertyChangeListener(name, pcl) throws NPE for null name
-
- Resolved
-
- relates to
-
JDK-7020922 java.awt.Toolkit.getPropertyChangeListeners() should mention that it returns proxies
-
- Closed
-