jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin von Gagern <Martin.vGag...@gmx.net>
Subject Re: How to push a Custom Type Object on Stack
Date Fri, 10 Jun 2011 06:24:59 GMT
On 09.06.2011 08:38, Zaree Faryal wrote:
> What i want to do is i have a class 
> 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-if i use createNew() method and generate new object then how i am
>   going to fill its fields value?
> 2-or if i firstly push all fields values of Engine type Obj on Stack
>   using PUSH then i can some how construct object on memory & then push it
>   on Stack.

I suggest you formulate how you'd create the object in Java, and then
simply run the resulting class through BCELifier to get an idea of how
the corresponding BCEL code would look like.

http://jakarta.apache.org/bcel/apidocs/org/apache/bcel/util/BCELifier.html

Martin


Mime
View raw message