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 Camila Rocha <ca...@hotmail.com> on 2004/02/19 03:38:08 UTC

InstructionList.delete

Hello, it's me again... :)

I'm modifiying a method push of a stack (in a .class archive) to include a post condition on it: I want to know if the 
stack.size = stack@pre.size + 1. 
To check this condition at the end of the method, I have to keep the initial value of stack.size. So, I created a local variable to keep the value:
InstructionHandle ih_3 = il.append(ih_2, factory.createStore(Type.INT, 2));

The problem is that, the code of the method uses this position (2). Translated with BCELifier:
    InstructionHandle ih_13 = il.append(_factory.createStore(Type.OBJECT, 2));
    InstructionHandle ih_14 = il.append(_factory.createLoad(Type.OBJECT, 2));
    
So, at the end, when I want to know the initial value of the stack size, it isn't there anymore. 
I tried to delete this ih_13 and ih_14 and include again, using the position 3. But it not possible, because the error "Target Lost Exception" 

What can I do?

Thanks, 
Camila 

      

Re: InstructionList.delete

Posted by Andrew Huntwork <as...@huntwork.net>.
you can do 1 of:

1.  Don't use index 2 to store the stack size

2.  IndexedInstruction.setIndex

3.  InstructionHandle.setInstruction

4. 
InstructionList.redirectBranches/redirectExceptionHandlers/redirectLocalVariables

5.  Don't use index 2 to store the stack size :)

Camila Rocha wrote:
> Hello, it's me again... :)
> 
> I'm modifiying a method push of a stack (in a .class archive) to include a post condition on it: I want to know if the 
> stack.size = stack@pre.size + 1. 
> To check this condition at the end of the method, I have to keep the initial value of stack.size. So, I created a local variable to keep the value:
> InstructionHandle ih_3 = il.append(ih_2, factory.createStore(Type.INT, 2));
> 
> The problem is that, the code of the method uses this position (2). Translated with BCELifier:
>     InstructionHandle ih_13 = il.append(_factory.createStore(Type.OBJECT, 2));
>     InstructionHandle ih_14 = il.append(_factory.createLoad(Type.OBJECT, 2));
>     
> So, at the end, when I want to know the initial value of the stack size, it isn't there anymore. 
> I tried to delete this ih_13 and ih_14 and include again, using the position 3. But it not possible, because the error "Target Lost Exception" 
> 
> What can I do?
> 
> Thanks, 
> Camila 
> 
>       

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