descriptor);
jMethod.setAccessFlags(Modifier.PUBLIC);
Class<?> []parameterTypes = method.getParameterTypes();
CodeWriterAttribute code = jMethod.createCodeWriter();
code.setMaxLocals(1 + 2 * parameterTypes.length);
code.setMaxStack(3 + 2 * parameterTypes.length);
code.pushObjectVar(0);
code.getField(jClass.getThisClass(), "_factory",
"Lcom/caucho/config/inject/InjectManager$ReferenceFactory;");
code.invoke("com/caucho/config/inject/InjectManager$ReferenceFactory",
"create",
"()Ljava/lang/Object;",
3, 1);
code.cast(method.getDeclaringClass().getName().replace('.', '/'));
int stack = 1;
int index = 1;
for (Class<?> type : parameterTypes) {
if (boolean.class.equals(type)
|| byte.class.equals(type)
|| short.class.equals(type)
|| int.class.equals(type)) {
code.pushIntVar(index);
index += 1;
stack += 1;
}
else if (long.class.equals(type)) {
code.pushLongVar(index);
index += 2;
stack += 2;
}
else if (float.class.equals(type)) {
code.pushFloatVar(index);
index += 1;
stack += 1;
}
else if (double.class.equals(type)) {
code.pushDoubleVar(index);
index += 2;
stack += 2;
}
else {
code.pushObjectVar(index);
index += 1;
stack += 1;
}
}
if (isInterface) {
code.invokeInterface(method.getDeclaringClass().getName().replace('.', '/'),
method.getName(),
createDescriptor(method),
stack, 1);
}
else {
code.invoke(method.getDeclaringClass().getName().replace('.', '/'),
method.getName(),
createDescriptor(method),
stack, 1);
}
Class<?> retType = method.getReturnType();
if (boolean.class.equals(retType)
|| byte.class.equals(retType)
|| short.class.equals(retType)
|| int.class.equals(retType)) {
code.addIntReturn();
}
else if (long.class.equals(retType)) {
code.addLongReturn();
}
else if (float.class.equals(retType)) {
code.addFloatReturn();
}
else if (double.class.equals(retType)) {
code.addDoubleReturn();
}
else if (void.class.equals(retType)) {
code.addReturn();
}
else {
code.addObjectReturn();
}
code.close();
}