diff --git a/src/main/java/org/spongepowered/asm/mixin/injection/callback/CallbackInjector.java b/src/main/java/org/spongepowered/asm/mixin/injection/callback/CallbackInjector.java index d36ed952..9827cfb1 100644 --- a/src/main/java/org/spongepowered/asm/mixin/injection/callback/CallbackInjector.java +++ b/src/main/java/org/spongepowered/asm/mixin/injection/callback/CallbackInjector.java @@ -529,13 +529,15 @@ public class CallbackInjector extends Injector { */ private String generateBadLVTMessage(final Callback callback) { int position = callback.target.indexOf(callback.node); - List expected = CallbackInjector.summariseLocals(this.methodNode.desc, callback.target.arguments.length + 1); - List found = CallbackInjector.summariseLocals(callback.getDescriptor(), callback.frameSize + (callback.target.isStatic ? 1 : 0)); + int targetArgc = callback.target.arguments.length + 1; + List expected = CallbackInjector.summariseLocals(this.methodNode.desc, targetArgc, 255); + List found = CallbackInjector.summariseLocals(callback.getDescriptorWithAllLocals(), targetArgc, expected.size()); if (expected.equals(found)) { return String.format("Invalid descriptor on %s! Expected %s but found %s", this.info, callback.getDescriptor(), this.methodNode.desc); } - return String.format("LVT in %s has incompatible changes at opcode %d in callback %s.\nExpected: %s\n Found: %s", - callback.target, position, this, expected, found); + List available = CallbackInjector.summariseLocals(callback.getDescriptorWithAllLocals(), targetArgc, 255); + return String.format("LVT in %s has incompatible changes at opcode %d in callback %s.\n Expected: %s\n Found: %s\nAvailable: %s", + callback.target, position, this.info, expected, found, available); } /** @@ -783,14 +785,14 @@ public class CallbackInjector extends Injector { return this.isStatic; } - private static List summariseLocals(String desc, int pos) { - return CallbackInjector.summariseLocals(Type.getArgumentTypes(desc), pos); + private static List summariseLocals(String desc, int pos, int count) { + return CallbackInjector.summariseLocals(Type.getArgumentTypes(desc), pos, count); } - private static List summariseLocals(Type[] locals, int pos) { + private static List summariseLocals(Type[] locals, int pos, int count) { List list = new ArrayList(); if (locals != null) { - for (; pos < locals.length; pos++) { + for (; pos < locals.length && list.size() < count; pos++) { if (locals[pos] != null) { list.add(locals[pos].toString()); } diff --git a/src/main/java/org/spongepowered/asm/mixin/injection/modify/LocalVariableDiscriminator.java b/src/main/java/org/spongepowered/asm/mixin/injection/modify/LocalVariableDiscriminator.java index b5c5ad87..544e5184 100644 --- a/src/main/java/org/spongepowered/asm/mixin/injection/modify/LocalVariableDiscriminator.java +++ b/src/main/java/org/spongepowered/asm/mixin/injection/modify/LocalVariableDiscriminator.java @@ -145,13 +145,16 @@ public class LocalVariableDiscriminator { } } - Local[] lvt = new Local[this.baseArgIndex + target.arguments.length]; + Local[] lvt = new Local[this.baseArgIndex + Bytecode.getArgsSize(target.arguments)]; if (!this.isStatic) { lvt[0] = new Local("this", Type.getObjectType(target.classNode.name)); } - for (int local = this.baseArgIndex; local < lvt.length; local++) { - Type arg = target.arguments[local - this.baseArgIndex]; - lvt[local] = new Local("arg" + local, arg); + for (int local = this.baseArgIndex, arg = 0; local < lvt.length; local++) { + Type argType = target.arguments[arg++]; + lvt[local] = new Local("arg" + local, argType); + if (argType.getSize() == 2) { + lvt[++local] = null; + } } return lvt; } diff --git a/src/main/java/org/spongepowered/asm/util/Locals.java b/src/main/java/org/spongepowered/asm/util/Locals.java index 733b57f2..e3cb05d8 100644 --- a/src/main/java/org/spongepowered/asm/util/Locals.java +++ b/src/main/java/org/spongepowered/asm/util/Locals.java @@ -137,7 +137,7 @@ public final class Locals { for (int i = 0; i < 3 && (node instanceof LabelNode || node instanceof LineNumberNode); i++) { node = Locals.nextNode(method.instructions, node); } - + ClassInfo classInfo = ClassInfo.forName(classNode.name); if (classInfo == null) { throw new LVTGeneratorError("Could not load class metadata for " + classNode.name + " generating LVT for " + method.name); @@ -195,7 +195,7 @@ public final class Locals { frameSize = Locals.getAdjustedFrameSize(frameSize, frameNode); } - if (frameNode.type == Opcodes.F_CHOP) { + if (frameNode.type == Opcodes.F_CHOP || frameNode.type == Opcodes.F_NEW) { for (int framePos = frameSize; framePos < frame.length; framePos++) { frame[framePos] = null; } @@ -223,7 +223,7 @@ public final class Locals { frame[framePos] = null; } else if (is32bitValue || is64bitValue) { frame[framePos] = Locals.getLocalVariableAt(classNode, method, insn, framePos); - + if (is64bitValue) { framePos++; frame[framePos] = null; // TOP @@ -435,7 +435,7 @@ public final class Locals { labels[i] = label = new LabelNode(); } } - + if (local == null && locals[j] != null) { localVariables.add(localNodes[j]); localNodes[j].end = label; @@ -447,7 +447,12 @@ public final class Locals { localNodes[j] = null; } - String desc = (local.getType() != null) ? local.getType().getDescriptor() : lastKnownType[j]; + String desc = lastKnownType[j]; + Type localType = local.getType(); + if (localType != null) { + desc = "null".equals(localType.getInternalName()) ? Constants.OBJECT_DESC : localType.getDescriptor(); + } + localNodes[j] = new LocalVariableNode("var" + j, desc, null, label, null, j); if (desc != null) { lastKnownType[j] = desc; @@ -497,7 +502,7 @@ public final class Locals { } return insn; } - + /** * Compute a new frame size based on the supplied frame type and the size of * locals contained in the frame (this may differ from the number of actual