Make ModifyArg and Redirect errors mention the handler name, fixes #84

This commit is contained in:
Mumfrey committed 2015-12-20 22:57:35 +00:00
1 parent d20698bd64
commit 087e3cfcfe
3 files changed
+9 -9

No files matched your search

@@ -86,8 +86,8 @@ public abstract class InvokeInjector extends Injector {
@Override
protected void inject(Target target, AbstractInsnNode node) {
if (!(node instanceof MethodInsnNode)) {
throw new InvalidInjectionException(this.info, this.annotationType + " annotation is targetting a non-method insn in " + target
+ " in " + this.classNode.name);
throw new InvalidInjectionException(this.info, this.annotationType + " annotation on is targetting a non-method insn in " + target
+ " in " + this.classNode.name + "/" + this.methodNode.name);
}
this.inject(target, (MethodInsnNode)node);
@@ -76,7 +76,7 @@ public class ModifyArgInjector extends InvokeInjector {
if (this.singleArgMode) {
if (!this.methodArgs[0].equals(this.returnType)) {
throw new InvalidInjectionException(this.info, "@ModifyArg return type must match the parameter type."
throw new InvalidInjectionException(this.info, "@ModifyArg return type on " + this.methodNode.name + " must match the parameter type."
+ " ARG=" + this.methodArgs[0] + " RETURN=" + this.returnType);
}
}
@@ -118,8 +118,8 @@ public class ModifyArgInjector extends InvokeInjector {
*/
private int injectMultiArgHandler(Target target, Type[] args, int argIndex, InsnList insns) {
if (!Arrays.equals(args, this.methodArgs)) {
throw new InvalidInjectionException(this.info, "@ModifyArg method targets a method with an invalid signature "
+ Injector.printArgs(args) + ", expected " + Injector.printArgs(this.methodArgs));
throw new InvalidInjectionException(this.info, "@ModifyArg method " + this.methodNode.name + " targets a method with an invalid"
+ " signature " + Injector.printArgs(args) + ", expected " + Injector.printArgs(this.methodArgs));
}
int[] argMap = this.storeArgs(target, args, insns, 0);
@@ -133,7 +133,7 @@ public class ModifyArgInjector extends InvokeInjector {
if (this.index > -1) {
if (this.index >= args.length || !args[this.index].equals(this.returnType)) {
throw new InvalidInjectionException(this.info, "Specified index " + this.index + " for @ModifyArg is invalid for args "
+ Injector.printArgs(args) + ", expected " + this.returnType);
+ Injector.printArgs(args) + ", expected " + this.returnType + " on " + this.methodNode.name);
}
return this.index;
}
@@ -147,7 +147,7 @@ public class ModifyArgInjector extends InvokeInjector {
if (argIndex != -1) {
throw new InvalidInjectionException(this.info, "Found duplicate args with index [" + argIndex + ", " + arg + "] matching type "
+ this.returnType + " for @ModifyArg target " + target + " in " + this.classNode.name
+ this.returnType + " for @ModifyArg target " + target + " in " + this.classNode.name + "/" + this.methodNode.name
+ ". Please specify index of desired arg.");
}
@@ -156,7 +156,7 @@ public class ModifyArgInjector extends InvokeInjector {
if (argIndex == -1) {
throw new InvalidInjectionException(this.info, "Could not find arg matching type " + this.returnType + " for @ModifyArg target "
+ target + " in " + this.classNode.name);
+ target + " in " + this.classNode.name + "/" + this.methodNode.name);
}
return argIndex;
@@ -90,7 +90,7 @@ public class RedirectInjector extends InvokeInjector {
if (alternateDesc.equals(this.methodNode.desc)) {
injectTargetParams = true;
} else {
throw new InvalidInjectionException(this.info, "@Redirect handler method has an invalid signature "
throw new InvalidInjectionException(this.info, "@Redirect handler method " + this.methodNode.name + " has an invalid signature "
+ ", expected " + desc + " found " + this.methodNode.desc);
}
}