139 lines
4.2 KiB
Java
139 lines
4.2 KiB
Java
package com.squareup.leakcanary;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class LeakTraceElement implements Serializable {
|
|
public final List<String> classHierarchy;
|
|
public final String className;
|
|
public final Exclusion exclusion;
|
|
public final String extra;
|
|
public final List<LeakReference> fieldReferences;
|
|
|
|
@Deprecated
|
|
public final List<String> fields;
|
|
public final Holder holder;
|
|
public final LeakReference reference;
|
|
|
|
@Deprecated
|
|
public final String referenceName;
|
|
|
|
@Deprecated
|
|
public final Type type;
|
|
|
|
public enum Holder {
|
|
OBJECT,
|
|
CLASS,
|
|
THREAD,
|
|
ARRAY
|
|
}
|
|
|
|
public enum Type {
|
|
INSTANCE_FIELD,
|
|
STATIC_FIELD,
|
|
LOCAL,
|
|
ARRAY_ENTRY
|
|
}
|
|
|
|
LeakTraceElement(LeakReference leakReference, Holder holder, List<String> list, String str, Exclusion exclusion, List<LeakReference> list2) {
|
|
this.reference = leakReference;
|
|
this.referenceName = leakReference == null ? null : leakReference.getDisplayName();
|
|
this.type = leakReference != null ? leakReference.type : null;
|
|
this.holder = holder;
|
|
this.classHierarchy = Collections.unmodifiableList(new ArrayList(list));
|
|
this.className = list.get(0);
|
|
this.extra = str;
|
|
this.exclusion = exclusion;
|
|
this.fieldReferences = Collections.unmodifiableList(new ArrayList(list2));
|
|
ArrayList arrayList = new ArrayList();
|
|
Iterator<LeakReference> it = list2.iterator();
|
|
while (it.hasNext()) {
|
|
arrayList.add(it.next().toString());
|
|
}
|
|
this.fields = Collections.unmodifiableList(arrayList);
|
|
}
|
|
|
|
public String getFieldReferenceValue(String str) {
|
|
for (LeakReference leakReference : this.fieldReferences) {
|
|
if (leakReference.name.equals(str)) {
|
|
return leakReference.value;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public String getSimpleClassName() {
|
|
int lastIndexOf = this.className.lastIndexOf(46);
|
|
return lastIndexOf == -1 ? this.className : this.className.substring(lastIndexOf + 1);
|
|
}
|
|
|
|
public boolean isInstanceOf(Class<?> cls) {
|
|
return isInstanceOf(cls.getName());
|
|
}
|
|
|
|
public String toDetailedString() {
|
|
String str;
|
|
Holder holder = this.holder;
|
|
if (holder == Holder.ARRAY) {
|
|
str = "* Array of";
|
|
} else if (holder == Holder.CLASS) {
|
|
str = "* Class";
|
|
} else {
|
|
str = "* Instance of";
|
|
}
|
|
String str2 = str + " " + this.className + "\n";
|
|
Iterator<LeakReference> it = this.fieldReferences.iterator();
|
|
while (it.hasNext()) {
|
|
str2 = str2 + "| " + it.next() + "\n";
|
|
}
|
|
return str2;
|
|
}
|
|
|
|
public String toString() {
|
|
return toString(false);
|
|
}
|
|
|
|
public boolean isInstanceOf(String str) {
|
|
Iterator<String> it = this.classHierarchy.iterator();
|
|
while (it.hasNext()) {
|
|
if (it.next().equals(str)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public String toString(boolean z) {
|
|
LeakReference leakReference = this.reference;
|
|
String str = "";
|
|
if (leakReference != null && leakReference.type == Type.STATIC_FIELD) {
|
|
str = "static ";
|
|
}
|
|
Holder holder = this.holder;
|
|
if (holder == Holder.ARRAY || holder == Holder.THREAD) {
|
|
str = str + this.holder.name().toLowerCase(Locale.US) + " ";
|
|
}
|
|
String str2 = str + getSimpleClassName();
|
|
LeakReference leakReference2 = this.reference;
|
|
if (leakReference2 != null) {
|
|
String displayName = leakReference2.getDisplayName();
|
|
if (z) {
|
|
displayName = "!(" + displayName + ")!";
|
|
}
|
|
str2 = str2 + "." + displayName;
|
|
}
|
|
if (this.extra != null) {
|
|
str2 = str2 + " " + this.extra;
|
|
}
|
|
if (this.exclusion == null) {
|
|
return str2;
|
|
}
|
|
return str2 + " , matching exclusion " + this.exclusion.matching;
|
|
}
|
|
}
|