package bluej.debugger.jdi;
import bluej.debugger.DebuggerObject;
import bluej.debugger.gentype.GenTypeArray;
import bluej.debugger.gentype.GenTypeArrayClass;
import bluej.debugger.gentype.GenTypeClass;
import bluej.debugger.gentype.JavaType;
import bluej.debugger.gentype.Reflective;
import com.sun.jdi.ArrayReference;
import com.sun.jdi.ArrayType;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.Value;
import threadchecker.OnThread;
import threadchecker.Tag;
| Represents an array object running on the user (remote) machine.
|
| @author Michael Kolling
| @created December 26, 2000
|
public class JdiArray
extends JdiObject{
private JavaType componentType;
@OnThread(Tag.Any)
protected JdiArray(ArrayReference obj)
{
this.obj = obj;
obj.disableCollection();
calcComponentType();
}
| Constructor for when the array type is known.
| @param obj The reference to the the remote object
| @param expectedType The known type of the object
|
protected JdiArray(ArrayReference obj, JavaType expectedType)
{
this.obj = obj;
obj.disableCollection();
if (expectedType instanceof GenTypeArray) {
String ctypestr = obj.referenceType().signature();
JavaType genericType = expectedType;
int level = 0;
while (genericType instanceof GenTypeArray) {
GenTypeArray genericArray = (GenTypeArray)genericType;
genericType = genericArray.getArrayComponent();
ctypestr = ctypestr.substring(1);
level++;
}
if (ctypestr.charAt(0) == '[') {
calcComponentType();
return;
}
if (genericType.isPrimitive()) {
calcComponentType();
return;
}
JavaType component;
if (genericType instanceof GenTypeClass) {
String compName = ctypestr.substring(1, ctypestr.length() - 1);
compName = compName.replace('/', '.');
Reflective compReflective = new JdiReflective(compName, obj.referenceType());
component = ((GenTypeClass) genericType).mapToDerived(compReflective);
while (level > 1){
component = component.getArray();
level--;
}
componentType = component;
}
}
if (componentType == null) {
calcComponentType();
}
}
@OnThread(Tag.Any)
@SuppressWarnings("threadchecker")
private void calcComponentType()
{
ArrayType ar = (ArrayType) obj.referenceType();
String componentSig = ar.componentSignature();
JdiReflective.StringIterator i = new JdiReflective.StringIterator(componentSig);
componentType = JdiReflective.typeFromSignature(i, null, ar).asType();
}
| Get the name of the class of this object.
|
| @return String representing the Class name.
|
@Override
@OnThread(Tag.Any)
public String getClassName()
{
return obj.referenceType().name();
}
| Get the GenType object representing the type of this array.
|
| @return GenType representing the type of the array.
|
@Override
public GenTypeClass getGenType()
{
Reflective r = new JdiArrayReflective(componentType, obj.referenceType());
return new GenTypeArrayClass(r, componentType);
}
| Return true if this object is an array.
|
| @return The Array value
|
@Override
@OnThread(Tag.Any)
public boolean isArray()
{
return true;
}
@Override
public int getElementCount()
{
return ((ArrayReference) obj).length();
}
@Override
public JavaType getElementType()
{
return componentType;
}
@Override
public String getElementValueString(int index)
{
Value val = ((ArrayReference) obj).getValue(index);
return JdiUtils.getJdiUtils().getValueString(val);
}
|
| Return the object in object field 'slot'.
|
| @param slot The slot number to be returned
| @return The InstanceFieldObject value
|
@Override
public DebuggerObject getElementObject(int index)
{
Value val = ((ArrayReference) obj).getValue(index);
return JdiObject.getDebuggerObject((ObjectReference) val, componentType);
}
}
top,
use,
map,
class JdiArray
. JdiArray
. JdiArray
. calcComponentType
. getClassName
. getGenType
. isArray
. getElementCount
. getElementType
. getElementValueString
. getElementObject
191 neLoCode
+ 16 LoComm