This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 242194 - NPE if attach debugger
Summary: NPE if attach debugger
Status: CLOSED FIXED
Alias: None
Product: debugger
Classification: Unclassified
Component: Java (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords: 8.0_HR_FIX
Depends on:
Blocks:
 
Reported: 2014-02-21 13:06 UTC by dyury
Modified: 2014-02-27 11:31 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dyury 2014-02-21 13:06:15 UTC
Windows 7 x64 
ME SDK 8 build b49 
NetBeans 2014-02-14 

If I run application from emulator with checked Use a remote debugger 
sometimes I may get the following exception after attaching debugger in NetBeans: 

java.lang.NullPointerException 
at org.netbeans.modules.debugger.ui.views.debugging.ThreadsListener.getCurrentThreadsHistory(ThreadsListener.java:162) 
at org.netbeans.modules.debugger.ui.views.debugging.ThreadsHistoryAction.getThreads(ThreadsHistoryAction.java:189) 
at org.netbeans.modules.debugger.ui.actions.SetCurrentThreadFromHistoryAction$2.hierarchyChanged(SetCurrentThreadFromHistoryAction.java:104) 
at java.awt.Component.processHierarchyEvent(Unknown Source) 
at java.awt.Component.processEvent(Unknown Source) 
at java.awt.Container.processEvent(Unknown Source) 
at java.awt.Component.dispatchEventImpl(Unknown Source) 
at java.awt.Container.dispatchEventImpl(Unknown Source) 
at java.awt.Component.dispatchEvent(Unknown Source) 
at java.awt.Component.addNotify(Unknown Source) 
at java.awt.Container.addNotify(Unknown Source) 
at javax.swing.JComponent.addNotify(Unknown Source) 
at java.awt.Container.addNotify(Unknown Source) 
at javax.swing.JComponent.addNotify(Unknown Source) 
at java.awt.Container.addNotify(Unknown Source) 
at javax.swing.JComponent.addNotify(Unknown Source) 
at java.awt.Container.addImpl(Unknown Source) 
at javax.swing.JLayeredPane.addImpl(Unknown Source) 
at java.awt.Container.add(Unknown Source) 
at javax.swing.PopupFactory$LightWeightPopup.show(Unknown Source) 
at javax.swing.JPopupMenu.getPopup(Unknown Source) 
at javax.swing.JPopupMenu.setVisible(Unknown Source) 
at javax.swing.JPopupMenu.show(Unknown Source) 
at javax.swing.JMenu.setPopupMenuVisible(Unknown Source) 
at org.openide.awt.MenuBar$LazyMenu.setPopupMenuVisible(MenuBar.java:684) 
at javax.swing.JPopupMenu.menuSelectionChanged(Unknown Source) 
at javax.swing.MenuSelectionManager.setSelectedPath(Unknown Source) 
at javax.swing.plaf.basic.BasicMenuUI.appendPath(Unknown Source) 
at javax.swing.plaf.basic.BasicMenuUI.access$200(Unknown Source) 
at javax.swing.plaf.basic.BasicMenuUI$Handler.mousePressed(Unknown Source) 
at javax.swing.plaf.basic.BasicMenuUI$MouseInputHandler.mousePressed(Unknown Source) 
at java.awt.Component.processMouseEvent(Unknown Source) 
at javax.swing.JComponent.processMouseEvent(Unknown Source) 
at java.awt.Component.processEvent(Unknown Source) 
at java.awt.Container.processEvent(Unknown Source) 
at java.awt.Component.dispatchEventImpl(Unknown Source) 
at java.awt.Container.dispatchEventImpl(Unknown Source) 
at java.awt.Component.dispatchEvent(Unknown Source) 
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) 
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) 
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) 
at java.awt.Container.dispatchEventImpl(Unknown Source) 
at java.awt.Window.dispatchEventImpl(Unknown Source) 
at java.awt.Component.dispatchEvent(Unknown Source) 
at java.awt.EventQueue.dispatchEventImpl(Unknown Source) 
at java.awt.EventQueue.access$200(Unknown Source) 
at java.awt.EventQueue$3.run(Unknown Source) 
at java.awt.EventQueue$3.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) 
at java.awt.EventQueue$4.run(Unknown Source) 
at java.awt.EventQueue$4.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) 
at java.awt.EventQueue.dispatchEvent(Unknown Source) 
[catch] at agent.AgentEventQueue.dispatchEvent(AgentEventQueue.java:231) 
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
at java.awt.EventDispatchThread.pumpEventsForFilter(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)
Comment 1 Roman Svitanic 2014-02-21 14:44:47 UTC
I couldn't reproduce the issue on:

Product Version: NetBeans IDE Dev (Build 20140221-ba00cdff3ec7)
Java: 1.7.0_51; Java HotSpot(TM) 64-Bit Server VM 24.51-b03
Runtime: Java(TM) SE Runtime Environment 1.7.0_51-b13
(1.8.8 b 129 tried as well)
Java ME SDK b49

I was able to debug the project in both ways: "Debug" action for ME project and attaching the debugger to running emulator in debug mode.

Please download latest NetBeans dev build, clean your NB user directory and delete C:\Users\<YOUR USERNAME>\javame-sdk\8.0 folder (it will be recreated when emulator will start). Thanks.
Comment 2 dyury 2014-02-21 16:59:33 UTC
Try running application several times.
First time it is working OK.
But if you run it second or third time (not closing emulator), NetBeans throws an exception.
Comment 3 dyury 2014-02-21 17:01:57 UTC
Sorry, my environment:
Product Version: NetBeans IDE Dev (Build 201402210001)
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
Java ME SDK b49
Comment 4 dyury 2014-02-21 17:08:24 UTC
This is an IMlet I run:

package remote;

import javax.microedition.midlet.*;

public class IMlet extends MIDlet {
    public IMlet() {
    }
    
    public void startApp() {
        int max = Math.max(5, 6);
        System.out.println("max: " + max);
        
        for (int i = 0; i < 600; i++) { //5 mins
            sleep(500);
            System.out.println("i: " + i);
        }
        
        exit();
    }
    
    public void pauseApp() {
    }
    
    public void destroyApp(boolean unconditional) {
        notifyDestroyed();
    }

    private void exit() {
        destroyApp(true);
    }
    
    private void sleep(long delay) {
        try {
            Thread.sleep(delay);
        } catch (InterruptedException ex) {
            System.err.println(ex);
        }
    }
}
Comment 5 Roman Svitanic 2014-02-21 17:16:41 UTC
(In reply to dyury from comment #2)
> Try running application several times.
> First time it is working OK.
> But if you run it second or third time (not closing emulator), NetBeans
> throws an exception.

I tried 5 times in row and it worked. No exception. It could be also ME SDK issue, if it started to happen in the latest build.

If there would be bug in NB debugger, then it would probably in other projects/use cases as well.

Moreover if you attach debugger to emulator manually it is not handled by NetBeans Java ME plugins.
Comment 6 dyury 2014-02-24 15:02:12 UTC
Exception is happened inside of generic NB debugger UI, there is no any connection between this exception and MESDK code. 
It seems a synchronization issue in NB code.
Comment 7 Martin Entlicher 2014-02-24 15:24:29 UTC
It looks like a null thread can get into the currentThreadsHistory list.
Comment 8 Martin Entlicher 2014-02-24 16:55:12 UTC
Fixed by changeset:   272605:ee967e7e8154
http://hg.netbeans.org/core-main/rev/ee967e7e8154
Comment 9 Martin Entlicher 2014-02-24 18:12:19 UTC
Considering the triviality of the fix and annoyance of the bug, it's backported into release80 branch:
changeset:   281373:421432ea46ea
http://hg.netbeans.org/releases/rev/421432ea46ea
Comment 10 Quality Engineering 2014-02-25 01:37:08 UTC
Integrated into 'releases/release80', will be available in build *201402242200* or newer. Wait for official and publicly available build.

Changeset: http://hg.netbeans.org/releases/rev/421432ea46ea
User: mentlicher@netbeans.org
Log: #242194: Check the current thread for null.
(transplanted from ee967e7e81545e885c953428c88badb787471699)
Comment 11 Quality Engineering 2014-02-26 03:04:27 UTC
Integrated into 'main-silver', will be available in build *201402260001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/ee967e7e8154
User: mentlicher@netbeans.org
Log: #242194: Check the current thread for null.
Comment 12 dyury 2014-02-27 11:31:56 UTC
Verified in NetBeans 201402260001