Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
5.1
-
None
Description
I'm trying to generate the following code use BCEL:
package bci;
public class Test {
public int[] getArray()
{ return new int[1]; } public static void main(String[] args) {
}
}
I use BCELIfier to generate the code that creates Test. The snippet that creates getArray is
private void createMethod_2() {
InstructionList il = new InstructionList();
MethodGen method = new MethodGen(ACC_PUBLIC, new ArrayType(T_INT, 1), Type.NO_ARGS, new
String[] { }, "getArray", "bci.Test", il, _cp);
InstructionHandle ih_0 = il.append(new PUSH(_cp, 1));
il.append(_factory.createNewArray(new ArrayType(T_INT, 1), (short) 1));
InstructionHandle ih_3 = il.append(_factory.createReturn(Type.OBJECT));
method.setMaxStack();
method.setMaxLocals();
_cg.addMethod(method.getMethod());
il.dispose();
}
I run TestCreator (generated by BCELIfier) and execute Test, which triggers the following error:
Exception in thread "main" java.lang.VerifyError: (class: bci/Test, method: getArray signature: ()[I)
Wrong return type in function
If I return null rather than the array, everything is perfectly allright.