APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.bcel.internal.generic

public Class InstructionList

extends Object
implements Iterable<InstructionHandle>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Imports
java.io.ByteArrayOutputStream, .DataOutputStream, .IOException, java.util.ArrayList, .Arrays, .HashMap, .Iterator, .List, .Map, .NoSuchElementException, com.sun.org.apache.bcel.internal.Const, com.sun.org.apache.bcel.internal.classfile.Constant, com.sun.org.apache.bcel.internal.util.ByteSequence, jdk.xml.internal.Utils

This class is a container for a list of Instruction objects. Instructions can be appended, inserted, moved, deleted, etc.. Instructions are being wrapped into InstructionHandles objects that are returned upon append/insert operations. They give the user (read only) access to the list structure, such that it can be traversed and manipulated in a controlled way. A list is finally dumped to a byte code array with getByteCode.
See Also
Instruction, InstructionHandle, BranchHandle

Field Summary

Modifier and TypeField and Description
private int[]
private InstructionHandle
private int
private List<InstructionListObserver>
private InstructionHandle

Constructor Summary

AccessConstructor and Description
public
InstructionList()

Create (empty) instruction list.

public
InstructionList(final BranchInstruction
initial instruction
i
)

Create instruction list containing one instruction.

public
InstructionList(final byte[]
byte array containing the instructions
code
)

Initialize instruction list from byte array.

public
InstructionList(final CompoundInstruction
compound instruction (list)
c
)

Initialize list with (nonnull) compound instruction.

public
InstructionList(final Instruction
initial instruction
i
)

Create instruction list containing one instruction.

Method Summary

Modifier and TypeMethod and Description
public void
addObserver(final InstructionListObserver o)

Add observer for this object.

public BranchHandle

Returns:

branch instruction handle of the appended instruction
append
(final BranchInstruction
branch instruction to append
i
)

Append a branch instruction to the end of this list.

public InstructionHandle

Returns:

instruction handle of the first appended instruction
append
(final CompoundInstruction
The composite instruction (containing an InstructionList)
c
)

Append a compound instruction.

public InstructionHandle

Returns:

instruction handle of the appended instruction
append
(final Instruction
instruction to append
i
)

Append an instruction to the end of this list.

public InstructionHandle

Returns:

instruction handle of the first appended instruction
append
(final Instruction
Instruction in list
i
,
final CompoundInstruction
The composite instruction (containing an InstructionList)
c
)

Append a compound instruction, after instruction i.

public InstructionHandle

Returns:

instruction handle of the first appended instruction
append
(final Instruction
Instruction in list
i
,
final Instruction
Instruction to append after i in list
j
)

Append a single instruction j after another instruction i, which must be in this list of course!

public InstructionHandle

Returns:

instruction handle pointing to the first appended instruction
append
(final Instruction
where to append the instruction list
i
,
final InstructionList
Instruction list to append to this one
il
)

Append another list after instruction i contained in this list.

private void
append(final InstructionHandle
instruction to append
ih
)

Append an instruction to the end of this list.

public BranchHandle

Returns:

instruction handle pointing to the first appended instruction
append
(final InstructionHandle
where to append the instruction list
ih
,
final BranchInstruction
Instruction to append
i
)

Append an instruction after instruction (handle) ih contained in this list.

public InstructionHandle

Returns:

instruction handle of the first appended instruction
append
(final InstructionHandle
where to append the instruction list
ih
,
final CompoundInstruction
The composite instruction (containing an InstructionList)
c
)

Append a compound instruction.

public InstructionHandle

Returns:

instruction handle pointing to the first appended instruction
append
(final InstructionHandle
where to append the instruction list
ih
,
final Instruction
Instruction to append
i
)

Append an instruction after instruction (handle) ih contained in this list.

public InstructionHandle

Returns:

instruction handle pointing to the first appended instruction
append
(final InstructionHandle
where to append the instruction list
ih
,
final InstructionList
Instruction list to append to this one
il
)

Append another list after instruction (handle) ih contained in this list.

public InstructionHandle

Returns:

instruction handle of the first appended instruction
append
(final InstructionList
list to append to end of this list
il
)

Append another list to this one.

private void
public boolean
public boolean
public InstructionList
copy()

Returns: complete, i.e., deep copy of this list

public void
delete(final Instruction
instruction to remove
i
)

Remove instruction from this list.

public void
delete(final Instruction
where to start deleting (inclusive)
from
,
final Instruction
where to end deleting (inclusive)
to
)

Remove instructions from instruction 'from' to instruction 'to' contained in this list.

public void
delete(final InstructionHandle
instruction (handle) to remove
ih
)

Remove instruction from this list.

public void
delete(final InstructionHandle
where to start deleting (inclusive)
from
,
final InstructionHandle
where to end deleting (inclusive)
to
)

Remove instructions from instruction 'from' to instruction 'to' contained in this list.

public void
dispose()

Delete contents of list.

public static InstructionHandle

Returns:

target position's instruction handle if available
findHandle
(final InstructionHandle[]
array of instruction handles, i.e. il.getInstructionHandles()
ihs
,
final int[]
array of positions corresponding to ihs, i.e. il.getInstructionPositions()
pos
,
final int
length of arrays
count
,
final int
target position to search for
target
)

Find the target instruction (handle) that corresponds to the given target position (byte code offset).

public InstructionHandle

Returns:

target position's instruction handle if available
findHandle
(final int
byte code position to search for
pos
)

Gets instruction handle for instruction at byte code position pos.

private InstructionHandle

Returns:

instruction found on success, null otherwise
findInstruction1
(final Instruction
instruction to search for
i
)

Search for given Instruction reference, start at beginning of list.

private InstructionHandle

Returns:

instruction found on success, null otherwise
findInstruction2
(final Instruction
instruction to search for
i
)

Search for given Instruction reference, start at end of list

public byte[]

Returns:

the byte code ready to be dumped
getByteCode
()

When everything is finished, use this method to convert the instruction list into an array of bytes.

public InstructionHandle
getEnd()

Returns: end of list

public InstructionHandle[]
getInstructionHandles()

Returns: array containing all instructions (handles)

public int[]

Returns:

array containing all instruction's offset in byte code
getInstructionPositions
()

Gets positions (offsets) of all instructions in the list.

public Instruction[]
getInstructions()

Returns: an array of instructions without target information for branch instructions.

public int
getLength()

Returns: length of list (Number of instructions, not bytes)

public InstructionHandle
getStart()

Returns: start of list

public BranchHandle

Returns:

branch instruction handle of the appended instruction
insert
(final BranchInstruction
branch instruction to insert
i
)

Insert a branch instruction at start of this list.

public InstructionHandle

Returns:

instruction handle of the first inserted instruction
insert
(final CompoundInstruction
The composite instruction (containing an InstructionList)
c
)

Insert a compound instruction.

public InstructionHandle

Returns:

instruction handle of the inserted instruction
insert
(final Instruction
instruction to insert
i
)

Insert an instruction at start of this list.

public InstructionHandle

Returns:

instruction handle of the first inserted instruction
insert
(final Instruction
Instruction in list
i
,
final CompoundInstruction
The composite instruction (containing an InstructionList)
c
)

Insert a compound instruction before instruction i.

public InstructionHandle

Returns:

instruction handle of the first inserted instruction
insert
(final Instruction
Instruction in list
i
,
final Instruction
Instruction to insert before i in list
j
)

Insert a single instruction j before another instruction i, which must be in this list of course!

public InstructionHandle

Returns:

instruction handle pointing to the first inserted instruction, i.e., il.getStart()
insert
(final Instruction
where to append the instruction list
i
,
final InstructionList
Instruction list to insert
il
)

Insert another list before Instruction i contained in this list.

private void
insert(final InstructionHandle
instruction to insert
ih
)

Insert an instruction at start of this list.

public BranchHandle

Returns:

instruction handle of the first inserted instruction
insert
(final InstructionHandle
where to insert to the instruction list
ih
,
final BranchInstruction
Instruction to insert
i
)

Insert an instruction before instruction (handle) ih contained in this list.

public InstructionHandle

Returns:

instruction handle of the first inserted instruction
insert
(final InstructionHandle
where to insert the instruction list
ih
,
final CompoundInstruction
The composite instruction (containing an InstructionList)
c
)

Insert a compound instruction.

public InstructionHandle

Returns:

instruction handle of the first inserted instruction
insert
(final InstructionHandle
where to insert to the instruction list
ih
,
final Instruction
Instruction to insert
i
)

Insert an instruction before instruction (handle) ih contained in this list.

public InstructionHandle

Returns:

instruction handle of the first inserted instruction
insert
(final InstructionHandle
where to append the instruction list
ih
,
final InstructionList
Instruction list to insert
il
)

Insert another list before Instruction handle ih contained in this list.

public InstructionHandle

Returns:

instruction handle of the first inserted instruction
insert
(final InstructionList
list to insert before start of this list
il
)

Insert another list.

public boolean
isEmpty()

Test for empty list.

public Iterator<InstructionHandle>

Returns:

iterator that lists all instructions (handles)
iterator
()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

public void
move(final InstructionHandle
moved instruction
ih
,
final InstructionHandle
new location of moved instruction
target
)

Move a single instruction (handle) to a new location.

public void
move(final InstructionHandle
of moved block
start
,
final InstructionHandle
of moved block
end
,
final InstructionHandle
of moved block
target
)

Take all instructions (handles) from "start" to "end" and append them after the new location "target".

public void
redirectBranches(final InstructionHandle
the old target instruction handle
oldTarget
,
final InstructionHandle
the new target instruction handle
newTarget
)

Redirect all references from oldTarget to newTarget, i.e., update targets of branch instructions.

public void
redirectExceptionHandlers(final CodeExceptionGen[]
array of exception handlers
exceptions
,
final InstructionHandle
the old target instruction handle
oldTarget
,
final InstructionHandle
the new target instruction handle
newTarget
)

Redirect all references of exception handlers from oldTarget to newTarget.

public void
redirectLocalVariables(final LocalVariableGen[]
array of local variables
lg
,
final InstructionHandle
the old target instruction handle
oldTarget
,
final InstructionHandle
the new target instruction handle
newTarget
)

Redirect all references of local variables from oldTarget to newTarget.

private void
remove(final InstructionHandle
where to start deleting (predecessor, exclusive)
prev
,
InstructionHandle
where to end deleting (successor, exclusive)
next
)

Remove from instruction 'prev' to instruction 'next' both contained in this list.

public void
removeObserver(final InstructionListObserver o)

Remove observer for this object.

public void
replaceConstantPool(final ConstantPoolGen oldCp, final ConstantPoolGen newCp)

Replace all references to the old constant pool with references to the new constant pool

public void
public void
setPositions(final boolean
Perform sanity checks, e.g. if all targeted instructions really belong to this list
check
)

Give all instructions their position number (offset in byte stream), i.e., make the list ready to be dumped.

public int
size()

Returns: length of list (Number of instructions, not bytes)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public String
toString(final boolean
toggle output format
verbose
)

Returns: String containing all instructions in this list.

public void
update()

Call notify() method on all observers.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bytePositionsback to summary
private int[] bytePositions
endback to summary
private InstructionHandle end
lengthback to summary
private int length
observersback to summary
private List<InstructionListObserver> observers
startback to summary
private InstructionHandle start

Constructor Detail

InstructionListback to summary
public InstructionList()

Create (empty) instruction list.

InstructionListback to summary
public InstructionList(final BranchInstruction i)

Create instruction list containing one instruction.

Parameters
i:BranchInstruction

initial instruction

InstructionListback to summary
public InstructionList(final byte[] code)

Initialize instruction list from byte array.

Parameters
code:byte[]

byte array containing the instructions

InstructionListback to summary
public InstructionList(final CompoundInstruction c)

Initialize list with (nonnull) compound instruction. Consumes argument list, i.e., it becomes empty.

Parameters
c:CompoundInstruction

compound instruction (list)

InstructionListback to summary
public InstructionList(final Instruction i)

Create instruction list containing one instruction.

Parameters
i:Instruction

initial instruction

Method Detail

addObserverback to summary
public void addObserver(final InstructionListObserver o)

Add observer for this object.

appendback to summary
public BranchHandle append(final BranchInstruction i)

Append a branch instruction to the end of this list.

Parameters
i:BranchInstruction

branch instruction to append

Returns:BranchHandle

branch instruction handle of the appended instruction

appendback to summary
public InstructionHandle append(final CompoundInstruction c)

Append a compound instruction.

Parameters
c:CompoundInstruction

The composite instruction (containing an InstructionList)

Returns:InstructionHandle

instruction handle of the first appended instruction

appendback to summary
public InstructionHandle append(final Instruction i)

Append an instruction to the end of this list.

Parameters
i:Instruction

instruction to append

Returns:InstructionHandle

instruction handle of the appended instruction

appendback to summary
public InstructionHandle append(final Instruction i, final CompoundInstruction c)

Append a compound instruction, after instruction i.

Parameters
i:Instruction

Instruction in list

c:CompoundInstruction

The composite instruction (containing an InstructionList)

Returns:InstructionHandle

instruction handle of the first appended instruction

appendback to summary
public InstructionHandle append(final Instruction i, final Instruction j)

Append a single instruction j after another instruction i, which must be in this list of course!

Parameters
i:Instruction

Instruction in list

j:Instruction

Instruction to append after i in list

Returns:InstructionHandle

instruction handle of the first appended instruction

appendback to summary
public InstructionHandle append(final Instruction i, final InstructionList il)

Append another list after instruction i contained in this list. Consumes argument list, i.e., it becomes empty.

Parameters
i:Instruction

where to append the instruction list

il:InstructionList

Instruction list to append to this one

Returns:InstructionHandle

instruction handle pointing to the first appended instruction

appendback to summary
private void append(final InstructionHandle ih)

Append an instruction to the end of this list.

Parameters
ih:InstructionHandle

instruction to append

appendback to summary
public BranchHandle append(final InstructionHandle ih, final BranchInstruction i)

Append an instruction after instruction (handle) ih contained in this list.

Parameters
ih:InstructionHandle

where to append the instruction list

i:BranchInstruction

Instruction to append

Returns:BranchHandle

instruction handle pointing to the first appended instruction

appendback to summary
public InstructionHandle append(final InstructionHandle ih, final CompoundInstruction c)

Append a compound instruction.

Parameters
ih:InstructionHandle

where to append the instruction list

c:CompoundInstruction

The composite instruction (containing an InstructionList)

Returns:InstructionHandle

instruction handle of the first appended instruction

appendback to summary
public InstructionHandle append(final InstructionHandle ih, final Instruction i)

Append an instruction after instruction (handle) ih contained in this list.

Parameters
ih:InstructionHandle

where to append the instruction list

i:Instruction

Instruction to append

Returns:InstructionHandle

instruction handle pointing to the first appended instruction

appendback to summary
public InstructionHandle append(final InstructionHandle ih, final InstructionList il)

Append another list after instruction (handle) ih contained in this list. Consumes argument list, i.e., it becomes empty.

Parameters
ih:InstructionHandle

where to append the instruction list

il:InstructionList

Instruction list to append to this one

Returns:InstructionHandle

instruction handle pointing to the first appended instruction

appendback to summary
public InstructionHandle append(final InstructionList il)

Append another list to this one. Consumes argument list, i.e., it becomes empty.

Parameters
il:InstructionList

list to append to end of this list

Returns:InstructionHandle

instruction handle of the first appended instruction

clearback to summary
private void clear()
containsback to summary
public boolean contains(final Instruction i)
containsback to summary
public boolean contains(final InstructionHandle i)
copyback to summary
public InstructionList copy()
Returns:InstructionList

complete, i.e., deep copy of this list

deleteback to summary
public void delete(final Instruction i) throws TargetLostException

Remove instruction from this list. The corresponding Instruction handles must not be reused!

Parameters
i:Instruction

instruction to remove

deleteback to summary
public void delete(final Instruction from, final Instruction to) throws TargetLostException

Remove instructions from instruction 'from' to instruction 'to' contained in this list. The user must ensure that 'from' is an instruction before 'to', or risk havoc. The corresponding Instruction handles must not be reused!

Parameters
from:Instruction

where to start deleting (inclusive)

to:Instruction

where to end deleting (inclusive)

deleteback to summary
public void delete(final InstructionHandle ih) throws TargetLostException

Remove instruction from this list. The corresponding Instruction handles must not be reused!

Parameters
ih:InstructionHandle

instruction (handle) to remove

deleteback to summary
public void delete(final InstructionHandle from, final InstructionHandle to) throws TargetLostException

Remove instructions from instruction 'from' to instruction 'to' contained in this list. The user must ensure that 'from' is an instruction before 'to', or risk havoc. The corresponding Instruction handles must not be reused!

Parameters
from:InstructionHandle

where to start deleting (inclusive)

to:InstructionHandle

where to end deleting (inclusive)

disposeback to summary
public void dispose()

Delete contents of list. Provides better memory utilization, because the system then may reuse the instruction handles. This method is typically called right after MethodGen#getMethod().

findHandleback to summary
public static InstructionHandle findHandle(final InstructionHandle[] ihs, final int[] pos, final int count, final int target)

Find the target instruction (handle) that corresponds to the given target position (byte code offset).

Parameters
ihs:InstructionHandle[]

array of instruction handles, i.e. il.getInstructionHandles()

pos:int[]

array of positions corresponding to ihs, i.e. il.getInstructionPositions()

count:int

length of arrays

target:int

target position to search for

Returns:InstructionHandle

target position's instruction handle if available

findHandleback to summary
public InstructionHandle findHandle(final int pos)

Gets instruction handle for instruction at byte code position pos. This only works properly, if the list is freshly initialized from a byte array or setPositions() has been called before this method.

Parameters
pos:int

byte code position to search for

Returns:InstructionHandle

target position's instruction handle if available

findInstruction1back to summary
private InstructionHandle findInstruction1(final Instruction i)

Search for given Instruction reference, start at beginning of list.

Parameters
i:Instruction

instruction to search for

Returns:InstructionHandle

instruction found on success, null otherwise

findInstruction2back to summary
private InstructionHandle findInstruction2(final Instruction i)

Search for given Instruction reference, start at end of list

Parameters
i:Instruction

instruction to search for

Returns:InstructionHandle

instruction found on success, null otherwise

getByteCodeback to summary
public byte[] getByteCode()

When everything is finished, use this method to convert the instruction list into an array of bytes.

Returns:byte[]

the byte code ready to be dumped

getEndback to summary
public InstructionHandle getEnd()
Returns:InstructionHandle

end of list

getInstructionHandlesback to summary
public InstructionHandle[] getInstructionHandles()
Returns:InstructionHandle[]

array containing all instructions (handles)

getInstructionPositionsback to summary
public int[] getInstructionPositions()

Gets positions (offsets) of all instructions in the list. This relies on that the list has been freshly created from an byte code array, or that setPositions() has been called. Otherwise this may be inaccurate.

Returns:int[]

array containing all instruction's offset in byte code

getInstructionsback to summary
public Instruction[] getInstructions()
Returns:Instruction[]

an array of instructions without target information for branch instructions.

getLengthback to summary
public int getLength()
Returns:int

length of list (Number of instructions, not bytes)

getStartback to summary
public InstructionHandle getStart()
Returns:InstructionHandle

start of list

insertback to summary
public BranchHandle insert(final BranchInstruction i)

Insert a branch instruction at start of this list.

Parameters
i:BranchInstruction

branch instruction to insert

Returns:BranchHandle

branch instruction handle of the appended instruction

insertback to summary
public InstructionHandle insert(final CompoundInstruction c)

Insert a compound instruction.

Parameters
c:CompoundInstruction

The composite instruction (containing an InstructionList)

Returns:InstructionHandle

instruction handle of the first inserted instruction

insertback to summary
public InstructionHandle insert(final Instruction i)

Insert an instruction at start of this list.

Parameters
i:Instruction

instruction to insert

Returns:InstructionHandle

instruction handle of the inserted instruction

insertback to summary
public InstructionHandle insert(final Instruction i, final CompoundInstruction c)

Insert a compound instruction before instruction i.

Parameters
i:Instruction

Instruction in list

c:CompoundInstruction

The composite instruction (containing an InstructionList)

Returns:InstructionHandle

instruction handle of the first inserted instruction

insertback to summary
public InstructionHandle insert(final Instruction i, final Instruction j)

Insert a single instruction j before another instruction i, which must be in this list of course!

Parameters
i:Instruction

Instruction in list

j:Instruction

Instruction to insert before i in list

Returns:InstructionHandle

instruction handle of the first inserted instruction

insertback to summary
public InstructionHandle insert(final Instruction i, final InstructionList il)

Insert another list before Instruction i contained in this list. Consumes argument list, i.e., it becomes empty.

Parameters
i:Instruction

where to append the instruction list

il:InstructionList

Instruction list to insert

Returns:InstructionHandle

instruction handle pointing to the first inserted instruction, i.e., il.getStart()

insertback to summary
private void insert(final InstructionHandle ih)

Insert an instruction at start of this list.

Parameters
ih:InstructionHandle

instruction to insert

insertback to summary
public BranchHandle insert(final InstructionHandle ih, final BranchInstruction i)

Insert an instruction before instruction (handle) ih contained in this list.

Parameters
ih:InstructionHandle

where to insert to the instruction list

i:BranchInstruction

Instruction to insert

Returns:BranchHandle

instruction handle of the first inserted instruction

insertback to summary
public InstructionHandle insert(final InstructionHandle ih, final CompoundInstruction c)

Insert a compound instruction.

Parameters
ih:InstructionHandle

where to insert the instruction list

c:CompoundInstruction

The composite instruction (containing an InstructionList)

Returns:InstructionHandle

instruction handle of the first inserted instruction

insertback to summary
public InstructionHandle insert(final InstructionHandle ih, final Instruction i)

Insert an instruction before instruction (handle) ih contained in this list.

Parameters
ih:InstructionHandle

where to insert to the instruction list

i:Instruction

Instruction to insert

Returns:InstructionHandle

instruction handle of the first inserted instruction

insertback to summary
public InstructionHandle insert(final InstructionHandle ih, final InstructionList il)

Insert another list before Instruction handle ih contained in this list. Consumes argument list, i.e., it becomes empty.

Parameters
ih:InstructionHandle

where to append the instruction list

il:InstructionList

Instruction list to insert

Returns:InstructionHandle

instruction handle of the first inserted instruction

insertback to summary
public InstructionHandle insert(final InstructionList il)

Insert another list.

Parameters
il:InstructionList

list to insert before start of this list

Returns:InstructionHandle

instruction handle of the first inserted instruction

isEmptyback to summary
public boolean isEmpty()

Test for empty list.

iteratorback to summary
public Iterator<InstructionHandle> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<InstructionHandle>

iterator that lists all instructions (handles)

Annotations
@Override
moveback to summary
public void move(final InstructionHandle ih, final InstructionHandle target)

Move a single instruction (handle) to a new location.

Parameters
ih:InstructionHandle

moved instruction

target:InstructionHandle

new location of moved instruction

moveback to summary
public void move(final InstructionHandle start, final InstructionHandle end, final InstructionHandle target)

Take all instructions (handles) from "start" to "end" and append them after the new location "target". Of course, "end" must be after "start" and target must not be located withing this range. If you want to move something to the start of the list use null as value for target.

Any instruction targeters pointing to handles within the block, keep their targets.

Parameters
start:InstructionHandle

of moved block

end:InstructionHandle

of moved block

target:InstructionHandle

of moved block

redirectBranchesback to summary
public void redirectBranches(final InstructionHandle oldTarget, final InstructionHandle newTarget)

Redirect all references from oldTarget to newTarget, i.e., update targets of branch instructions.

Parameters
oldTarget:InstructionHandle

the old target instruction handle

newTarget:InstructionHandle

the new target instruction handle

redirectExceptionHandlersback to summary
public void redirectExceptionHandlers(final CodeExceptionGen[] exceptions, final InstructionHandle oldTarget, final InstructionHandle newTarget)

Redirect all references of exception handlers from oldTarget to newTarget.

Parameters
exceptions:CodeExceptionGen[]

array of exception handlers

oldTarget:InstructionHandle

the old target instruction handle

newTarget:InstructionHandle

the new target instruction handle

See Also
MethodGen
redirectLocalVariablesback to summary
public void redirectLocalVariables(final LocalVariableGen[] lg, final InstructionHandle oldTarget, final InstructionHandle newTarget)

Redirect all references of local variables from oldTarget to newTarget.

Parameters
lg:LocalVariableGen[]

array of local variables

oldTarget:InstructionHandle

the old target instruction handle

newTarget:InstructionHandle

the new target instruction handle

See Also
MethodGen
removeback to summary
private void remove(final InstructionHandle prev, InstructionHandle next) throws TargetLostException

Remove from instruction 'prev' to instruction 'next' both contained in this list. Throws TargetLostException when one of the removed instruction handles is still being targeted.

Parameters
prev:InstructionHandle

where to start deleting (predecessor, exclusive)

next:InstructionHandle

where to end deleting (successor, exclusive)

removeObserverback to summary
public void removeObserver(final InstructionListObserver o)

Remove observer for this object.

replaceConstantPoolback to summary
public void replaceConstantPool(final ConstantPoolGen oldCp, final ConstantPoolGen newCp)

Replace all references to the old constant pool with references to the new constant pool

setPositionsback to summary
public void setPositions()
setPositionsback to summary
public void setPositions(final boolean check)

Give all instructions their position number (offset in byte stream), i.e., make the list ready to be dumped.

Parameters
check:boolean

Perform sanity checks, e.g. if all targeted instructions really belong to this list

sizeback to summary
public int size()
Returns:int

length of list (Number of instructions, not bytes)

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
toStringback to summary
public String toString(final boolean verbose)
Parameters
verbose:boolean

toggle output format

Returns:String

String containing all instructions in this list.

updateback to summary
public void update()

Call notify() method on all observers. This method is not called automatically whenever the state has changed, but has to be called by the user after he has finished editing the object.