Search code examples
javabytecodebcel

How to push integer on Stack in BCEL


I am facing a problem in context of pushing a integer on stack in BCEL. I have a method _square of someClass i.e. "mathClass"

    ilist = new InstructionList();
    ilist.append(InstructionConstants.ALOAD_0);
    ilist.append(new GETFIELD(findex));
   //I am trying to push some value using createLoad but it is not working 

     ilist.append(InstructionConstants.ALOAD_1);
    ilist.append(ifact.createInvoke("mathClass", _square, Type.INT,
       new Type[] { Type.INT }, Constants.INVOKEVIRTUAL));

thanks


Solution

  • I use

    new InstructionList.append(new PUSH(constantPool,23));
    

    the push method use to push primitive type data on stack.