From 92c674fdff12fdaf65328104e0ad916fd83e1d51 Mon Sep 17 00:00:00 2001 From: Lucwousin Date: Thu, 31 Oct 2019 17:10:13 +0100 Subject: [PATCH] Don't look for instance methods when mixin method is static and vice-v --- .../java/net/runelite/injector/MixinInjector.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java b/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java index bf4627c785..fc871fa152 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java +++ b/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java @@ -525,7 +525,7 @@ public class MixinInjector String deobMethodName = (String) replaceAnnotation.getElement().getValue(); ClassFile deobCf = inject.toDeobClass(cf); - Method deobMethod = findDeobMethod(deobCf, deobMethodName, method.getDescriptor()); + Method deobMethod = findDeobMethod(deobCf, deobMethodName, method); if (deobMethod == null) { @@ -739,14 +739,16 @@ public class MixinInjector } } - private Method findDeobMethod(ClassFile deobCf, String deobMethodName, Signature descriptor) + private Method findDeobMethod(ClassFile deobCf, String deobMethodName, Method mixinMethod) throws InjectionException { - List matchingMethods = new ArrayList<>(); + final Signature descriptor = mixinMethod.getDescriptor(); + final List matchingMethods = new ArrayList<>(); + final boolean stat = mixinMethod.isStatic(); for (Method m : deobCf.getMethods()) { - if (!deobMethodName.equals(m.getName())) + if (!deobMethodName.equals(m.getName()) || m.isStatic() != stat) { continue; } @@ -966,7 +968,7 @@ public class MixinInjector String hookName = methodHook.getElement().getString(); boolean end = methodHook.getElements().size() == 2 && methodHook.getElements().get(1).getValue().equals(true); ClassFile deobCf = inject.toDeobClass(cf); - Method targetMethod = findDeobMethod(deobCf, hookName, method.getDescriptor()); + Method targetMethod = findDeobMethod(deobCf, hookName, method); if (targetMethod == null) {