JDK-5088782 : AWT application does not load : throws NPE
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2_05
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-08-18
  • Updated: 2012-10-09
  • Resolved: 2004-09-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6Fixed
Related Reports
Relates :  
Description
AWT application which adds lot of awt components to a panel,
which inturn is added to a Frame, throws an exception when
the number of components increases.

For simulating the problem, see the comments part.

1.4.2_04,1.4.2_05 gives the following exception :
Exception in thread "main" java.lang.NullPointerException: disposed component
       at sun.awt.windows.Win32SurfaceData.initOps(Native Method)
       at sun.awt.windows.Win32SurfaceData.<init>(Unknown Source)
       at sun.awt.windows.Win32SurfaceData.createData(Unknown Source)
       at sun.awt.windows.WComponentPeer.<init>(Unknown Source)
       at sun.awt.windows.WLabelPeer.<init>(Unknown Source)
       at sun.awt.windows.WToolkit.createLabel(Unknown Source)
       at java.awt.Label.addNotify(Unknown Source)
       at java.awt.Container.addNotify(Unknown Source)
       at java.awt.Panel.addNotify(Unknown Source)
       at java.awt.Container.addNotify(Unknown Source)
       at java.awt.Panel.addNotify(Unknown Source)
       at java.awt.Container.addNotify(Unknown Source)
       at java.awt.Window.addNotify(Unknown Source)
       at java.awt.Frame.addNotify(Unknown Source)
       at java.awt.Window.pack(Unknown Source)
       at Grid.main(Grid.java:27)
       1.5.2-beta2 :
the application hangs with the following stack trace:

----------------Stack Trace  Begins here ---------------------------------------
Full thread dump Java HotSpot(TM) Client VM (1.5.0-beta2-b51 mixed mode, sharing
):

"AWT-EventQueue-0" prio=7 tid=0x009fd5e0 nid=0x7b8 waiting for monitor entry [0x
0398f000..0x0398fbe4]
       at sun.awt.windows.WComponentPeer.replaceSurfaceData(Unknown Source)
       - waiting to lock <0x22fb1a48> (a java.awt.Component$AWTTreeLock)
       at sun.awt.windows.WComponentPeer.replaceSurfaceData(Unknown Source)
       at sun.awt.windows.WComponentPeer$2.run(Unknown Source)
       at java.awt.event.InvocationEvent.dispatch(Unknown Source)
       at java.awt.EventQueue.dispatchEvent(Unknown Source)
       at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

       at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
       at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
       at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
       at java.awt.EventDispatchThread.run(Unknown Source)

"AWT-Shutdown" prio=7 tid=0x009f9e20 nid=0xcc in Object.wait() [0x0388f000..0x03
88fc64]
       at java.lang.Object.wait(Native Method)
       at java.lang.Object.wait(Unknown Source)
       at sun.awt.AWTAutoShutdown.run(Unknown Source)
       - locked <0x22facef8> (a java.lang.Object)
       at java.lang.Thread.run(Unknown Source)

"AWT-Windows" daemon prio=7 tid=0x009fa1e8 nid=0x7bc runnable [0x0376f000..0x037
6fce4]
       at sun.awt.windows.WToolkit.eventLoop(Native Method)
       at sun.awt.windows.WToolkit.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)

"Java2D Disposer" daemon prio=10 tid=0x009f8d38 nid=0x678 in Object.wait() [0x03
56f000..0x0356f9e4]
       at java.lang.Object.wait(Native Method)
       - waiting on <0x22facf80> (a java.lang.ref.ReferenceQueue$Lock)
       at java.lang.ref.ReferenceQueue.remove(Unknown Source)
       - locked <0x22facf80> (a java.lang.ref.ReferenceQueue$Lock)
       at java.lang.ref.ReferenceQueue.remove(Unknown Source)
       at sun.java2d.Disposer.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)

"Low Memory Detector" daemon prio=5 tid=0x0099bd38 nid=0x330 runnable [0x0000000
0..0x00000000]

"CompilerThread0" daemon prio=10 tid=0x0099a850 nid=0x714 waiting on condition [
0x00000000..0x0303f8bc]

"Signal Dispatcher" daemon prio=10 tid=0x00999b10 nid=0x128 waiting on condition
[0x00000000..0x00000000]

"Finalizer" daemon prio=9 tid=0x0023eea8 nid=0x600 in Object.wait() [0x02e3f000.
.0x02e3fc64]
       at java.lang.Object.wait(Native Method)
       - waiting on <0x22fad128> (a java.lang.ref.ReferenceQueue$Lock)
       at java.lang.ref.ReferenceQueue.remove(Unknown Source)
       - locked <0x22fad128> (a java.lang.ref.ReferenceQueue$Lock)
       at java.lang.ref.ReferenceQueue.remove(Unknown Source)
       at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

"Reference Handler" daemon prio=10 tid=0x009979a0 nid=0x44c in Object.wait() [0x
02d3f000..0x02d3fce4]
       at java.lang.Object.wait(Native Method)
       at java.lang.Object.wait(Unknown Source)
       at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
       - locked <0x22fad1a8> (a java.lang.ref.Reference$Lock)

"main" prio=5 tid=0x00236030 nid=0x63c runnable [0x0006f000..0x0006fc3c]
       at sun.awt.windows.WPanelPeer.pRestack(Native Method)
       at sun.awt.windows.WPanelPeer.restack(Unknown Source)
       at java.awt.Component.addNotify(Unknown Source)
       - locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)
       at java.awt.Container.addNotify(Unknown Source)
       - locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)
       at java.awt.Panel.addNotify(Unknown Source)
       - locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)
       at java.awt.Container.addNotify(Unknown Source)
       - locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)
       at java.awt.Panel.addNotify(Unknown Source)
       - locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)
       at java.awt.Container.addNotify(Unknown Source)
       - locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)
       at java.awt.Window.addNotify(Unknown Source)
       - locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)
       at java.awt.Frame.addNotify(Unknown Source)
       - locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)
       at java.awt.Window.show(Unknown Source)
       at java.awt.Component.show(Unknown Source)
       at java.awt.Component.setVisible(Unknown Source)
       at Grid.main(Grid.java:24)

"VM Thread" prio=10 tid=0x00976100 nid=0x628 runnable

"VM Periodic Task Thread" prio=10 tid=0x0099d2c0 nid=0x6f0 waiting on condition

--------------------------Stack Trace Ends------------------------------------

Justification: Customer has migrated their product to use Sun JVM from Microsoft JVM.
        With their new release, end users of the customer are unable to see the         application. This accounts to a total failure of a feature         they used to support with Microsoft JVM.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.2_07 1.5.0_01 mustang FIXED IN: 1.5.0_01 mustang INTEGRATED IN: 1.5.0_01
28-09-2004

EVALUATION The problem is trivial out of memory error. When we create a window object for a heavyweight component we just store its handle in hwnd field but don't check it is 0. In the test we create many window handles so at some moment system refuses creating more window objects. We should check return value of CreateWindow() and if it is 0 throw OutOfMemoryError (if GetLastError() corresponds to out of memory) or InternalError (otherwise). ###@###.### 2004-08-19
19-08-2004

WORK AROUND Possible workaround can be: don't use so many heavyweight components. If you really do need such amount of components you should use lightweights (for example, Swing) ###@###.### 2004-08-19
19-08-2004