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.

View | Details | Raw Unified | Return to bug 58365
Collapse All | Expand All

(-)debuggercore/viewmodel/src/org/netbeans/modules/viewmodel/TreeTable.java (-16 / +26 lines)
Lines 125-153 Link Here
125
        
125
        
126
        // 5) set root node for given model
126
        // 5) set root node for given model
127
        currentTreeModelRoot = new TreeModelRoot (model, this);
127
        currentTreeModelRoot = new TreeModelRoot (model, this);
128
        getExplorerManager ().setRootContext (
128
        TreeModelNode.getRequestProcessor ().post (new Runnable () {
129
            currentTreeModelRoot.getRootNode ()
129
            public void run () {
130
        );
130
                getExplorerManager ().setRootContext (
131
                    currentTreeModelRoot.getRootNode ()
132
                );
133
            }
134
        });
131
        
135
        
132
        // 6) update column widths & expanded nodes
136
        // 6) update column widths & expanded nodes
133
        updateColumnWidths ();
137
        updateColumnWidths ();
134
        treeTable.expandNodes (expandedPaths);
138
        treeTable.expandNodes (expandedPaths);
135
        // TODO: this is a workaround, we should find a better way later
139
        // TODO: this is a workaround, we should find a better way later
136
        final List backupPath = new ArrayList (expandedPaths);
140
        final List backupPath = new ArrayList (expandedPaths);
137
        SwingUtilities.invokeLater (new Runnable () {
141
        if (backupPath.size () == 0)
138
            public void run () {
142
            TreeModelNode.getRequestProcessor ().post (new Runnable () {
139
                if (backupPath.size () == 0)
143
                public void run () {
140
                    try {
144
                    try {
141
                        expandDefault (
145
                        final Object[] ch = TreeTable.this.model.getChildren 
142
                            TreeTable.this.model.getChildren 
146
                            (TreeTable.this.model.getRoot (), 0, 0);
143
                            (TreeTable.this.model.getRoot (), 0, 0));
147
                        SwingUtilities.invokeLater (new Runnable () {
144
                    } catch (UnknownTypeException ex) {
148
                            public void run () {
145
                        
149
                                expandDefault (ch);
146
                    }
150
                            }
147
                else
151
                        });
152
                    } catch (UnknownTypeException ex) {}
153
                }
154
            });
155
        else
156
            SwingUtilities.invokeLater (new Runnable () {
157
                public void run () {
148
                    treeTable.expandNodes (backupPath);
158
                    treeTable.expandNodes (backupPath);
149
            }
159
                }
150
        });
160
            });
151
        if (ep.size () > 0) expandedPaths = ep;
161
        if (ep.size () > 0) expandedPaths = ep;
152
    }
162
    }
153
    
163
    
Lines 308-314 Link Here
308
318
309
    public void expandNode (Object node) {
319
    public void expandNode (Object node) {
310
        Node n = currentTreeModelRoot.findNode (node);
320
        Node n = currentTreeModelRoot.findNode (node);
311
        if (treeTable != null)
321
        if (treeTable != null && n != null)
312
            treeTable.expandNode (n);
322
            treeTable.expandNode (n);
313
    }
323
    }
314
324
(-)debuggerjpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java (-17 / +4 lines)
Lines 82-88 Link Here
82
82
83
import org.netbeans.spi.viewmodel.TreeModel;
83
import org.netbeans.spi.viewmodel.TreeModel;
84
import org.netbeans.spi.viewmodel.UnknownTypeException;
84
import org.netbeans.spi.viewmodel.UnknownTypeException;
85
import org.openide.util.RequestProcessor;
86
85
87
86
88
/**
87
/**
Lines 90-96 Link Here
90
*
89
*
91
* @author   Jan Jancura
90
* @author   Jan Jancura
92
*/
91
*/
93
public class JPDADebuggerImpl extends JPDADebugger implements Runnable {
92
public class JPDADebuggerImpl extends JPDADebugger {
94
    
93
    
95
    private static final boolean startVerbose = 
94
    private static final boolean startVerbose = 
96
        System.getProperty ("netbeans.debugger.start") != null;
95
        System.getProperty ("netbeans.debugger.start") != null;
Lines 577-583 Link Here
577
    public void setStarting (Thread startingThread) {
576
    public void setStarting (Thread startingThread) {
578
        this.startingThread = startingThread;
577
        this.startingThread = startingThread;
579
        setState (STATE_STARTING);
578
        setState (STATE_STARTING);
580
        RequestProcessor.getDefault ().post (this, 200);
581
    }
579
    }
582
580
583
    public void setRunning (VirtualMachine vm, Operator o) {
581
    public void setRunning (VirtualMachine vm, Operator o) {
Lines 693-698 Link Here
693
     * @see  com.sun.jdi.ThreadReference#suspend
691
     * @see  com.sun.jdi.ThreadReference#suspend
694
     */
692
     */
695
    public void suspend () {
693
    public void suspend () {
694
        if (getState () == STATE_STOPPED) return;
696
        synchronized (LOCK) {
695
        synchronized (LOCK) {
697
            if (virtualMachine != null)
696
            if (virtualMachine != null)
698
                virtualMachine.suspend ();
697
                virtualMachine.suspend ();
Lines 713-718 Link Here
713
     * Used by ContinueActionProvider & StepActionProvider.
712
     * Used by ContinueActionProvider & StepActionProvider.
714
     */
713
     */
715
    public void resume () {
714
    public void resume () {
715
        if (getState () == STATE_RUNNING) return;
716
        synchronized (LOCK) {
716
        synchronized (LOCK) {
717
            if (virtualMachine != null)
717
            if (virtualMachine != null)
718
                virtualMachine.resume ();
718
                virtualMachine.resume ();
Lines 763-769 Link Here
763
        }
763
        }
764
    }
764
    }
765
    
765
    
766
    private void setState (int state) {
766
    public void setState (int state) {
767
        if (state == this.state) return;
767
        if (state == this.state) return;
768
        int o = this.state;
768
        int o = this.state;
769
        this.state = state;
769
        this.state = state;
Lines 874-892 Link Here
874
            } catch (InvalidRequestStateException ex) {
874
            } catch (InvalidRequestStateException ex) {
875
                // workaround for #51176
875
                // workaround for #51176
876
            }
876
            }
877
    }
878
    
879
    public void run () {
880
        if (getState () == JPDADebugger.STATE_DISCONNECTED)
881
            return;
882
        JPDAThreadImpl t = (JPDAThreadImpl) getCurrentThread ();
883
        if (t != null) {
884
            if ( t.getThreadReference ().isSuspended () &&
885
                 getState () == STATE_RUNNING
886
            )
887
                setState (STATE_STOPPED);
888
        }
889
        RequestProcessor.getDefault ().post (this, 200);
890
    }
877
    }
891
878
892
    private void checkJSR45Languages (JPDAThread t) {
879
    private void checkJSR45Languages (JPDAThread t) {
(-)debuggerjpda/src/org/netbeans/modules/debugger/jpda/actions/ContinueActionProvider.java (-5 / +24 lines)
Lines 19-24 Link Here
19
19
20
import java.util.Collections;
20
import java.util.Collections;
21
import java.util.List;
21
import java.util.List;
22
import java.util.Map;
22
import java.util.Set;
23
import java.util.Set;
23
import org.netbeans.api.debugger.ActionsManager;
24
import org.netbeans.api.debugger.ActionsManager;
24
25
Lines 38-49 Link Here
38
public class ContinueActionProvider extends JPDADebuggerActionProvider 
39
public class ContinueActionProvider extends JPDADebuggerActionProvider 
39
implements Runnable {
40
implements Runnable {
40
    
41
    
41
    public ContinueActionProvider (ContextProvider lookupProvider) {
42
    private boolean j2meDebugger = false;
43
    
44
    
45
    public ContinueActionProvider (ContextProvider contextProvider) {
42
        super (
46
        super (
43
            (JPDADebuggerImpl) lookupProvider.lookupFirst 
47
            (JPDADebuggerImpl) contextProvider.lookupFirst 
44
                (null, JPDADebugger.class)
48
                (null, JPDADebugger.class)
45
        );
49
        );
46
        RequestProcessor.getDefault ().post (this, 200);
50
        Map properties = (Map) contextProvider.lookupFirst (null, Map.class);
51
        if (properties != null)
52
            j2meDebugger = properties.containsKey ("J2ME_DEBUGGER");
53
        RequestProcessor.getDefault ().post (this, 500);
47
    }
54
    }
48
    
55
    
49
    public Set getActions () {
56
    public Set getActions () {
Lines 51-60 Link Here
51
    }
58
    }
52
    
59
    
53
    public void doAction (Object action) {
60
    public void doAction (Object action) {
54
        getDebuggerImpl ().resume ();
61
        // getDebuggerImpl ().resume () does not work if debugger 
62
        // is already suspended
63
        VirtualMachine vm = getDebuggerImpl ().getVirtualMachine ();
64
        if (vm == null) return;
65
        vm.resume ();
66
        getDebuggerImpl ().setState (JPDADebugger.STATE_RUNNING);
55
    }
67
    }
56
    
68
    
57
    protected void checkEnabled (int debuggerState) {
69
    protected void checkEnabled (int debuggerState) {
70
        if (j2meDebugger) {
71
            setEnabled (
72
                ActionsManager.ACTION_CONTINUE,
73
                debuggerState == JPDADebugger.STATE_STOPPED
74
            );
75
            return;
76
        }
58
        VirtualMachine vm = getDebuggerImpl ().getVirtualMachine ();
77
        VirtualMachine vm = getDebuggerImpl ().getVirtualMachine ();
59
        if (vm == null) {
78
        if (vm == null) {
60
            setEnabled (
79
            setEnabled (
Lines 88-93 Link Here
88
        if (getDebuggerImpl ().getState () == JPDADebugger.STATE_DISCONNECTED)
107
        if (getDebuggerImpl ().getState () == JPDADebugger.STATE_DISCONNECTED)
89
            return;
108
            return;
90
        checkEnabled (getDebuggerImpl ().getState ());
109
        checkEnabled (getDebuggerImpl ().getState ());
91
        RequestProcessor.getDefault ().post (this, 200);
110
        RequestProcessor.getDefault ().post (this, 500);
92
    }
111
    }
93
}
112
}
(-)debuggerjpda/src/org/netbeans/modules/debugger/jpda/actions/PauseActionProvider.java (-5 / +24 lines)
Lines 18-23 Link Here
18
import com.sun.jdi.VirtualMachine;
18
import com.sun.jdi.VirtualMachine;
19
import java.util.Collections;
19
import java.util.Collections;
20
import java.util.List;
20
import java.util.List;
21
import java.util.Map;
21
import java.util.Set;
22
import java.util.Set;
22
import org.netbeans.api.debugger.ActionsManager;
23
import org.netbeans.api.debugger.ActionsManager;
23
24
Lines 38-49 Link Here
38
public class PauseActionProvider extends JPDADebuggerActionProvider 
39
public class PauseActionProvider extends JPDADebuggerActionProvider 
39
implements Runnable {
40
implements Runnable {
40
    
41
    
41
    public PauseActionProvider (ContextProvider lookupProvider) {
42
    private boolean j2meDebugger = false;
43
    
44
    
45
    public PauseActionProvider (ContextProvider contextProvider) {
42
        super (
46
        super (
43
            (JPDADebuggerImpl) lookupProvider.lookupFirst 
47
            (JPDADebuggerImpl) contextProvider.lookupFirst 
44
                (null, JPDADebugger.class)
48
                (null, JPDADebugger.class)
45
        );
49
        );
46
        RequestProcessor.getDefault ().post (this, 200);
50
        Map properties = (Map) contextProvider.lookupFirst (null, Map.class);
51
        if (properties != null)
52
            j2meDebugger = properties.containsKey ("J2ME_DEBUGGER");
53
        RequestProcessor.getDefault ().post (this, 500);
47
    }
54
    }
48
    
55
    
49
    public Set getActions () {
56
    public Set getActions () {
Lines 51-60 Link Here
51
    }
58
    }
52
59
53
    public void doAction (Object action) {
60
    public void doAction (Object action) {
54
        ((JPDADebuggerImpl) getDebuggerImpl ()).suspend ();
61
        // getDebuggerImpl ().suspend () does not work if debugger 
62
        // is already suspended
63
        VirtualMachine vm = getDebuggerImpl ().getVirtualMachine ();
64
        if (vm == null) return;
65
        vm.suspend ();
66
        getDebuggerImpl ().setState (JPDADebugger.STATE_STOPPED);
55
    }
67
    }
56
    
68
    
57
    protected void checkEnabled (int debuggerState) {
69
    protected void checkEnabled (int debuggerState) {
70
        if (j2meDebugger) {
71
            setEnabled (
72
                ActionsManager.ACTION_PAUSE,
73
                debuggerState == JPDADebugger.STATE_RUNNING
74
            );
75
            return;
76
        }
58
        VirtualMachine vm = getDebuggerImpl ().getVirtualMachine ();
77
        VirtualMachine vm = getDebuggerImpl ().getVirtualMachine ();
59
        if (vm == null) {
78
        if (vm == null) {
60
            setEnabled (
79
            setEnabled (
Lines 88-93 Link Here
88
        if (getDebuggerImpl ().getState () == JPDADebugger.STATE_DISCONNECTED)
107
        if (getDebuggerImpl ().getState () == JPDADebugger.STATE_DISCONNECTED)
89
            return;
108
            return;
90
        checkEnabled (getDebuggerImpl ().getState ());
109
        checkEnabled (getDebuggerImpl ().getState ());
91
        RequestProcessor.getDefault ().post (this, 200);
110
        RequestProcessor.getDefault ().post (this, 500);
92
    }
111
    }
93
}
112
}
(-)debuggerjpda/src/org/netbeans/modules/debugger/jpda/expr/Evaluator.java (-19 / +63 lines)
Lines 799-815 Link Here
799
                        Evaluator.class, 
799
                        Evaluator.class, 
800
                        "CTL_UnsupportedOperationException"
800
                        "CTL_UnsupportedOperationException"
801
                    )); 
801
                    )); 
802
                return method.instanceContext.invokeMethod(frameThread, method.method, method.args,
802
                return invokeVirtual (
803
                                                        ObjectReference.INVOKE_SINGLE_THREADED | ObjectReference.INVOKE_NONVIRTUAL);
803
                    method.instanceContext, 
804
            } catch (InvalidTypeException e) {
804
                    method.method, 
805
                    frameThread, 
806
                    method.args,
807
                    ObjectReference.INVOKE_SINGLE_THREADED | 
808
                        ObjectReference.INVOKE_NONVIRTUAL
809
                );
810
            } catch (InvalidExpressionException e) {
805
                Assert.error(node, "callException", e, ctx);
811
                Assert.error(node, "callException", e, ctx);
806
            } catch (ClassNotLoadedException e) {
812
            } catch (TimeoutException e) {
807
                // TODO: load the class
808
                Assert.error(node, "callException", e, ctx);
809
            } catch (IncompatibleThreadStateException e) {
810
                Assert.error(node, "callException", e, ctx);
813
                Assert.error(node, "callException", e, ctx);
811
            } catch (InvocationException e) {
812
                Assert.error(node, "calleeException", e, ctx);
813
            }
814
            }
814
            finally {
815
            finally {
815
                try {
816
                try {
Lines 836-843 Link Here
836
                            Evaluator.class, 
837
                            Evaluator.class, 
837
                            "CTL_UnsupportedOperationException"
838
                            "CTL_UnsupportedOperationException"
838
                        )); 
839
                        )); 
839
                    return classContext.invokeMethod(frameThread, method.method, method.args, ClassType.INVOKE_SINGLE_THREADED);
840
                    return invokeVirtual (
841
                        classContext,
842
                        method.method, 
843
                        frameThread, 
844
                        method.args, 
845
                        ClassType.INVOKE_SINGLE_THREADED
846
                    );
840
                }
847
                }
848
            } catch (TimeoutException e) {
849
                Assert.error(node, "callException", e, ctx);
850
            } catch (InvalidExpressionException e) {
851
                Assert.error(node, "callException", e, ctx);
841
            } catch (InvalidTypeException e) {
852
            } catch (InvalidTypeException e) {
842
                Assert.error(node, "callException", e, ctx);
853
                Assert.error(node, "callException", e, ctx);
843
            } catch (ClassNotLoadedException e) {
854
            } catch (ClassNotLoadedException e) {
Lines 1173-1179 Link Here
1173
                    Evaluator.class, 
1184
                    Evaluator.class, 
1174
                    "CTL_UnsupportedOperationException"
1185
                    "CTL_UnsupportedOperationException"
1175
                )); 
1186
                )); 
1176
            return (PrimitiveValue) reference.invokeMethod(frameThread, toCall, new ArrayList(0), ObjectReference.INVOKE_SINGLE_THREADED);
1187
            return (PrimitiveValue) invokeVirtual (
1188
                reference, 
1189
                toCall, 
1190
                frameThread, 
1191
                new ArrayList(0), 
1192
                ObjectReference.INVOKE_SINGLE_THREADED
1193
            );
1177
        } catch (Exception e) {
1194
        } catch (Exception e) {
1178
            // this should never happen, indicates an internal error
1195
            // this should never happen, indicates an internal error
1179
            throw new RuntimeException("Unexpected exception while invoking unboxing method", e);
1196
            throw new RuntimeException("Unexpected exception while invoking unboxing method", e);
Lines 1534-1543 Link Here
1534
    static int INVOKE_TIMEOUT_MILLIS = 700;
1551
    static int INVOKE_TIMEOUT_MILLIS = 700;
1535
1552
1536
    public static Value invokeVirtual (
1553
    public static Value invokeVirtual (
1537
        ObjectReference objectReference, 
1554
        Object          objectReference, 
1538
        Method method, 
1555
        Method          method, 
1556
        ThreadReference evaluationThread, 
1557
        List            args
1558
    ) throws TimeoutException, InvalidExpressionException {
1559
        return invokeVirtual (
1560
            objectReference, 
1561
            method, 
1562
            evaluationThread, 
1563
            args, 
1564
            ObjectReference.INVOKE_SINGLE_THREADED
1565
        );
1566
    }
1567
1568
    public static Value invokeVirtual (
1569
        Object          objectReference, 
1570
        Method          method, 
1539
        ThreadReference evaluationThread, 
1571
        ThreadReference evaluationThread, 
1540
        List args
1572
        List            args,
1573
        int             options
1541
     ) throws TimeoutException, InvalidExpressionException {
1574
     ) throws TimeoutException, InvalidExpressionException {
1542
1575
1543
        EvaluationThread evalThread = new EvaluationThread (
1576
        EvaluationThread evalThread = new EvaluationThread (
Lines 1545-1551 Link Here
1545
            evaluationThread, 
1578
            evaluationThread, 
1546
            method, 
1579
            method, 
1547
            args, 
1580
            args, 
1548
            ObjectReference.INVOKE_SINGLE_THREADED
1581
            options
1549
        );
1582
        );
1550
        synchronized (evalThread) {
1583
        synchronized (evalThread) {
1551
            evalThread.start();
1584
            evalThread.start();
Lines 1554-1560 Link Here
1554
            } catch (InterruptedException e) {
1587
            } catch (InterruptedException e) {
1555
            }
1588
            }
1556
            if (!evalThread.isFinished ()) {
1589
            if (!evalThread.isFinished ()) {
1557
                evalThread.stop();  // we cannot gracefully finish the thread, it's stuck in JDI
1590
                evalThread.stop ();  // we cannot gracefully finish the thread, it's stuck in JDI
1558
                throw new TimeoutException ();
1591
                throw new TimeoutException ();
1559
            }
1592
            }
1560
            if (evalThread.getException () != null)
1593
            if (evalThread.getException () != null)
Lines 1568-1574 Link Here
1568
1601
1569
    private static class EvaluationThread extends Thread {
1602
    private static class EvaluationThread extends Thread {
1570
1603
1571
        private ObjectReference obj;
1604
        private Object          obj;
1572
        private ThreadReference evaluationThread;
1605
        private ThreadReference evaluationThread;
1573
        private Method          method;
1606
        private Method          method;
1574
        private List            args;
1607
        private List            args;
Lines 1578-1584 Link Here
1578
        private Value       value;
1611
        private Value       value;
1579
        private Throwable   exception;
1612
        private Throwable   exception;
1580
1613
1581
        public EvaluationThread(ObjectReference obj, ThreadReference evaluationThread, Method method, List args, int options) {
1614
        public EvaluationThread (
1615
                Object          obj, 
1616
                ThreadReference evaluationThread, 
1617
                Method          method, 
1618
                List            args, 
1619
                int             options
1620
        ) {
1582
            super("EvalThread");
1621
            super("EvalThread");
1583
            this.obj = obj;
1622
            this.obj = obj;
1584
            this.evaluationThread = evaluationThread;
1623
            this.evaluationThread = evaluationThread;
Lines 1594-1600 Link Here
1594
                        Evaluator.class, 
1633
                        Evaluator.class, 
1595
                        "CTL_UnsupportedOperationException"
1634
                        "CTL_UnsupportedOperationException"
1596
                    )); 
1635
                    )); 
1597
                value = obj.invokeMethod(evaluationThread, method, args, options);
1636
                if (obj instanceof ClassType)
1637
                    value = ((ClassType) obj).invokeMethod 
1638
                        (evaluationThread, method, args, options);
1639
                else
1640
                    value = ((ObjectReference) obj).invokeMethod 
1641
                        (evaluationThread, method, args, options);
1598
            } catch (ThreadDeath e) {
1642
            } catch (ThreadDeath e) {
1599
                return; // killed by the caller, no need to notify
1643
                return; // killed by the caller, no need to notify
1600
            } catch (Throwable e) {
1644
            } catch (Throwable e) {

Return to bug 58365