Seeing something weird with invokestatic methods on non static methods?

This commit is contained in:
Adam
2015-07-26 21:36:19 -04:00
parent 35fcfc0645
commit fda37792ff
3 changed files with 18 additions and 7 deletions

View File

@@ -175,6 +175,19 @@ public class ClassFile
return null; 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) public Method findMethod(NameAndType nat)
{ {
return methods.findMethod(nat); return methods.findMethod(nat);

View File

@@ -51,7 +51,7 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
if (otherClass == null) if (otherClass == null)
return new ArrayList<>(); // not our class 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; assert other != null;
List<info.sigterm.deob.Method> list = new ArrayList<>(); List<info.sigterm.deob.Method> list = new ArrayList<>();
@@ -180,7 +180,8 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
if (otherClass == null) if (otherClass == null)
return; // not our class 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)) if (other.equals(m))
method = new Method(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor())); method = new Method(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor()));

View File

@@ -34,7 +34,7 @@ public class UnusedParameters implements Deobfuscator
visited.add(cf); visited.add(cf);
Method method = cf.findMethodDeep(nat); // XXX this searches down Method method = cf.findMethod(nat);
if (method != null && !method.isStatic()) if (method != null && !method.isStatic())
list.add(method); list.add(method);
@@ -55,10 +55,7 @@ public class UnusedParameters implements Deobfuscator
private static List<Method> findDependentMethods(Method m) private static List<Method> findDependentMethods(Method m)
{ {
ClassFile cf = m.getMethods().getClassFile(); ClassFile cf = m.getMethods().getClassFile();
List<Method> methods = findDependentMethods(m.getNameAndType(), new HashSet<ClassFile>(), cf.getGroup(), cf); return findDependentMethods(m.getNameAndType(), new HashSet<ClassFile>(), cf.getGroup(), cf);
Set s = new HashSet<>(methods); // XXX
return new ArrayList<>(s);
} }
private List<Integer> findUnusedParameters(Method method) private List<Integer> findUnusedParameters(Method method)