Index: apichanges.xml =================================================================== RCS file: /cvs/debuggerjpda/api/apichanges.xml,v retrieving revision 1.19 diff -u -r1.19 apichanges.xml --- apichanges.xml 4 Apr 2007 12:52:46 -0000 1.19 +++ apichanges.xml 5 Apr 2007 07:35:24 -0000 @@ -489,6 +489,47 @@ + + + Support for heap walking. + + + + + +

+ In order to be able to provide heap walking functionality, + we need methods for retrieval of class instances and + back references. +

+

+ Added methods:
+ Field.getDeclaringClass(), + JPDAClassType.getClassLoader(), + JPDAClassType.getSuperClass(), + JPDAClassType.getInstanceCount(), + JPDAClassType.getInstances(), + JPDADebugger.canGetInstanceInfo(), + JPDADebugger.getAllClasses(), + JPDADebugger.getClassesByName(), + JPDADebugger.getInstanceCounts(), + ObjectVariable.getReferringObjects(), + ObjectVariable.getClassType(), + ObjectVariable.getUniqueID(). +

+

+ Added classes:
+ VariableType, + JPDAArrayType. +

+
+ + + + + + +
Index: manifest.mf =================================================================== RCS file: /cvs/debuggerjpda/api/manifest.mf,v retrieving revision 1.21 diff -u -r1.21 manifest.mf --- manifest.mf 4 Apr 2007 12:52:47 -0000 1.21 +++ manifest.mf 5 Apr 2007 07:35:24 -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.10 +OpenIDE-Module-Specification-Version: 2.11 OpenIDE-Module-Package-Dependencies: com.sun.jdi[VirtualMachineManager] Index: src/org/netbeans/api/debugger/jpda/Field.java =================================================================== RCS file: /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/Field.java,v retrieving revision 1.6 diff -u -r1.6 Field.java --- src/org/netbeans/api/debugger/jpda/Field.java 30 Jun 2006 19:04:46 -0000 1.6 +++ src/org/netbeans/api/debugger/jpda/Field.java 5 Apr 2007 07:35:24 -0000 @@ -13,7 +13,7 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ @@ -48,6 +48,12 @@ * @return name of enclosing class */ public abstract String getClassName (); + + /** + * Get the class type in which this field was declared. + * @return the class type + */ + public abstract JPDAClassType getDeclaringClass(); /** * Declared type of this field. Index: src/org/netbeans/api/debugger/jpda/JPDAClassType.java =================================================================== RCS file: /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/JPDAClassType.java,v retrieving revision 1.1 diff -u -r1.1 JPDAClassType.java --- src/org/netbeans/api/debugger/jpda/JPDAClassType.java 21 Jul 2006 10:14:29 -0000 1.1 +++ src/org/netbeans/api/debugger/jpda/JPDAClassType.java 5 Apr 2007 07:35:24 -0000 @@ -13,7 +13,7 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ @@ -35,19 +35,7 @@ * * @author Martin Entlicher */ -public interface JPDAClassType { - - /* - List instances(long maxInstances); - - long instanceCount(); - */ - - /** - * Get the name of this type. - * @return fully qualified name of this type. - */ - String getName(); +public interface JPDAClassType extends VariableType { /** * Get the source name of this type. @@ -62,10 +50,40 @@ ClassVariable classObject(); /** + * Gets the classloader object which loaded the class corresponding to this type. + * @return an object variable representing the classloader, or null + * if the class was loaded through the bootstrap class loader. + */ + ObjectVariable getClassLoader(); + + /** + * Gets the superclass of this class. + * @return the superclass of this class in the debuggee, or null + * if no such class exists. + */ + Super getSuperClass(); + + /** * Provide a list of static fields declared in this type. * @return the list of {@link org.netbeans.api.debugger.jpda.Field} objects * representing static fields. */ List staticFields(); + + /** + * Retrieves the number of instances this class. + * Use {@link JPDADebugger#canGetInstanceInfo} to determine if this operation is supported. + * @return the number of instances. + */ + long getInstanceCount() throws UnsupportedOperationException; + + /** + * Returns instances of this class type. Only instances that are reachable + * for the purposes of garbage collection are returned. + * Use {@link JPDADebugger#canGetInstanceInfo} to determine if this operation is supported. + * @param maxInstances the maximum number of instances to return. Must be non-negative. If zero, all instances are returned. + * @return a List of object variables. + */ + List getInstances(long maxInstances) throws UnsupportedOperationException; } Index: 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.22 diff -u -r1.22 JPDADebugger.java --- src/org/netbeans/api/debugger/jpda/JPDADebugger.java 4 Aug 2006 14:18:22 -0000 1.22 +++ src/org/netbeans/api/debugger/jpda/JPDADebugger.java 5 Apr 2007 07:35:24 -0000 @@ -13,7 +13,7 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ @@ -30,6 +30,7 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -431,4 +432,45 @@ public JPDAStep createJPDAStep(int size, int depth) { throw new UnsupportedOperationException("This method must be overridden."); } + + /** + * Test whether the debuggee supports accessing of class instances, instance counts, and referring objects. + * + * @see #getInstanceCounts + * @see JPDAClassType#getInstanceCount + * @see JPDAClassType#getInstances + * @see ObjectVariable#getReferringObjects + * + * @return true when the feature is supported, false otherwise. + */ + public boolean canGetInstanceInfo() { + return false; + } + + /** + * Get the list of all classes in the debuggee. + * @return The list of all classes. + */ + public List getAllClasses() { + return Collections.emptyList(); + } + + /** + * Get the list of all classes mathing the given name in the debuggee. + * @return The list of classes. + */ + public List getClassesByName(String name) { + return Collections.emptyList(); + } + + /** + * Retrieves the number of instances of each class in the list. + * Use {@link #canGetInstanceInfo} to determine if this operation is supported. + * @return an array of long containing one instance counts for + * each respective element in the classTypes list. + */ + public long[] getInstanceCounts(List classTypes) throws UnsupportedOperationException { + throw new UnsupportedOperationException("Not supported."); + } + } Index: src/org/netbeans/api/debugger/jpda/ObjectVariable.java =================================================================== RCS file: /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/ObjectVariable.java,v retrieving revision 1.8 diff -u -r1.8 ObjectVariable.java --- src/org/netbeans/api/debugger/jpda/ObjectVariable.java 30 Jun 2006 19:04:48 -0000 1.8 +++ src/org/netbeans/api/debugger/jpda/ObjectVariable.java 5 Apr 2007 07:35:24 -0000 @@ -13,12 +13,14 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.api.debugger.jpda; +import java.util.List; + /** * Represents instance of some object in debugged JVM. This interface can @@ -107,9 +109,30 @@ public abstract Field[] getInheritedFields (int from, int to); /** + * Returns variables that directly reference this variable. + * Use {@link JPDADebugger#canGetInstanceInfo} to determine if this operation is supported. + * @param maxReferrers The maximum number of referring variables to return. Must be non-negative. If zero, all referring variables are returned. + * @return A list of referring variables. + */ + List getReferringObjects(long maxReferrers) throws UnsupportedOperationException; + + /** * Returns representation of super class of this object. * * @return representation of super class of this object */ public abstract Super getSuper (); + + /** + * Get the run-time class type of this object variable. + * @return The variable class type. + */ + JPDAClassType getClassType(); + + /** + * Returns a unique identifier for this object variable. + * It is guaranteed to be unique among all object variables from the same debuggee that have not yet been disposed. + * @return a long unique ID + */ + long getUniqueID(); }