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 Simplice Djoko <Si...@imag.fr> on 2004/08/13 13:36:28 UTC

problem with local variable-please help me

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: problem with local variable-please help me

Posted by Andrew Huntwork <as...@huntwork.net>.
sometimes the compiler (or other code generator) produces debugging info 
like variable names (like when -g is specified), and sometimes it 
doesn't.  When it doesn't, it would seem that bcel tells you bogus 
names.  You can use javap to see what kind of debugging information is 
included in a particular class.

basically, in a lot of cases, you'll just be out of luck if you want 
local variable names.

Simplice Djoko wrote:
> 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
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org