在 BCEL 中,我们可以在 Operand Stack 上推送原始类型。但是现在我想知道是否可以在 BCEL的堆栈上推送自定义类型对象?
我给出了一些代码,以便它可以解释问题上下文
class Automobile {
public void getEngine(int carNo,EngineClass engineClassObj){
System.out.println("EngineNo="+engineClassObj.sisNo);
}
}
Now when i load "Automobile" class in memory.
ilist = new InstructionList();
ilist.append(InstructionConstants.ALOAD_0);
ilist.append(new PUSH(pgen,345));
////Hear Now i have to also push the Object on Stack
ilist.append(ifact.createInvoke(_invoking_ClassName,_invoking_MethodName, Type.INT,*
new Type[] { Type.INT,Type.OBJECT }, Constants.INVOKEVIRTUAL));
ilist.append(InstructionConstants.IRETURN);
1-如果我使用 createNew() 方法并生成新对象,那么我将如何填充其字段值?2-或者,如果我首先使用 PUSH 将引擎类型 Obj 的所有字段值推送到堆栈上,那么我可以了解如何在内存上构造对象然后将其推送到堆栈上。这些是我能想到的一些解决方案。
但我不知道正确的解决方案所以仍然需要帮助......