in src/main/java/org/apache/bcel/generic/MethodGen.java [257:304]
public MethodGen(final int accessFlags, final Type returnType, final Type[] argTypes, String[] argNames, final String methodName, final String className,
final InstructionList il, final ConstantPoolGen cp) {
super(accessFlags);
setType(returnType);
setArgumentTypes(argTypes);
setArgumentNames(argNames);
setName(methodName);
setClassName(className);
setInstructionList(il);
setConstantPool(cp);
final boolean abstract_ = isAbstract() || isNative();
InstructionHandle start = null;
final InstructionHandle end = null;
if (!abstract_) {
start = il.getStart();
// end == null => live to end of method
/*
* Add local variables, namely the implicit 'this' and the arguments
*/
if (!isStatic() && className != null) { // Instance method -> 'this' is local var 0
addLocalVariable("this", ObjectType.getInstance(className), start, end);
}
}
if (argTypes != null) {
final int size = argTypes.length;
for (final Type argType : argTypes) {
if (Type.VOID == argType) {
throw new ClassGenException("'void' is an illegal argument type for a method");
}
}
if (argNames != null) { // Names for variables provided?
if (size != argNames.length) {
throw new ClassGenException("Mismatch in argument array lengths: " + size + " vs. " + argNames.length);
}
} else { // Give them dummy names
argNames = new String[size];
for (int i = 0; i < size; i++) {
argNames[i] = "arg" + i;
}
setArgumentNames(argNames);
}
if (!abstract_) {
for (int i = 0; i < size; i++) {
addLocalVariable(argNames[i], argTypes[i], start, end);
}
}
}
}