jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "chinmoy chakraborty" <chinu...@rediffmail.com>
Subject Re: Re: [SPAM] New to BCEL - Please help
Date Fri, 23 Dec 2005 08:52:35 GMT
Hi Dave,

Thank you very much for your reply. Now I am trying to generate following code dynamically,

public int getNum()
{ return num; //num is a private class variable
i have written following BCEL code to genarate that,
FieldGen fg = new FieldGen(Constants.ACC_PRIVATE, Type.INT, "Num", cp ); //class variable

MethodGen mg1 = new MethodGen(Constants.ACC_PUBLIC,
                    Type.INT, Type.NO_ARGS, new String[] {}, "getNum", "Num", i1, cp); //i1-instruction
list, cp - //constantpoolgen

i1.append(factory.createLoad(fg.getField().getType(), fg.getField().getNameIndex()));

It generates following code through BCEL,

public int getNum()
        return <no variable>;
why is it so?? why the variable name is missing??


On Fri, 23 Dec 2005 Dave Brosius wrote :
>There is a tool in BCEL called BCELifier, which will show you the code to generate a class,
given that class.
>That is an ideal way to learn how to do what you want.
>----- Original Message ----- From: "chinmoy chakraborty" <chinu_ss@rediffmail.com>
>To: <bcel-user@jakarta.apache.org>
>Sent: Wednesday, December 21, 2005 11:15 PM
>Subject: [SPAM] New to BCEL - Please help
>I am new to BCEL nad still struggling to get used to it. Could you please tell me where
I can get some tutorial of BCEL. I have gone through the BCEL Manual but I want something
more. Could you please tell me what will be the BCEL equivalent code for the following.
>public class Num
>  private int num;
>  public int getNum()
>  { return num;}
>  public void setNum(int num)
>  { this.num = num;}
>  private static org.apache.axis.description.TypeDesc typeDesc =
>        new org.apache.axis.description.TypeDesc(Num.class);
>  public static org.apache.axis.encoding.Serializer getSerializer (java.lang.String mechType,java.lang.Class
_javaType, javax.xml.namespace.QName _xmlType)
>    {return new  org.apache.axis.encoding.ser.BeanSerializer  (_javaType, _xmlType,typeDesc);
>    }
>To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: bcel-user-help@jakarta.apache.org

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message