You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-user@jakarta.apache.org by Eric Chow <ec...@macaucabletv.com> on 2004/07/01 09:49:33 UTC
Urgent , BCEL beginner questions ???
Hi,
I am going to use BCEL to do some education project.
But I have so many problems and questions if I should use BCEL or other
library.
1. retrieve all the variable names and its corresponding values (global
variables, and local variables) ?
2. can I add a method with some source expression ??
for example,
clazzGen.addMethod(" int a = 10; System.out.println(a); "); // something
like this, Javassist provides this ....
3. can I insert a statement into a specific line within a method?
for example,
public void init() {
int a = 10;
// <<<<<<< insert a statement here : a = a * a;
System.out.println(a);
}
4. can I modify a specific statement ?
for example,
public void init(int x) {
return x; //<<<<<<< modify it to: return (x * 2);
}
Would you please to show me some example about the above questions ???
Please give me a hand !!! It's very urgent for me...
Thanks a lot.
Best regadrs,
Eric
==========================
If you know what you are doing,
it is not called RESEARCH!
==========================
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org
Re: local variable problem
Posted by Simplice Djoko <Si...@imag.fr>.
Hi,
i have a problem to get the name of the local variable in a method.
i used LocalVariableTable and LocalVariable[] in this context:
ConstantPoolGen cp = mg.getConstantPool();
InstructionList il = mg.getInstructionList();
InstructionList iL = new InstructionList();
InstructionHandle[] ih = il.getInstructionHandles();
Instruction[] inst = il.getInstructions();
.
.
.
LocalVariableTable lt = mg.getLocalVariableTable(cp);
LocalVariable[] lv = lt.getLocalVariableTable();
for(int t=0; t<lv.length; t++){
if(lv[t].getName().equals( varNameSpec) && lv[t].getIndex() == ((LocalVariableInstruction)inst[j]).getIndex()){
}
But in certain case this stament is good but in another they return only arg0, arg1 who represent the parameters(depend of the number of parameters) of the method. I used also LocalVariableGen and i have thesame problems.
please help me
---------------------------------------------------------------------------------------------------------------------------------
Simplice Djoko. Equipe cadp. VERIMAG. Grenoble. France.
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org
Re: Urgent , BCEL beginner questions ???
Posted by Lalitha Vishali <la...@pramati.com>.
Hi ...
Am beginning with BCEL ... Can i plz be guided thru the first steps....
I prefer to start-off hands-on... rather than read huge docs...
thanks,
lalitha
Eric Chow wrote:
>Hi,
>
>I am going to use BCEL to do some education project.
>But I have so many problems and questions if I should use BCEL or other
>library.
>
>
>1. retrieve all the variable names and its corresponding values (global
>variables, and local variables) ?
>2. can I add a method with some source expression ??
> for example,
>
> clazzGen.addMethod(" int a = 10; System.out.println(a); "); // something
>like this, Javassist provides this ....
>
>3. can I insert a statement into a specific line within a method?
> for example,
>
> public void init() {
> int a = 10;
> // <<<<<<< insert a statement here : a = a * a;
> System.out.println(a);
> }
>
>4. can I modify a specific statement ?
> for example,
>
> public void init(int x) {
> return x; //<<<<<<< modify it to: return (x * 2);
> }
>
>
>Would you please to show me some example about the above questions ???
>Please give me a hand !!! It's very urgent for me...
>Thanks a lot.
>
>
>Best regadrs,
>Eric
>
>
>
>==========================
>If you know what you are doing,
>it is not called RESEARCH!
>==========================
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: bcel-user-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org