diff --git a/src/main/java/info/sigterm/deob/ClassFile.java b/src/main/java/info/sigterm/deob/ClassFile.java index ab61ba7a48..ee3e065d5e 100644 --- a/src/main/java/info/sigterm/deob/ClassFile.java +++ b/src/main/java/info/sigterm/deob/ClassFile.java @@ -175,6 +175,19 @@ public class ClassFile return null; } + public Method findMethodDeepStatic(NameAndType nat) + { + Method m = methods.findMethod(nat); + if (m != null && m.isStatic()) + return m; + + ClassFile parent = getParent(); + if (parent != null) + return parent.findMethodDeep(nat); + + return null; + } + public Method findMethod(NameAndType nat) { return methods.findMethod(nat); diff --git a/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeStatic.java b/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeStatic.java index e2f8bf402e..fa258c5ffc 100644 --- a/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeStatic.java +++ b/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeStatic.java @@ -51,7 +51,7 @@ public class InvokeStatic extends Instruction implements InvokeInstruction if (otherClass == null) return new ArrayList<>(); // not our class - info.sigterm.deob.Method other = otherClass.findMethodDeep(method.getNameAndType()); + info.sigterm.deob.Method other = otherClass.findMethodDeepStatic(method.getNameAndType()); assert other != null; List list = new ArrayList<>(); @@ -180,7 +180,8 @@ public class InvokeStatic extends Instruction implements InvokeInstruction if (otherClass == null) return; // not our class - info.sigterm.deob.Method other = otherClass.findMethodDeep(method.getNameAndType()); + info.sigterm.deob.Method other = otherClass.findMethodDeepStatic(method.getNameAndType()); + assert other.isStatic(); if (other.equals(m)) method = new Method(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor())); diff --git a/src/main/java/info/sigterm/deob/deobfuscators/UnusedParameters.java b/src/main/java/info/sigterm/deob/deobfuscators/UnusedParameters.java index 26a16924d4..1df8130a61 100644 --- a/src/main/java/info/sigterm/deob/deobfuscators/UnusedParameters.java +++ b/src/main/java/info/sigterm/deob/deobfuscators/UnusedParameters.java @@ -34,7 +34,7 @@ public class UnusedParameters implements Deobfuscator visited.add(cf); - Method method = cf.findMethodDeep(nat); // XXX this searches down + Method method = cf.findMethod(nat); if (method != null && !method.isStatic()) list.add(method); @@ -55,10 +55,7 @@ public class UnusedParameters implements Deobfuscator private static List findDependentMethods(Method m) { ClassFile cf = m.getMethods().getClassFile(); - List methods = findDependentMethods(m.getNameAndType(), new HashSet(), cf.getGroup(), cf); - - Set s = new HashSet<>(methods); // XXX - return new ArrayList<>(s); + return findDependentMethods(m.getNameAndType(), new HashSet(), cf.getGroup(), cf); } private List findUnusedParameters(Method method)