Index: debuggercore/viewmodel/src/org/netbeans/modules/viewmodel/TreeTable.java =================================================================== RCS file: /cvs/debuggercore/viewmodel/src/org/netbeans/modules/viewmodel/TreeTable.java,v retrieving revision 1.15 diff -u -r1.15 TreeTable.java --- debuggercore/viewmodel/src/org/netbeans/modules/viewmodel/TreeTable.java 27 Mar 2005 12:03:40 -0000 1.15 +++ debuggercore/viewmodel/src/org/netbeans/modules/viewmodel/TreeTable.java 27 Apr 2005 15:14:37 -0000 @@ -125,29 +125,39 @@ // 5) set root node for given model currentTreeModelRoot = new TreeModelRoot (model, this); - getExplorerManager ().setRootContext ( - currentTreeModelRoot.getRootNode () - ); + TreeModelNode.getRequestProcessor ().post (new Runnable () { + public void run () { + getExplorerManager ().setRootContext ( + currentTreeModelRoot.getRootNode () + ); + } + }); // 6) update column widths & expanded nodes updateColumnWidths (); treeTable.expandNodes (expandedPaths); // TODO: this is a workaround, we should find a better way later final List backupPath = new ArrayList (expandedPaths); - SwingUtilities.invokeLater (new Runnable () { - public void run () { - if (backupPath.size () == 0) + if (backupPath.size () == 0) + TreeModelNode.getRequestProcessor ().post (new Runnable () { + public void run () { try { - expandDefault ( - TreeTable.this.model.getChildren - (TreeTable.this.model.getRoot (), 0, 0)); - } catch (UnknownTypeException ex) { - - } - else + final Object[] ch = TreeTable.this.model.getChildren + (TreeTable.this.model.getRoot (), 0, 0); + SwingUtilities.invokeLater (new Runnable () { + public void run () { + expandDefault (ch); + } + }); + } catch (UnknownTypeException ex) {} + } + }); + else + SwingUtilities.invokeLater (new Runnable () { + public void run () { treeTable.expandNodes (backupPath); - } - }); + } + }); if (ep.size () > 0) expandedPaths = ep; } @@ -308,7 +318,7 @@ public void expandNode (Object node) { Node n = currentTreeModelRoot.findNode (node); - if (treeTable != null) + if (treeTable != null && n != null) treeTable.expandNode (n); } Index: debuggerjpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java =================================================================== RCS file: /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java,v retrieving revision 1.64.2.2 diff -u -r1.64.2.2 JPDADebuggerImpl.java --- debuggerjpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java 15 Apr 2005 08:39:49 -0000 1.64.2.2 +++ debuggerjpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java 27 Apr 2005 15:14:38 -0000 @@ -82,7 +82,6 @@ import org.netbeans.spi.viewmodel.TreeModel; import org.netbeans.spi.viewmodel.UnknownTypeException; -import org.openide.util.RequestProcessor; /** @@ -90,7 +89,7 @@ * * @author Jan Jancura */ -public class JPDADebuggerImpl extends JPDADebugger implements Runnable { +public class JPDADebuggerImpl extends JPDADebugger { private static final boolean startVerbose = System.getProperty ("netbeans.debugger.start") != null; @@ -577,7 +576,6 @@ public void setStarting (Thread startingThread) { this.startingThread = startingThread; setState (STATE_STARTING); - RequestProcessor.getDefault ().post (this, 200); } public void setRunning (VirtualMachine vm, Operator o) { @@ -693,6 +691,7 @@ * @see com.sun.jdi.ThreadReference#suspend */ public void suspend () { + if (getState () == STATE_STOPPED) return; synchronized (LOCK) { if (virtualMachine != null) virtualMachine.suspend (); @@ -713,6 +712,7 @@ * Used by ContinueActionProvider & StepActionProvider. */ public void resume () { + if (getState () == STATE_RUNNING) return; synchronized (LOCK) { if (virtualMachine != null) virtualMachine.resume (); @@ -763,7 +763,7 @@ } } - private void setState (int state) { + public void setState (int state) { if (state == this.state) return; int o = this.state; this.state = state; @@ -874,19 +874,6 @@ } catch (InvalidRequestStateException ex) { // workaround for #51176 } - } - - public void run () { - if (getState () == JPDADebugger.STATE_DISCONNECTED) - return; - JPDAThreadImpl t = (JPDAThreadImpl) getCurrentThread (); - if (t != null) { - if ( t.getThreadReference ().isSuspended () && - getState () == STATE_RUNNING - ) - setState (STATE_STOPPED); - } - RequestProcessor.getDefault ().post (this, 200); } private void checkJSR45Languages (JPDAThread t) { Index: debuggerjpda/src/org/netbeans/modules/debugger/jpda/actions/ContinueActionProvider.java =================================================================== RCS file: /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/actions/ContinueActionProvider.java,v retrieving revision 1.3.38.1 diff -u -r1.3.38.1 ContinueActionProvider.java --- debuggerjpda/src/org/netbeans/modules/debugger/jpda/actions/ContinueActionProvider.java 14 Apr 2005 09:03:16 -0000 1.3.38.1 +++ debuggerjpda/src/org/netbeans/modules/debugger/jpda/actions/ContinueActionProvider.java 27 Apr 2005 15:14:38 -0000 @@ -19,6 +19,7 @@ import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Set; import org.netbeans.api.debugger.ActionsManager; @@ -38,12 +39,18 @@ public class ContinueActionProvider extends JPDADebuggerActionProvider implements Runnable { - public ContinueActionProvider (ContextProvider lookupProvider) { + private boolean j2meDebugger = false; + + + public ContinueActionProvider (ContextProvider contextProvider) { super ( - (JPDADebuggerImpl) lookupProvider.lookupFirst + (JPDADebuggerImpl) contextProvider.lookupFirst (null, JPDADebugger.class) ); - RequestProcessor.getDefault ().post (this, 200); + Map properties = (Map) contextProvider.lookupFirst (null, Map.class); + if (properties != null) + j2meDebugger = properties.containsKey ("J2ME_DEBUGGER"); + RequestProcessor.getDefault ().post (this, 500); } public Set getActions () { @@ -51,10 +58,22 @@ } public void doAction (Object action) { - getDebuggerImpl ().resume (); + // getDebuggerImpl ().resume () does not work if debugger + // is already suspended + VirtualMachine vm = getDebuggerImpl ().getVirtualMachine (); + if (vm == null) return; + vm.resume (); + getDebuggerImpl ().setState (JPDADebugger.STATE_RUNNING); } protected void checkEnabled (int debuggerState) { + if (j2meDebugger) { + setEnabled ( + ActionsManager.ACTION_CONTINUE, + debuggerState == JPDADebugger.STATE_STOPPED + ); + return; + } VirtualMachine vm = getDebuggerImpl ().getVirtualMachine (); if (vm == null) { setEnabled ( @@ -88,6 +107,6 @@ if (getDebuggerImpl ().getState () == JPDADebugger.STATE_DISCONNECTED) return; checkEnabled (getDebuggerImpl ().getState ()); - RequestProcessor.getDefault ().post (this, 200); + RequestProcessor.getDefault ().post (this, 500); } } Index: debuggerjpda/src/org/netbeans/modules/debugger/jpda/actions/PauseActionProvider.java =================================================================== RCS file: /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/actions/PauseActionProvider.java,v retrieving revision 1.3.38.1 diff -u -r1.3.38.1 PauseActionProvider.java --- debuggerjpda/src/org/netbeans/modules/debugger/jpda/actions/PauseActionProvider.java 14 Apr 2005 09:03:16 -0000 1.3.38.1 +++ debuggerjpda/src/org/netbeans/modules/debugger/jpda/actions/PauseActionProvider.java 27 Apr 2005 15:14:38 -0000 @@ -18,6 +18,7 @@ import com.sun.jdi.VirtualMachine; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Set; import org.netbeans.api.debugger.ActionsManager; @@ -38,12 +39,18 @@ public class PauseActionProvider extends JPDADebuggerActionProvider implements Runnable { - public PauseActionProvider (ContextProvider lookupProvider) { + private boolean j2meDebugger = false; + + + public PauseActionProvider (ContextProvider contextProvider) { super ( - (JPDADebuggerImpl) lookupProvider.lookupFirst + (JPDADebuggerImpl) contextProvider.lookupFirst (null, JPDADebugger.class) ); - RequestProcessor.getDefault ().post (this, 200); + Map properties = (Map) contextProvider.lookupFirst (null, Map.class); + if (properties != null) + j2meDebugger = properties.containsKey ("J2ME_DEBUGGER"); + RequestProcessor.getDefault ().post (this, 500); } public Set getActions () { @@ -51,10 +58,22 @@ } public void doAction (Object action) { - ((JPDADebuggerImpl) getDebuggerImpl ()).suspend (); + // getDebuggerImpl ().suspend () does not work if debugger + // is already suspended + VirtualMachine vm = getDebuggerImpl ().getVirtualMachine (); + if (vm == null) return; + vm.suspend (); + getDebuggerImpl ().setState (JPDADebugger.STATE_STOPPED); } protected void checkEnabled (int debuggerState) { + if (j2meDebugger) { + setEnabled ( + ActionsManager.ACTION_PAUSE, + debuggerState == JPDADebugger.STATE_RUNNING + ); + return; + } VirtualMachine vm = getDebuggerImpl ().getVirtualMachine (); if (vm == null) { setEnabled ( @@ -88,6 +107,6 @@ if (getDebuggerImpl ().getState () == JPDADebugger.STATE_DISCONNECTED) return; checkEnabled (getDebuggerImpl ().getState ()); - RequestProcessor.getDefault ().post (this, 200); + RequestProcessor.getDefault ().post (this, 500); } } Index: debuggerjpda/src/org/netbeans/modules/debugger/jpda/expr/Evaluator.java =================================================================== RCS file: /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/expr/Evaluator.java,v retrieving revision 1.14 diff -u -r1.14 Evaluator.java --- debuggerjpda/src/org/netbeans/modules/debugger/jpda/expr/Evaluator.java 25 Feb 2005 15:43:13 -0000 1.14 +++ debuggerjpda/src/org/netbeans/modules/debugger/jpda/expr/Evaluator.java 27 Apr 2005 15:14:39 -0000 @@ -799,17 +799,18 @@ Evaluator.class, "CTL_UnsupportedOperationException" )); - return method.instanceContext.invokeMethod(frameThread, method.method, method.args, - ObjectReference.INVOKE_SINGLE_THREADED | ObjectReference.INVOKE_NONVIRTUAL); - } catch (InvalidTypeException e) { + return invokeVirtual ( + method.instanceContext, + method.method, + frameThread, + method.args, + ObjectReference.INVOKE_SINGLE_THREADED | + ObjectReference.INVOKE_NONVIRTUAL + ); + } catch (InvalidExpressionException e) { Assert.error(node, "callException", e, ctx); - } catch (ClassNotLoadedException e) { - // TODO: load the class - Assert.error(node, "callException", e, ctx); - } catch (IncompatibleThreadStateException e) { + } catch (TimeoutException e) { Assert.error(node, "callException", e, ctx); - } catch (InvocationException e) { - Assert.error(node, "calleeException", e, ctx); } finally { try { @@ -836,8 +837,18 @@ Evaluator.class, "CTL_UnsupportedOperationException" )); - return classContext.invokeMethod(frameThread, method.method, method.args, ClassType.INVOKE_SINGLE_THREADED); + return invokeVirtual ( + classContext, + method.method, + frameThread, + method.args, + ClassType.INVOKE_SINGLE_THREADED + ); } + } catch (TimeoutException e) { + Assert.error(node, "callException", e, ctx); + } catch (InvalidExpressionException e) { + Assert.error(node, "callException", e, ctx); } catch (InvalidTypeException e) { Assert.error(node, "callException", e, ctx); } catch (ClassNotLoadedException e) { @@ -1173,7 +1184,13 @@ Evaluator.class, "CTL_UnsupportedOperationException" )); - return (PrimitiveValue) reference.invokeMethod(frameThread, toCall, new ArrayList(0), ObjectReference.INVOKE_SINGLE_THREADED); + return (PrimitiveValue) invokeVirtual ( + reference, + toCall, + frameThread, + new ArrayList(0), + ObjectReference.INVOKE_SINGLE_THREADED + ); } catch (Exception e) { // this should never happen, indicates an internal error throw new RuntimeException("Unexpected exception while invoking unboxing method", e); @@ -1534,10 +1551,26 @@ static int INVOKE_TIMEOUT_MILLIS = 700; public static Value invokeVirtual ( - ObjectReference objectReference, - Method method, + Object objectReference, + Method method, + ThreadReference evaluationThread, + List args + ) throws TimeoutException, InvalidExpressionException { + return invokeVirtual ( + objectReference, + method, + evaluationThread, + args, + ObjectReference.INVOKE_SINGLE_THREADED + ); + } + + public static Value invokeVirtual ( + Object objectReference, + Method method, ThreadReference evaluationThread, - List args + List args, + int options ) throws TimeoutException, InvalidExpressionException { EvaluationThread evalThread = new EvaluationThread ( @@ -1545,7 +1578,7 @@ evaluationThread, method, args, - ObjectReference.INVOKE_SINGLE_THREADED + options ); synchronized (evalThread) { evalThread.start(); @@ -1554,7 +1587,7 @@ } catch (InterruptedException e) { } if (!evalThread.isFinished ()) { - evalThread.stop(); // we cannot gracefully finish the thread, it's stuck in JDI + evalThread.stop (); // we cannot gracefully finish the thread, it's stuck in JDI throw new TimeoutException (); } if (evalThread.getException () != null) @@ -1568,7 +1601,7 @@ private static class EvaluationThread extends Thread { - private ObjectReference obj; + private Object obj; private ThreadReference evaluationThread; private Method method; private List args; @@ -1578,7 +1611,13 @@ private Value value; private Throwable exception; - public EvaluationThread(ObjectReference obj, ThreadReference evaluationThread, Method method, List args, int options) { + public EvaluationThread ( + Object obj, + ThreadReference evaluationThread, + Method method, + List args, + int options + ) { super("EvalThread"); this.obj = obj; this.evaluationThread = evaluationThread; @@ -1594,7 +1633,12 @@ Evaluator.class, "CTL_UnsupportedOperationException" )); - value = obj.invokeMethod(evaluationThread, method, args, options); + if (obj instanceof ClassType) + value = ((ClassType) obj).invokeMethod + (evaluationThread, method, args, options); + else + value = ((ObjectReference) obj).invokeMethod + (evaluationThread, method, args, options); } catch (ThreadDeath e) { return; // killed by the caller, no need to notify } catch (Throwable e) {