Details
-
Bug
-
Resolution: Fixed
-
P3
-
5.0, 6
-
b62
-
generic, x86, sparc
-
generic, linux_suse_sles_8, solaris_8
-
Verified
Description
While running Java2Demo using java -jar Java2Demo.jar -runs=1, I got the following NullPointerException:
java.lang.NullPointerException
at java.awt.Dimension.<init>(Dimension.java:91)
at java.awt.Component.getMaximumSize(Component.java:2321)
at java.awt.Container.getMaximumSize(Container.java:1648)
at javax.swing.JComponent.getMaximumSize(JComponent.java:1564)
at javax.swing.BoxLayout.checkRequests(BoxLayout.java:435)
at javax.swing.BoxLayout.layoutContainer(BoxLayout.java:375)
at javax.swing.JToolBar$DefaultToolBarLayout.layoutContainer(JToolBar.java:786)
at java.awt.Container.layout(Container.java:1424)
at java.awt.Container.doLayout(Container.java:1414)
at java.awt.Container.validateTree(Container.java:1496)
at java.awt.Container.validateTree(Container.java:1503)
at java.awt.Container.validateTree(Container.java:1503)
at java.awt.Container.validateTree(Container.java:1503)
at java.awt.Container.validateTree(Container.java:1503)
at java.awt.Container.validateTree(Container.java:1503)
at java.awt.Container.validate(Container.java:1471)
at java2d.DemoGroup.setup(DemoGroup.java:257)
at java2d.GlobalPanel.stateChanged(GlobalPanel.java:102)
at javax.swing.JTabbedPane.fireStateChanged(JTabbedPane.java:283)
at javax.swing.JTabbedPane$ModelListener.stateChanged(JTabbedPane.java:215)
at javax.swing.DefaultSingleSelectionModel.fireStateChanged(DefaultSingleSelectionModel.java:116)
at javax.swing.DefaultSingleSelectionModel.setSelectedIndex(DefaultSingleSelectionModel.java:50)
at javax.swing.JTabbedPane.setSelectedIndexImpl(JTabbedPane.java:471)
at javax.swing.JTabbedPane.setSelectedIndex(JTabbedPane.java:457)
at java2d.RunWindow.run(RunWindow.java:219)
at java.lang.Thread.run(Thread.java:567)
Looking through the sources for Component.getMaximumSize I noticed that the flag maxSizeSet protects the usage of the field maxSize. The public method setMaximumSize has the following code for setting these 2 values.
this.maxSize = maximumSize;
maxSizeSet = (maximumSize != null);
However the invalidate method does this:
if (!isMaximumSizeSet()) {
maxSize = null;
}
If these are executed interleaved you can end up with maxSizeSet to true but maxSize set to null. This would result in the NPE I saw above. I can't reproduce it though. By inspection there's clearly a problem though.
###@###.### 2003-12-09
java.lang.NullPointerException
at java.awt.Dimension.<init>(Dimension.java:91)
at java.awt.Component.getMaximumSize(Component.java:2321)
at java.awt.Container.getMaximumSize(Container.java:1648)
at javax.swing.JComponent.getMaximumSize(JComponent.java:1564)
at javax.swing.BoxLayout.checkRequests(BoxLayout.java:435)
at javax.swing.BoxLayout.layoutContainer(BoxLayout.java:375)
at javax.swing.JToolBar$DefaultToolBarLayout.layoutContainer(JToolBar.java:786)
at java.awt.Container.layout(Container.java:1424)
at java.awt.Container.doLayout(Container.java:1414)
at java.awt.Container.validateTree(Container.java:1496)
at java.awt.Container.validateTree(Container.java:1503)
at java.awt.Container.validateTree(Container.java:1503)
at java.awt.Container.validateTree(Container.java:1503)
at java.awt.Container.validateTree(Container.java:1503)
at java.awt.Container.validateTree(Container.java:1503)
at java.awt.Container.validate(Container.java:1471)
at java2d.DemoGroup.setup(DemoGroup.java:257)
at java2d.GlobalPanel.stateChanged(GlobalPanel.java:102)
at javax.swing.JTabbedPane.fireStateChanged(JTabbedPane.java:283)
at javax.swing.JTabbedPane$ModelListener.stateChanged(JTabbedPane.java:215)
at javax.swing.DefaultSingleSelectionModel.fireStateChanged(DefaultSingleSelectionModel.java:116)
at javax.swing.DefaultSingleSelectionModel.setSelectedIndex(DefaultSingleSelectionModel.java:50)
at javax.swing.JTabbedPane.setSelectedIndexImpl(JTabbedPane.java:471)
at javax.swing.JTabbedPane.setSelectedIndex(JTabbedPane.java:457)
at java2d.RunWindow.run(RunWindow.java:219)
at java.lang.Thread.run(Thread.java:567)
Looking through the sources for Component.getMaximumSize I noticed that the flag maxSizeSet protects the usage of the field maxSize. The public method setMaximumSize has the following code for setting these 2 values.
this.maxSize = maximumSize;
maxSizeSet = (maximumSize != null);
However the invalidate method does this:
if (!isMaximumSizeSet()) {
maxSize = null;
}
If these are executed interleaved you can end up with maxSizeSet to true but maxSize set to null. This would result in the NPE I saw above. I can't reproduce it though. By inspection there's clearly a problem though.
###@###.### 2003-12-09
Attachments
Issue Links
- duplicates
-
JDK-4988063 SLES8: Java2D demo threw exceptions when using linux-i586
- Closed
-
JDK-6202916 java2demo BAT test fails intermittently when X server is Xvfb
- Closed