Methods Summary |
---|
public java.lang.String | describeReferenceTo(long referent)
// If this isn't an object array then we can't refer to an object
if (mType != Types.OBJECT) {
return super.describeReferenceTo(referent);
}
int idSize = Types.getTypeSize(mType);
final int N = mNumEntries;
int numRefs = 0;
StringBuilder result = new StringBuilder("Elements [");
ByteArrayInputStream bais = new ByteArrayInputStream(mData);
DataInputStream dis = new DataInputStream(bais);
/*
* Spin through all the objects and build up a string describing
* all of the array elements that refer to the target object.
*/
for (int i = 0; i < N; i++) {
long id;
try {
if (idSize == 4) {
id = dis.readInt();
} else {
id = dis.readLong();
}
if (id == referent) {
numRefs++;
if (numRefs > 1) {
result.append(", ");
}
result.append(i);
}
} catch (java.io.IOException e) {
e.printStackTrace();
}
}
if (numRefs == 0) {
return super.describeReferenceTo(referent);
}
result.append("]");
return result.toString();
|
public final int | getSize()
return mData.length;
|
public final java.lang.String | getTypeName()
return Types.getTypeName(mType) + "[" + mNumEntries + "]";
|
public final void | resolveReferences(State state)
if (mType != Types.OBJECT) {
return;
}
/*
* mData holds a stream of object instance ids
* Spin through them all and list ourselves as a reference holder.
*/
int idSize = Types.getTypeSize(mType);
final int N = mNumEntries;
ByteArrayInputStream bais = new ByteArrayInputStream(mData);
DataInputStream dis = new DataInputStream(bais);
for (int i = 0; i < N; i++) {
long id;
try {
if (idSize == 4) {
id = dis.readInt();
} else {
id = dis.readLong();
}
Instance instance = state.findReference(id);
if (instance != null) {
instance.addParent(this);
}
} catch (java.io.IOException e) {
e.printStackTrace();
}
}
|
public final java.lang.String | toString()
return String.format("%s@0x08x", getTypeName(), mId);
|
public final void | visit(java.util.Set resultSet, Filter filter)
// If we're in the set then we and our children have been visited
if (resultSet.contains(this)) {
return;
}
if (null != filter) {
if (filter.accept(this)) {
resultSet.add(this);
}
} else {
resultSet.add(this);
}
if (mType != Types.OBJECT) {
return;
}
/*
* mData holds a stream of object instance ids
* Spin through them all and visit them
*/
int idSize = Types.getTypeSize(mType);
final int N = mNumEntries;
ByteArrayInputStream bais = new ByteArrayInputStream(mData);
DataInputStream dis = new DataInputStream(bais);
State state = mHeap.mState;
for (int i = 0; i < N; i++) {
long id;
try {
if (idSize == 4) {
id = dis.readInt();
} else {
id = dis.readLong();
}
Instance instance = state.findReference(id);
if (instance != null) {
instance.visit(resultSet, filter);
}
} catch (java.io.IOException e) {
e.printStackTrace();
}
}
|