Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 133092 - NPE from sun.awt.windows.WComponentPeer.nativeHandleEvent on JDK 1.5
NPE from sun.awt.windows.WComponentPeer.nativeHandleEvent on JDK 1.5
Status: VERIFIED FIXED
Product: platform
Classification: Unclassified
Component: Text
6.x
PC Windows XP
: P2 (vote)
: 6.x
Assigned To: mslama
issues@platform
jdk_bug_6704417 65fixes2-verified
: JDK_SPECIFIC
: 135592 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-04-17 11:53 UTC by snelson
Modified: 2009-02-19 22:53 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description snelson 2008-04-17 11:53:57 UTC
SteveNB wrote:
 
 Hello Folks,
 
 Well it my first posting and I usually don't post problems unless I've
 reached my wits end. So here's what I am trying to accomplish. Hopefully,
 I can example it properly.
 
 1. I have a DataNode Object which has the following assignments.
 
 getCookieSet().assign(PaletteSupportProvider.class, new
 PaletteSupport().createPalette());
 getCookieSet().assign(EditorCookie.class);
 getCookieSet().assign(OpenCookie.class);
 getCookieSet().assign(EditCookie.class);
 getCookieSet().assign(ViewCookie.class);
 getCookieSet().assign(LineCookie.class);
 getCookieSet().assign(CloseCookie.class);
 getCookieSet().assign(PrintCookie.class);
 getCookieSet().assign(SaveCookie.class);
 
 CookieSet cookies = getCookieSet();
 cookies.add((Node.Cookie) DataEditorSupport.create(this,
 getPrimaryEntry(), cookies));
 
 2. I have an action which the following:
 
 FileObject fileobject =
 FileUtil.toFileObject(FileUtil.normalizeFile(openfile));
 DataObject dob = DataObject.find(fileobject);                       
 EditorCookie ec = (EditorCookie) dob.getCookie(EditorCookie.class);
 if ( ec != null ) {
    ec.open();
 }
 
 This work great. However, when I try to print the content of the
 EditorCookie Pane (using the native PrintAction instance), I get the
 following:
 
 java.lang.IllegalArgumentException
 	at org.openide.text.DefaultPrintable.<init>(DefaultPrintable.java:135)
 	at org.openide.text.DefaultPrintable.<init>(DefaultPrintable.java:169)
 	at org.openide.text.NbDocument.findPageable(NbDocument.java:443)
 	at org.openide.text.CloneableEditorSupport.print(CloneableEditorSupport.java:1011)
 	at org.openide.actions.PrintAction.performAction(PrintAction.java:70)
 	at org.openide.util.actions.NodeAction.performAction(NodeAction.java:289)
 	at org.openide.util.actions.CallableSystemAction$1.run(CallableSystemAction.java:118)
 	at org.netbeans.modules.openide.util.ActionsBridge$ActionRunnable.actionPerformed(ActionsBridge.java:111)
 	at org.netbeans.core.ModuleActions.invokeAction(ModuleActions.java:104)
 	at org.netbeans.modules.openide.actions.ActionsBridgeImpl.invokeAction(ActionsBridgeImpl.java:52)
 	at org.netbeans.modules.openide.util.ActionsBridge$ActionRunnable.doRun(ActionsBridge.java:102)
 	at org.netbeans.modules.openide.util.ActionsBridge$1.run(ActionsBridge.java:71)
 	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561)
 [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986)
 
 
 I have looked all over creation, but nothing. If anyone has an idea what I
 am doing wrong, I would be most appreciative. Using JDK 1.5.0_12-b02.
 
 Regards,
 Steve Nelson
 
 
 --- Interesting Note --- 
 
 I am using JDK 1.5.0_14-b03 at home and I get:
 
 java.lang.NullPointerException: null pData
         at sun.awt.windows.WComponentPeer.nativeHandleEvent(Native Method)
         at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:262)
         at java.awt.Component.dispatchEventImpl(Component.java:4060)
         at java.awt.Container.dispatchEventImpl(Container.java:2024)
         at java.awt.Window.dispatchEventImpl(Window.java:1791)
         at java.awt.Component.dispatchEvent(Component.java:3819)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
 [catch] at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
         at java.awt.Dialog$1.run(Dialog.java:535)
         at java.awt.Dialog$2.run(Dialog.java:565)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.awt.Dialog.show(Dialog.java:563)
         at sun.awt.windows.WPrinterJob.displayNativeDialog(WPrinterJob.java:473)
         at sun.awt.windows.WPrinterJob.printDialog(WPrinterJob.java:553)
         at org.openide.text.CloneableEditorSupport.print(CloneableEditorSupport.java:1020)
         at com.cca.model204module.PrintFileAction.performAction(PrintFileAction.java:34)
         at org.openide.util.actions.NodeAction.performAction(NodeAction.java:289)
         at org.openide.util.actions.CallableSystemAction$1.run(CallableSystemAction.java:118)
         at org.netbeans.modules.openide.util.ActionsBridge.doPerformAction(ActionsBridge.java:77)
         at org.openide.util.actions.CallableSystemAction.actionPerformed(CallableSystemAction.java:114)
         at org.openide.util.actions.NodeAction.actionPerformed(NodeAction.java:277)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
         at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
         at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1051)
         at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1092)
         at java.awt.Component.processMouseEvent(Component.java:5517)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
         at java.awt.Component.processEvent(Component.java:5282)
         at java.awt.Container.processEvent(Container.java:1966)
         at java.awt.Component.dispatchEventImpl(Component.java:3984)
         at java.awt.Container.dispatchEventImpl(Container.java:2024)
         at java.awt.Component.dispatchEvent(Component.java:3819)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
         at java.awt.Container.dispatchEventImpl(Container.java:2010)
         at java.awt.Window.dispatchEventImpl(Window.java:1791)
         at java.awt.Component.dispatchEvent(Component.java:3819)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


-- Interesting Note --

I've install JDK 1.6.0_06-b02 the method works fine!
Comment 1 mslama 2008-04-24 10:40:24 UTC
Please could you attach test module (or send it to me) to reproduce issue?
Comment 2 mslama 2008-05-19 16:10:47 UTC
I filed #6704417 against JDK/AWT for NPE on Windows when opening PageSetup dialog. It happens on JDK 5.0u15 (latest
released update). In any case it is JDK issue both on Linux/Windows. Closing as WONTFIX. I will update status of issue
on Windows.
Comment 3 Lukas Hasik 2008-05-22 12:29:40 UTC
*** Issue 135592 has been marked as a duplicate of this issue. ***
Comment 4 pzajac 2008-12-12 09:47:59 UTC
I found 32 duplicates:

http://statistics.netbeans.org/exceptions/detail.do?id=13423

This excetpion is too confusing for our users. We had to patch platform:

o.n.core/src/org/netbeans/core/NotifyExcPanel.java

static void notify (
        final NbErrorManager.Exc t
    )

...
     // error in jdk during printing
       if ("java.lang.NullPointerException".equals(t.getClassName())) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            t.printStackTrace(pw);
            if (sw.toString().contains("sun.awt.windows.WComponentPeer.nativeHandleEvent")) {
                 t.printStackTrace(System.err);
                 return;
            }
       }
...

The patch is safe. Printing works correctly.
 
Comment 5 mslama 2008-12-12 10:01:20 UTC
Jarda is this patch ok?
Comment 6 mslama 2009-01-06 10:42:10 UTC
As it can happen any time even when there is no our code in call stack there is no better way. I added check for JDK
version and exception dialog is not shown on JDK 5 only. As said above it does not happen on JDK 6.

core-main #bb9e27ad5280

Because of special exception handling in java.awt.EventDispatchThread.pumpOneEventForHierarchy code is not interrupted.
It has no visible effect on functionality. It happens when native printing or page setup dialog is displayed. There is
no progress in JDK to fix this.
Comment 7 mslama 2009-01-06 11:04:36 UTC
There is generated event and NPE is thrown during its processing. Our code is on call stack because modal dialog is
displayed.
Comment 8 mslama 2009-01-06 11:07:19 UTC
Fix summary
Comment 9 Quality Engineering 2009-01-07 05:35:33 UTC
Integrated into 'main-golden', will be available in build *200901070201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/bb9e27ad5280
User: Marek Slama <mslama@netbeans.org>
Log: #133092: Do not show exception dialog when NPE from WComponentPeer.nativeHandleEvent is thrown on JDK 5.
Comment 10 Lukas Hasik 2009-01-09 15:36:11 UTC
snelson, could verify if the patch (or trunk) works for you?
Comment 11 Lukas Hasik 2009-01-13 09:24:33 UTC
I checked the code - in any way it seems safe -> verified
Comment 12 Lukas Hasik 2009-01-13 11:34:08 UTC
from snelson's email:
Hello,

Works as advertised..

Thank you,
Comment 13 pgebauer 2009-01-13 16:10:17 UTC
The fix has been ported into the release65_fixes repository.

http://hg.netbeans.org/release65_fixes/rev/1483a5591936


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo