Handle gaps in local variable table when failing over to surrogates

This commit is contained in:
Mumfrey committed 2015-11-21 02:20:16 +00:00
1 parent e337823f69
commit f32d67a23c
3 files changed
+6 -4

No files matched your search

@@ -422,8 +422,8 @@ public class CallbackInjector extends Injector {
private String generateBadLVTMessage(final Callback callback) {
int position = callback.target.method.instructions.indexOf(callback.node);
List<String> expected = CallbackInjector.summariseLocals(this.methodNode.desc, callback.target.arguments.length + 1);
List<String> found = CallbackInjector.summariseLocals(callback.localTypes, callback.frameSize);
String message = String.format("LVT in %s::%s has incompatible changes at opcode %d in callback %s%s.\nExpected: %s\n Found:%s",
List<String> found = CallbackInjector.summariseLocals(callback.getDescriptorWithAllLocals(), callback.frameSize);
String message = String.format("LVT in %s::%s has incompatible changes at opcode %d in callback %s%s.\nExpected: %s\n Found: %s",
this.classNode.name, callback.target.method.name, position, this.methodNode.name, this.methodNode.desc, expected, found);
return message;
}
@@ -255,9 +255,10 @@ public class Target {
}
String descriptor = this.callbackDescriptor.substring(0, this.callbackDescriptor.indexOf(')'));
for (int l = startIndex; l < locals.length && l < (startIndex + extra); l++) {
for (int l = startIndex; l < locals.length && extra > 0; l++) {
if (locals[l] != null) {
descriptor += locals[l].getDescriptor();
extra--;
}
}
@@ -72,9 +72,10 @@ public class Locals {
*/
public static void loadLocals(Type[] locals, InsnList insns, int pos, int limit) {
limit += pos;
for (; pos < locals.length && pos < limit; pos++) {
for (; pos < locals.length && limit > 0; pos++) {
if (locals[pos] != null) {
insns.add(new VarInsnNode(locals[pos].getOpcode(Opcodes.ILOAD), pos));
limit--;
}
}
}