From 92b053548a6361600e462f9d4f6d42ffafc6c6a8 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 27 Feb 2016 13:37:41 -0500 Subject: [PATCH] Fix handling invokevirtual on static methods --- .../java/net/runelite/deob/execution/Frame.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/runelite/deob/execution/Frame.java b/src/main/java/net/runelite/deob/execution/Frame.java index 6cc119cd14..89f45c63c4 100644 --- a/src/main/java/net/runelite/deob/execution/Frame.java +++ b/src/main/java/net/runelite/deob/execution/Frame.java @@ -99,6 +99,9 @@ public class Frame created = ctx.getInstruction(); // initialize frame from invoking context assert ctx.getInstruction() instanceof InvokeInstruction; + + // this assert fails. evidently it's possible to invokevirtual a static method. + //assert ctx.getInstruction() instanceof InvokeStatic == this.method.isStatic(); if (this.getMethod().isStatic()) { @@ -111,8 +114,17 @@ public class Frame pops = Lists.reverse(new ArrayList<>(pops)); // reverse the list so first argument is at index 0 int lvtOffset = 0; - if (!method.isStatic()) - variables.set(lvtOffset++, new VariableContext(ctx, pops.remove(0)).markParameter()); + if (!(ctx.getInstruction() instanceof InvokeStatic)) + { + StackContext s = pops.remove(0); // object + + // sometimes there are invokevirtuals on static methods. still must pop the object from the stack, + // but don't set as a parameter + if (!method.isStatic()) + { + variables.set(lvtOffset++, new VariableContext(ctx, s).markParameter()); + } + } NameAndType nat = method.getNameAndType();