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 bl...@sddc.fr on 2006/01/23 17:20:35 UTC

LocalVariableTable changed on rename !

Hi,
I'm trying very simply to encapsulate a method MethodName by renaming 
original method, and create a new one calling the original; 
Very briefly:

MethodGen mgen = new MethodGen( method, name, poolgen);
cgen.removeMethod(method);
String oname = mgen.getName()+"_O";
mgen.setName( oname);
cgen.addMethod( methgen.getMethod());

Then I create the new method (nothing but call to original one);


Unfortunatly Verifier pass2 is in error because local variable table of my 
renamed method has been changed from:
....
LocalVariable(start_pc=33, length=54, index=8:..............
LocalVariable(start_pc= 89, length = 16, index=8.......
....
to

LocalVariable(start_pc= 89, length = 18, index=8.......
LocalVariable(start_pc=33, length=56, index=8:..............

giving the error At bytecode offset '89' a local variable has 2 different 
names: 'e' and 'draft'

I don't understand what could happen, please any help would be very 
welcome !
Thank you

Cordialement / Best regards 

Réf. : Re: LocalVariableTable changed on rename !

Posted by bl...@sddc.fr.
Hi Andrew,
Thank you for your suggestion, it runs now !
Honnestly, I don't really understand why... but it runs !
Thank you for help

Cordialement / Best regards  




Andrew Huntwork <as...@huntwork.net>
Envoyé par : ahuntwork@gmail.com
23/01/2006 17:25
Veuillez répondre à "BCEL Users List"
 
        Pour :  BCEL Users List <bc...@jakarta.apache.org>
        cc : 
        Objet : Re: LocalVariableTable changed on rename !


MethodGen.removeLocalVariables() or some similar api will fix you right 
up.

On 1/23/06, blanglois@sddc.fr <bl...@sddc.fr> wrote:
>
> Hi,
> I'm trying very simply to encapsulate a method MethodName by renaming
> original method, and create a new one calling the original;
> Very briefly:
>
> MethodGen mgen = new MethodGen( method, name, poolgen);
> cgen.removeMethod(method);
> String oname = mgen.getName()+"_O";
> mgen.setName( oname);
> cgen.addMethod( methgen.getMethod());
>
> Then I create the new method (nothing but call to original one);
>
>
> Unfortunatly Verifier pass2 is in error because local variable table of 
my
> renamed method has been changed from:
> ....
> LocalVariable(start_pc=33, length=54, index=8:..............
> LocalVariable(start_pc= 89, length = 16, index=8.......
> ....
> to
>
> LocalVariable(start_pc= 89, length = 18, index=8.......
> LocalVariable(start_pc=33, length=56, index=8:..............
>
> giving the error At bytecode offset '89' a local variable has 2 
different
> names: 'e' and 'draft'
>
> I don't understand what could happen, please any help would be very
> welcome !
> Thank you
>
> Cordialement / Best regards
>

Re: LocalVariableTable changed on rename !

Posted by Andrew Huntwork <as...@huntwork.net>.
MethodGen.removeLocalVariables() or some similar api will fix you right up.

On 1/23/06, blanglois@sddc.fr <bl...@sddc.fr> wrote:
>
> Hi,
> I'm trying very simply to encapsulate a method MethodName by renaming
> original method, and create a new one calling the original;
> Very briefly:
>
> MethodGen mgen = new MethodGen( method, name, poolgen);
> cgen.removeMethod(method);
> String oname = mgen.getName()+"_O";
> mgen.setName( oname);
> cgen.addMethod( methgen.getMethod());
>
> Then I create the new method (nothing but call to original one);
>
>
> Unfortunatly Verifier pass2 is in error because local variable table of my
> renamed method has been changed from:
> ....
> LocalVariable(start_pc=33, length=54, index=8:..............
> LocalVariable(start_pc= 89, length = 16, index=8.......
> ....
> to
>
> LocalVariable(start_pc= 89, length = 18, index=8.......
> LocalVariable(start_pc=33, length=56, index=8:..............
>
> giving the error At bytecode offset '89' a local variable has 2 different
> names: 'e' and 'draft'
>
> I don't understand what could happen, please any help would be very
> welcome !
> Thank you
>
> Cordialement / Best regards
>