in src/main/java/org/apache/bcel/generic/InstructionFactory.java [634:666]
public InvokeInstruction createInvoke(final String className, final String name, final Type retType, final Type[] argTypes, final short kind,
final boolean useInterface) {
if (kind != Const.INVOKESPECIAL && kind != Const.INVOKEVIRTUAL && kind != Const.INVOKESTATIC && kind != Const.INVOKEINTERFACE
&& kind != Const.INVOKEDYNAMIC) {
throw new IllegalArgumentException("Unknown invoke kind: " + kind);
}
int index;
int nargs = 0;
final String signature = Type.getMethodSignature(retType, argTypes);
for (final Type argType : argTypes) {
nargs += argType.getSize();
}
if (useInterface) {
index = cp.addInterfaceMethodref(className, name, signature);
} else {
index = cp.addMethodref(className, name, signature);
}
switch (kind) {
case Const.INVOKESPECIAL:
return new INVOKESPECIAL(index);
case Const.INVOKEVIRTUAL:
return new INVOKEVIRTUAL(index);
case Const.INVOKESTATIC:
return new INVOKESTATIC(index);
case Const.INVOKEINTERFACE:
return new INVOKEINTERFACE(index, nargs + 1);
case Const.INVOKEDYNAMIC:
return new INVOKEDYNAMIC(index);
default:
// Can't happen
throw new IllegalStateException("Unknown invoke kind: " + kind);
}
}