A null callback info is passed to static handlers that target instance methods and capture the enclosing method args regardless of whether the handler uses the callback info. this happens because the calculation of callbackInfoSlot in CallbackInjector$Callback doesn't consider the handler being static unless the handler doesn't capture the enclosing method arguments.
public class CallbackInjector extends Injector {
// ...
private class Callback extends InsnList {
// ...
Callback(MethodNode handler, Target target, final InjectionNode node, final LocalVariableNode[] locals, boolean captureLocals) {
// ...
int callbackInfoSlot = handlerArgs.length == 1 ? Bytecode.isStatic(handler) ? 0 : 1 : frameSize;
// ...
}
}
}
it seems to me that this could be fixed like so:
- int callbackInfoSlot = handlerArgs.length == 1 ? Bytecode.isStatic(handler) ? 0 : 1 : frameSize;
+ int callbackInfoSlot = handlerArgs.length == 1 ? Bytecode.isStatic(handler) ? 0 : 1 : Bytecode.isStatic(handler) && !target.isStatic ? (frameSize - 1) : frameSize;