Index: api/src/org/netbeans/api/debugger/jpda/JPDADebugger.java =================================================================== RCS file: /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/JPDADebugger.java,v retrieving revision 1.18 diff -u -r1.18 JPDADebugger.java --- api/src/org/netbeans/api/debugger/jpda/JPDADebugger.java 12 Aug 2005 12:45:10 -0000 1.18 +++ api/src/org/netbeans/api/debugger/jpda/JPDADebugger.java 21 Oct 2005 12:46:30 -0000 @@ -322,6 +322,17 @@ * @return true if this debugger supports Pop action */ public abstract boolean canPopFrames (); + + /** + * Determines if the target debuggee can be modified. + * + * @return true if the target debuggee can be modified or when + * this information is not available (on JDK 1.4). + * @since 2.3 + */ + public boolean canBeModified() { + return true; + } /** * Implements fix & continue (HotSwap). Map should contain class names Index: api/manifest.mf =================================================================== RCS file: /cvs/debuggerjpda/api/manifest.mf,v retrieving revision 1.13 diff -u -r1.13 manifest.mf --- api/manifest.mf 24 Sep 2005 00:37:04 -0000 1.13 +++ api/manifest.mf 21 Oct 2005 12:46:30 -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.2 +OpenIDE-Module-Specification-Version: 2.3 OpenIDE-Module-Package-Dependencies: com.sun.jdi[VirtualMachineManager] Index: api/apichanges.xml =================================================================== RCS file: /cvs/debuggerjpda/api/apichanges.xml,v retrieving revision 1.11 diff -u -r1.11 apichanges.xml --- api/apichanges.xml 18 Aug 2005 14:46:09 -0000 1.11 +++ api/apichanges.xml 21 Oct 2005 12:46:31 -0000 @@ -348,6 +348,23 @@ + + + Added canBeModified() method to JPDADebugger class + + + + + +

+ A possibility to detect whether the debuggee is read-only is added. + This check works fine on JDK 1.5 and higher, on JDK 1.4 it returns + true by default. +

+
+ + +
Index: arch.xml =================================================================== RCS file: /cvs/debuggerjpda/arch.xml,v retrieving revision 1.1 diff -u -r1.1 arch.xml --- arch.xml 17 May 2004 11:42:15 -0000 1.1 +++ arch.xml 21 Oct 2005 12:46:32 -0000 @@ -126,7 +126,7 @@ --> - Needs at least JRE 1.3. + Needs at least JRE 1.4. @@ -138,7 +138,7 @@ --> - Need JDK (dt.jar). + Need JDK (dt.jar, tools.jar). @@ -578,7 +578,9 @@ --> - No. + VirtualMachine.canBeModified(), TypeComponent.genericSignature() and + LocalVariable.genericSignature() are called by reflection, because it's + available on JDK 1.5 and higher only. Index: src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java =================================================================== RCS file: /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java,v retrieving revision 1.86 diff -u -r1.86 JPDADebuggerImpl.java --- src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java 17 Oct 2005 09:28:13 -0000 1.86 +++ src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java 18 Oct 2005 13:07:46 -0000 @@ -313,6 +313,33 @@ } } + + private Boolean canBeModified; + private Object canBeModifiedLock = new Object(); + + public boolean canBeModified() { + VirtualMachine vm = getVirtualMachine (); + if (vm == null) return false; + synchronized (canBeModifiedLock) { + if (canBeModified == null) { + try { + java.lang.reflect.Method canBeModifiedMethod = + com.sun.jdi.VirtualMachine.class.getMethod("canBeModified", new Class[] {}); + Object modifiable = canBeModifiedMethod.invoke(vm, new Object[] {}); + canBeModified = (Boolean) modifiable; + } catch (NoSuchMethodException nsmex) { + // On JDK 1.4 we do not know... we suppose that can + canBeModified = Boolean.TRUE; + } catch (IllegalAccessException iaex) { + canBeModified = Boolean.TRUE; + } catch (InvocationTargetException itex) { + canBeModified = Boolean.TRUE; + } + } + return canBeModified.booleanValue(); + } + // return vm.canBeModified(); -- After we'll build on JDK 1.5 + } private SmartSteppingFilter smartSteppingFilter; @@ -640,6 +667,9 @@ JPDAUtils.printFeatures (vm); } virtualMachine = vm; + synchronized (canBeModifiedLock) { + canBeModified = null; // Reset the can be modified flag + } initGenericsSupport ();