Annotate References with their referent.
Also, don't include annotations in an object's link. That way we can
distinguish between the object link and any links in the annotations.
Change-Id: I3fef3f5b2c343699f527cad9efa7c93a4b35a3a4
diff --git a/tools/ahat/src/InstanceUtils.java b/tools/ahat/src/InstanceUtils.java
index c2d75c4..7fa53c7 100644
--- a/tools/ahat/src/InstanceUtils.java
+++ b/tools/ahat/src/InstanceUtils.java
@@ -244,6 +244,24 @@
return null;
}
+ private static boolean isJavaLangRefReference(Instance inst) {
+ ClassObj cls = (inst == null) ? null : inst.getClassObj();
+ while (cls != null) {
+ if ("java.lang.ref.Reference".equals(cls.getClassName())) {
+ return true;
+ }
+ cls = cls.getSuperClassObj();
+ }
+ return false;
+ }
+
+ public static Instance getReferent(Instance inst) {
+ if (isJavaLangRefReference(inst)) {
+ return getRefField(inst, "referent");
+ }
+ return null;
+ }
+
/**
* Assuming inst represents a DexCache object, return the dex location for
* that dex cache. Returns null if the given instance doesn't represent a