From 422b10b419eb010b612931e8b250b9dd1b7424ed Mon Sep 17 00:00:00 2001 From: Runemoro Date: Sat, 2 Nov 2019 17:23:14 -0400 Subject: Check protected method/field target in visibility index (#157) --- src/main/java/cuchaz/enigma/analysis/EntryReference.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/main/java/cuchaz/enigma/analysis/EntryReference.java') diff --git a/src/main/java/cuchaz/enigma/analysis/EntryReference.java b/src/main/java/cuchaz/enigma/analysis/EntryReference.java index e122210..2e738c0 100644 --- a/src/main/java/cuchaz/enigma/analysis/EntryReference.java +++ b/src/main/java/cuchaz/enigma/analysis/EntryReference.java @@ -29,6 +29,7 @@ public class EntryReference, C extends Entry> implements T private static final List CONSTRUCTOR_NON_NAMES = Arrays.asList("this", "super", "static"); public E entry; public C context; + public ReferenceTargetType targetType; private boolean sourceName; @@ -37,12 +38,17 @@ public class EntryReference, C extends Entry> implements T } public EntryReference(E entry, String sourceName, C context) { + this(entry, sourceName, context, ReferenceTargetType.none()); + } + + public EntryReference(E entry, String sourceName, C context, ReferenceTargetType targetType) { if (entry == null) { throw new IllegalArgumentException("Entry cannot be null!"); } this.entry = entry; this.context = context; + this.targetType = targetType; this.sourceName = sourceName != null && !sourceName.isEmpty(); if (entry instanceof MethodEntry && ((MethodEntry) entry).isConstructor() && CONSTRUCTOR_NON_NAMES.contains(sourceName)) { @@ -54,6 +60,7 @@ public class EntryReference, C extends Entry> implements T this.entry = entry; this.context = context; this.sourceName = other.sourceName; + this.targetType = other.targetType; } public ClassEntry getLocationClassEntry() { @@ -112,10 +119,17 @@ public class EntryReference, C extends Entry> implements T public String toString() { StringBuilder buf = new StringBuilder(); buf.append(entry); + if (context != null) { buf.append(" called from "); buf.append(context); } + + if (targetType != null && targetType.getKind() != ReferenceTargetType.Kind.NONE) { + buf.append(" on target of type "); + buf.append(targetType); + } + return buf.toString(); } -- cgit v1.2.3