? api/src/org/netbeans/api/debugger/jpda/ClassVariable.java ? api/src/org/netbeans/api/debugger/jpda/JPDAClassType.java ? api/src/org/netbeans/api/debugger/jpda/ReturnVariable.java Index: api/apichanges.xml =================================================================== RCS file: /cvs/debuggerjpda/api/apichanges.xml,v retrieving revision 1.14 diff -u -r1.14 apichanges.xml --- api/apichanges.xml 30 Jun 2006 19:04:45 -0000 1.14 +++ api/apichanges.xml 12 Jul 2006 19:03:39 -0000 @@ -388,6 +388,24 @@ + + + Added JPDAClassType, ClassVariable and ReturnVariable classes + + + + + +

+ In order to be able to provide static context information + and return value of methods, three new classes were added. +

+
+ + + + +
Index: api/manifest.mf =================================================================== RCS file: /cvs/debuggerjpda/api/manifest.mf,v retrieving revision 1.17 diff -u -r1.17 manifest.mf --- api/manifest.mf 12 May 2006 16:52:59 -0000 1.17 +++ api/manifest.mf 12 Jul 2006 19:03:39 -0000 @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.api.debugger.jpda/2 OpenIDE-Module-Localizing-Bundle: org/netbeans/api/debugger/jpda/Bundle.properties -OpenIDE-Module-Specification-Version: 2.6 +OpenIDE-Module-Specification-Version: 2.7 OpenIDE-Module-Package-Dependencies: com.sun.jdi[VirtualMachineManager] Index: api/nbproject/project.properties =================================================================== RCS file: /cvs/debuggerjpda/api/nbproject/project.properties,v retrieving revision 1.7 diff -u -r1.7 project.properties --- api/nbproject/project.properties 30 Jun 2006 19:04:46 -0000 1.7 +++ api/nbproject/project.properties 12 Jul 2006 19:03:39 -0000 @@ -17,6 +17,8 @@ is.autoload=true cp.extra=${tools.jar} +javac.compilerargs=-Xlint:unchecked +javac.source=1.5 javadoc.title=Debugger JPDA API javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml Index: test/unit/src/org/netbeans/api/debugger/jpda/MethodBreakpointTest.java =================================================================== RCS file: /cvs/debuggerjpda/test/unit/src/org/netbeans/api/debugger/jpda/MethodBreakpointTest.java,v retrieving revision 1.10 diff -u -r1.10 MethodBreakpointTest.java --- test/unit/src/org/netbeans/api/debugger/jpda/MethodBreakpointTest.java 12 Jul 2006 13:52:05 -0000 1.10 +++ test/unit/src/org/netbeans/api/debugger/jpda/MethodBreakpointTest.java 12 Jul 2006 19:03:39 -0000 @@ -42,7 +42,7 @@ super (s); } - public void testMethodBreakpoints() throws Exception { + public void testMethodEntryBreakpoints() throws Exception { try { MethodBreakpoint mb1 = MethodBreakpoint.create (CLASS_NAME, "a"); TestBreakpointListener tbl = new TestBreakpointListener @@ -157,6 +157,45 @@ } } + public void testMethodExitBreakpoints() throws Exception { + try { + MethodBreakpoint mb1 = MethodBreakpoint.create ( + CLASS_NAME + "$AbstractInner", "compute" + ); + mb1.setBreakpointType(MethodBreakpoint.TYPE_METHOD_EXIT); + TestBreakpointListener tbl = new TestBreakpointListener + ("compute", 118, 1, "1.0"); + mb1.addJPDABreakpointListener (tbl); + dm.addBreakpoint(mb1); + + MethodBreakpoint mb2 = MethodBreakpoint.create ( + CLASS_NAME + "$InterfaceInner", "getString" + ); + mb2.setBreakpointType(MethodBreakpoint.TYPE_METHOD_EXIT); + TestBreakpointListener tb2 = new TestBreakpointListener + ("getString", 123, 1, "\"Hello\""); + mb2.addJPDABreakpointListener (tb2); + dm.addBreakpoint(mb2); + + support = JPDASupport.attach (CLASS_NAME); + + for (;;) { + support.waitState (JPDADebugger.STATE_STOPPED); + if (support.getDebugger ().getState () == + JPDADebugger.STATE_DISCONNECTED + ) break; + support.doContinue (); + } + tbl.assertFailure (); + tb2.assertFailure (); + + dm.removeBreakpoint (mb1); + dm.removeBreakpoint (mb2); + } finally { + support.doFinish(); + } + } + private class TestBreakpointListener implements JPDABreakpointListener { private int hitCount; @@ -164,6 +203,7 @@ private String methodName; private int hitLine; private int expectedHitCount; + private String returnValue; public TestBreakpointListener ( String methodName, @@ -175,6 +215,16 @@ this.expectedHitCount = expectedHitCount; } + public TestBreakpointListener ( + String methodName, + int hitLine, + int expectedHitCount, + String returnValue + ) { + this(methodName, hitLine, expectedHitCount); + this.returnValue = returnValue; + } + public void breakpointReached(JPDABreakpointEvent event) { try { checkEvent(event); @@ -207,6 +257,20 @@ mb.getMethodName (), event.getThread ().getMethodName () ); + + if (returnValue != null && !System.getProperty("java.version").startsWith("1.5")) { + Variable retVar = event.getVariable(); + assertNotNull( + "Breakpoint event: The return value must not be null!", + retVar); + ReturnVariable returnVariable = (ReturnVariable) retVar; + assertEquals( + "Breakpoint event: Wrong method name hit", + methodName, returnVariable.methodName()); + assertEquals( + "Breakpoint event: Wrong return value", + returnValue, returnVariable.getValue()); + } hitCount++; } Index: test/unit/src/org/netbeans/api/debugger/jpda/testapps/MethodBreakpointApp.java =================================================================== RCS file: /cvs/debuggerjpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/MethodBreakpointApp.java,v retrieving revision 1.2 diff -u -r1.2 MethodBreakpointApp.java --- test/unit/src/org/netbeans/api/debugger/jpda/testapps/MethodBreakpointApp.java 30 Jun 2006 19:05:02 -0000 1.2 +++ test/unit/src/org/netbeans/api/debugger/jpda/testapps/MethodBreakpointApp.java 12 Jul 2006 19:03:39 -0000 @@ -32,8 +32,8 @@ sa.b(); sa.c(); new InnerStatic().getW(); + new ConcreteInner().compute(); new ConcreteInner().getString(); } - static { System.currentTimeMillis(); } @@ -97,6 +97,32 @@ public int getW() { return w; } + } + + private static abstract class AbstractInner { + + public abstract double compute(); + + } + + private static interface InterfaceInner { + + String getString(); + + } + + private static class ConcreteInner extends AbstractInner implements InterfaceInner { + + public double compute() { + double num = Math.PI/2; + return Math.round(Math.sin(num)*1000)/1000.0; + } + + public String getString() { + char[] chars = new char[] { 'H', 'e', 'l', 'l', 'o' }; + return new String(chars); + } + } }