-
Bug
-
Resolution: Fixed
-
P3
-
9, 11, 12
-
b17
-
x86_64
-
windows_10
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8226469 | 11.0.5-oracle | Sergey Bylokhov | P3 | Resolved | Fixed | b02 |
JDK-8229806 | 11.0.4.0.1-oracle | Sergey Bylokhov | P3 | Resolved | Fixed | master |
JDK-8220558 | 11.0.4-oracle | Sergey Bylokhov | P3 | Resolved | Fixed | b01 |
JDK-8220756 | 11.0.4 | Sergey Bylokhov | P3 | Resolved | Fixed | b01 |
JDK-8221953 | 11.0.3-oracle | Sergey Bylokhov | P3 | Closed | Fixed | b31 |
A DESCRIPTION OF THE PROBLEM :
In case I create a JSpinner add a PropertyChangeListener and then call setFont(null) it results in a NullPointerException. It looks like the bug was introduced in Java 9 with the fix:
https://bugs.openjdk.java.net/browse/JDK-5036022
Instead of passing the font it has been wrapped in a FontUIResource first, but the FontUIResource does not allow null font.
tf.setFont(new FontUIResource(spinner.getFont()));
The line should be:
tf.setFont(spinner. getFont() == null ? null : new FontUIResource(spinner.getFont()));
REGRESSION : Last worked in version 8u172
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a JSpinner
Add a PropertyChangeListener
Call setFont(null)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
NullPointerException should not be thrown
ACTUAL -
Exception in thread "main" java.lang.NullPointerException
at java.desktop/java.awt.Font.<init>(Font.java:712)
at java.desktop/javax.swing.plaf.FontUIResource.<init>(FontUIResource.java:68)
at java.desktop/javax.swing.plaf.basic.BasicSpinnerUI$Handler.propertyChange(BasicSpinnerUI.java:1020)
at java.desktop/java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:341)
at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:266)
at java.desktop/java.awt.Component.firePropertyChange(Component.java:8728)
at java.desktop/java.awt.Component.setFont(Component.java:1946)
at java.desktop/java.awt.Container.setFont(Container.java:1777)
at java.desktop/javax.swing.JComponent.setFont(JComponent.java:2769)
at JSpinnerTest.main(JSpinnerTest.java:14)
---------- BEGIN SOURCE ----------
import javax.swing.JSpinner;
public class JSpinnerTest {
public static void main(String[] args) {
JSpinner spinner = new JSpinner();
spinner.addPropertyChangeListener(evt -> {});
spinner.setFont(null);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
We could avoid this bug by not calling the setFont with null, but unfortunately, it is in an external library, so we cannot change.
FREQUENCY : always
In case I create a JSpinner add a PropertyChangeListener and then call setFont(null) it results in a NullPointerException. It looks like the bug was introduced in Java 9 with the fix:
https://bugs.openjdk.java.net/browse/JDK-5036022
Instead of passing the font it has been wrapped in a FontUIResource first, but the FontUIResource does not allow null font.
tf.setFont(new FontUIResource(spinner.getFont()));
The line should be:
tf.setFont(spinner. getFont() == null ? null : new FontUIResource(spinner.getFont()));
REGRESSION : Last worked in version 8u172
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a JSpinner
Add a PropertyChangeListener
Call setFont(null)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
NullPointerException should not be thrown
ACTUAL -
Exception in thread "main" java.lang.NullPointerException
at java.desktop/java.awt.Font.<init>(Font.java:712)
at java.desktop/javax.swing.plaf.FontUIResource.<init>(FontUIResource.java:68)
at java.desktop/javax.swing.plaf.basic.BasicSpinnerUI$Handler.propertyChange(BasicSpinnerUI.java:1020)
at java.desktop/java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:341)
at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:266)
at java.desktop/java.awt.Component.firePropertyChange(Component.java:8728)
at java.desktop/java.awt.Component.setFont(Component.java:1946)
at java.desktop/java.awt.Container.setFont(Container.java:1777)
at java.desktop/javax.swing.JComponent.setFont(JComponent.java:2769)
at JSpinnerTest.main(JSpinnerTest.java:14)
---------- BEGIN SOURCE ----------
import javax.swing.JSpinner;
public class JSpinnerTest {
public static void main(String[] args) {
JSpinner spinner = new JSpinner();
spinner.addPropertyChangeListener(evt -> {});
spinner.setFont(null);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
We could avoid this bug by not calling the setFont with null, but unfortunately, it is in an external library, so we cannot change.
FREQUENCY : always
- backported by
-
JDK-8220558 Calling JSpinner's setFont with null throws NullPointerException
-
- Resolved
-
-
JDK-8220756 Calling JSpinner's setFont with null throws NullPointerException
-
- Resolved
-
-
JDK-8226469 Calling JSpinner's setFont with null throws NullPointerException
-
- Resolved
-
-
JDK-8229806 Calling JSpinner's setFont with null throws NullPointerException
-
- Resolved
-
-
JDK-8221953 Calling JSpinner's setFont with null throws NullPointerException
-
- Closed
-
- links to
(1 links to)