United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6826104 Getting a NullPointer exception when clicked on Application & Toolkit Modal dialog
JDK-6826104 : Getting a NullPointer exception when clicked on Application & Toolkit Modal dialog

Details
Type:
Bug
Submit Date:
2009-04-03
Status:
Closed
Updated Date:
2011-03-07
Project Name:
JDK
Resolved Date:
2011-03-07
Component:
client-libs
OS:
solaris,solaris_10
Sub-Component:
java.awt
CPU:
sparc
Priority:
P2
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

Description
When i click on a Application or Toolkit Modal dialog with the parent, i am getting NullPointer Exception in jdk7 b55 pit build. It works fine in jdk7 b51 promoted build. 

Step to reproduce :-
----------------------
1) Run the attached program.
java -jar ToplevelFactory.jar
2) Select Dialog , Owner is visible, Modality type is either Applicatin_Modal or Toolkit modal. & click on "Show toplevel" button. 
3) Click on the dialog, Observe that exception is thrown on console. If you see the same then the bug is reproduced. 


bash-3.00# /net/sqindia.india/export/disk05/awt/karen/pit7b55/solaris-sparc/bin/java -jar ToplevelFactory.jar
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at sun.awt.X11.XWindowPeer.restoreTransientFor(XWindowPeer.java:1666)
        at sun.awt.X11.XWindowPeer.removeFromTransientFors(XWindowPeer.java:1732)
        at sun.awt.X11.XWindowPeer.setModalBlocked(XWindowPeer.java:1454)
        at sun.awt.X11.XWindowPeer.setModalBlocked(XWindowPeer.java:1428)
        at java.awt.Window.setModalBlocked(Window.java:1411)
        at java.awt.Dialog.unblockWindow(Dialog.java:1597)
        at java.awt.Dialog.modalHide(Dialog.java:1483)
        at java.awt.Dialog.hideAndDisposePreHandler(Dialog.java:1215)
        at java.awt.Dialog.hide(Dialog.java:1255)
        at java.awt.Window$1DisposeAction.run(Window.java:1097)
        at java.awt.Window.doDispose(Window.java:1111)
        at java.awt.Dialog.doDispose(Dialog.java:1273)
        at java.awt.Window.dispose(Window.java:1058)
        at toplevelfactory.ControlFrame.showToplevelButtonActionPerformed(ControlFrame.java:518)
        at toplevelfactory.ControlFrame.access$500(ControlFrame.java:41)
        at toplevelfactory.ControlFrame$14.mousePressed(ControlFrame.java:618)
        at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:280)
        at java.awt.Component.processMouseEvent(Component.java:6257)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3309)
        at java.awt.Component.processEvent(Componena:4258)
        at java.awt.Container.dispatchEventImpl(Container.java:2127)
        at java.awt.Window.dispatchEventImpl(Window.java:2609)
        at java.awt.Component.dispatchEvent(Component.java:4446)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:605)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:286)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:195)
        at java.awt.Dialog$1.run(Dialog.java:1072)
        at java.awt.Dialog$3.run(Dialog.java:1126)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.awt.Dialog.show(Dialog.java:1124)
        at java.awt.Component.show(Component.java:1525)
        at java.awt.Component.setVisible(Component.java:1477)
        at java.awt.Window.setVisible(Window.java:925)
        at java.awt.Dialog.setVisible(Dialog.java:1011)
        at toplevelfactory.CoultButtonModel.setPressed(DefaultButtonModel.java:259)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:253)
        at java.awt.Component.processMouseEvent(Component.java:6260)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3309)
        at java.awt.Component.processEvent(Component.java:6025)
        at java.awt.Container.processEvent(Container.java:2083)
        at java.awt.Component.dispatchEventImpl(Component.java:4620)
        at java.awt.Container.dispatchEventImpl(Container.java:2141)
        at java.awt.Component.dispatchEvent(Component.java:4446)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4665)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4328)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4258)
        at java.awt.Container.dispatchEventImpl(Container.java:2127)
        at java.awt.Window.dispatchEventImpl(Window.java:2609)
        at java.awt.Compos(EventDispatchThread.java:178)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:139)

                                    

Comments
EVALUATION

The problem isn't specific to Solaris 10 and easily reproducible on Linux as well.
                                     
2009-04-09
EVALUATION

It's a regression of the forward-port for 6693253 (Security Warning appearance requires enhancements) to JDK7.

Below are some diffs applied to the XWindowPeer class 

-         SunToolkit.awtLock();
-         try {
-             windows.add(this);
-             if (wm_protocols == null) {
-                 wm_protocols = XAtom.get("WM_PROTOCOLS");
-                 wm_delete_window = XAtom.get("WM_DELETE_WINDOW");
-                 wm_take_focus = XAtom.get("WM_TAKE_FOCUS");
-             }
-         }
-         finally {
-             SunToolkit.awtUnlock();
-         }

The fix removes the call to add() method on the windows instance by mistake. Reverting the change back helps to fix the problem.
                                     
2009-04-09
EVALUATION

The block of code mentioned above has been moved to XWindow isntead. However, the call to windows.add(this) was just mistakenly removed. It needs to be added back to the XWindowPeer.preInit() method.
                                     
2009-04-14
SUGGESTED FIX

--- old/src/solaris/classes/sun/awt/X11/XWindowPeer.java	2009-04-14 18:10:51.000000000 +0400
+++ new/src/solaris/classes/sun/awt/X11/XWindowPeer.java	2009-04-14 18:10:51.000000000 +0400
@@ -146,6 +146,13 @@
 
         params.put(OVERRIDE_REDIRECT, Boolean.valueOf(isOverrideRedirect()));
 
+        SunToolkit.awtLock();
+        try {
+            windows.add(this);
+        } finally {
+            SunToolkit.awtUnlock();
+        }
+
         cachedFocusableWindow = isFocusableWindow();
 
         Font f = target.getFont();
                                     
2009-04-17
PUBLIC COMMENTS

Just FYI, there are duplicate reports of this bug from NetBeans users:
http://www.netbeans.org/issues/show_bug.cgi?id=163548
                                     
2009-05-11



Hardware and Software, Engineered to Work Together