Top Description Inners Fields Constructors Methods
org.objectweb.asm.tree

public Class InsnList

extends Object
implements Iterable<AbstractInsnNode>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Imports
java.util.ListIterator, .NoSuchElementException, org.objectweb.asm.MethodVisitor

A doubly linked list of AbstractInsnNode objects. This implementation is not thread safe.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
pack-priv AbstractInsnNode[]
cache

A cache of the instructions of this list.

private AbstractInsnNode
firstInsn

The first instruction in this list.

private AbstractInsnNode
lastInsn

The last instruction in this list.

private int
size

The number of instructions in this list.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
accept(final MethodVisitor
the method visitor that must visit the instructions.
methodVisitor
)

Makes the given visitor visit all the instructions in this list.

public void
add(final AbstractInsnNode
an instruction, which must not belong to any InsnList.
insnNode
)

Adds the given instruction to the end of this list.

public void
add(final InsnList
an instruction list, which is cleared during the process. This list must be different from 'this'.
insnList
)

Adds the given instructions to the end of this list.

public void
clear()

Removes all the instructions of this list.

public boolean

Returns:

true if the given instruction belongs to this list.
contains
(final AbstractInsnNode
an instruction.
insnNode
)

Returns true if the given instruction belongs to this list.

public AbstractInsnNode

Returns:

the instruction whose index is given.
get
(final int
the index of the instruction that must be returned.
index
)

Returns the instruction whose index is given.

public AbstractInsnNode

Returns:

the first instruction in this list, or null if the list is empty.
getFirst
()

Returns the first instruction in this list.

public AbstractInsnNode

Returns:

the last instruction in this list, or null if the list is empty.
getLast
()

Returns the last instruction in this list.

public int

Returns:

the index of the given instruction in this list. The result of this method is undefined if the given instruction does not belong to this list. Use contains to test if an instruction belongs to an instruction list or not.
indexOf
(final AbstractInsnNode
an instruction of this list.
insnNode
)

Returns the index of the given instruction in this list.

public void
insert(final AbstractInsnNode
an instruction, which must not belong to any InsnList.
insnNode
)

Inserts the given instruction at the beginning of this list.

public void
insert(final InsnList
an instruction list, which is cleared during the process. This list must be different from 'this'.
insnList
)

Inserts the given instructions at the beginning of this list.

public void
insert(final AbstractInsnNode
an instruction of this list after which insnNode must be inserted.
previousInsn
,
final AbstractInsnNode
the instruction to be inserted, which must not belong to any InsnList.
insnNode
)

Inserts the given instruction after the specified instruction.

public void
insert(final AbstractInsnNode
an instruction of this list after which the instructions must be inserted.
previousInsn
,
final InsnList
the instruction list to be inserted, which is cleared during the process. This list must be different from 'this'.
insnList
)

Inserts the given instructions after the specified instruction.

public void
insertBefore(final AbstractInsnNode
an instruction of this list before which insnNode must be inserted.
nextInsn
,
final AbstractInsnNode
the instruction to be inserted, which must not belong to any InsnList.
insnNode
)

Inserts the given instruction before the specified instruction.

public void
insertBefore(final AbstractInsnNode
an instruction of this list before which the instructions must be inserted.
nextInsn
,
final InsnList
the instruction list to be inserted, which is cleared during the process. This list must be different from 'this'.
insnList
)

Inserts the given instructions before the specified instruction.

public ListIterator<AbstractInsnNode>

Returns:

an iterator over the instructions in this list.
iterator
()

Implements java.lang.Iterable.iterator.

Returns an iterator over the instructions in this list.
public ListIterator<AbstractInsnNode>

Returns:

an iterator over the instructions in this list.
iterator
(final int
index of instruction for the iterator to start at.
index
)

Returns an iterator over the instructions in this list.

public void
remove(final AbstractInsnNode
the instruction of this list that must be removed.
insnNode
)

Removes the given instruction from this list.

pack-priv void
removeAll(final boolean
if the instructions must be marked as no longer belonging to any InsnList.
mark
)

Removes all the instructions of this list.

public void
resetLabels()

Resets all the labels in the instruction list.

public void
set(final AbstractInsnNode
an instruction of this list.
oldInsnNode
,
final AbstractInsnNode
another instruction, which must not belong to any InsnList.
newInsnNode
)

Replaces an instruction of this list with another instruction.

public int

Returns:

the number of instructions in this list.
size
()

Returns the number of instructions in this list.

public AbstractInsnNode[]

Returns:

an array containing all the instructions in this list.
toArray
()

Returns an array containing all the instructions in this list.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
pack-priv AbstractInsnNode[] cache

A cache of the instructions of this list. This cache is used to improve the performance of the get method.

firstInsnback to summary
private AbstractInsnNode firstInsn

The first instruction in this list. May be null.

lastInsnback to summary
private AbstractInsnNode lastInsn

The last instruction in this list. May be null.

sizeback to summary
private int size

The number of instructions in this list.

Constructor Detail

InsnListback to summary
public InsnList()

Method Detail

acceptback to summary
public void accept(final MethodVisitor methodVisitor)

Makes the given visitor visit all the instructions in this list.

Parameters
methodVisitor:MethodVisitor

the method visitor that must visit the instructions.

addback to summary
public void add(final AbstractInsnNode insnNode)

Adds the given instruction to the end of this list.

Parameters
insnNode:AbstractInsnNode

an instruction, which must not belong to any InsnList.

addback to summary
public void add(final InsnList insnList)

Adds the given instructions to the end of this list.

Parameters
insnList:InsnList

an instruction list, which is cleared during the process. This list must be different from 'this'.

clearback to summary
public void clear()

Removes all the instructions of this list.

containsback to summary
public boolean contains(final AbstractInsnNode insnNode)

Returns true if the given instruction belongs to this list. This method always scans the instructions of this list until it finds the given instruction or reaches the end of the list.

Parameters
insnNode:AbstractInsnNode

an instruction.

Returns:boolean

true if the given instruction belongs to this list.

getback to summary
public AbstractInsnNode get(final int index)

Returns the instruction whose index is given. This method builds a cache of the instructions in this list to avoid scanning the whole list each time it is called. Once the cache is built, this method runs in constant time. This cache is invalidated by all the methods that modify the list.

Parameters
index:int

the index of the instruction that must be returned.

Returns:AbstractInsnNode

the instruction whose index is given.

Exceptions
IndexOutOfBoundsException:
if (index < 0 || index >= size()).
getFirstback to summary
public AbstractInsnNode getFirst()

Returns the first instruction in this list.

Returns:AbstractInsnNode

the first instruction in this list, or null if the list is empty.

getLastback to summary
public AbstractInsnNode getLast()

Returns the last instruction in this list.

Returns:AbstractInsnNode

the last instruction in this list, or null if the list is empty.

indexOfback to summary
public int indexOf(final AbstractInsnNode insnNode)

Returns the index of the given instruction in this list. This method builds a cache of the instruction indexes to avoid scanning the whole list each time it is called. Once the cache is built, this method run in constant time. The cache is invalidated by all the methods that modify the list.

Parameters
insnNode:AbstractInsnNode

an instruction of this list.

Returns:int

the index of the given instruction in this list. The result of this method is undefined if the given instruction does not belong to this list. Use contains to test if an instruction belongs to an instruction list or not.

insertback to summary
public void insert(final AbstractInsnNode insnNode)

Inserts the given instruction at the beginning of this list.

Parameters
insnNode:AbstractInsnNode

an instruction, which must not belong to any InsnList.

insertback to summary
public void insert(final InsnList insnList)

Inserts the given instructions at the beginning of this list.

Parameters
insnList:InsnList

an instruction list, which is cleared during the process. This list must be different from 'this'.

insertback to summary
public void insert(final AbstractInsnNode previousInsn, final AbstractInsnNode insnNode)

Inserts the given instruction after the specified instruction.

Parameters
previousInsn:AbstractInsnNode

an instruction of this list after which insnNode must be inserted.

insnNode:AbstractInsnNode

the instruction to be inserted, which must not belong to any InsnList.

insertback to summary
public void insert(final AbstractInsnNode previousInsn, final InsnList insnList)

Inserts the given instructions after the specified instruction.

Parameters
previousInsn:AbstractInsnNode

an instruction of this list after which the instructions must be inserted.

insnList:InsnList

the instruction list to be inserted, which is cleared during the process. This list must be different from 'this'.

insertBeforeback to summary
public void insertBefore(final AbstractInsnNode nextInsn, final AbstractInsnNode insnNode)

Inserts the given instruction before the specified instruction.

Parameters
nextInsn:AbstractInsnNode

an instruction of this list before which insnNode must be inserted.

insnNode:AbstractInsnNode

the instruction to be inserted, which must not belong to any InsnList.

insertBeforeback to summary
public void insertBefore(final AbstractInsnNode nextInsn, final InsnList insnList)

Inserts the given instructions before the specified instruction.

Parameters
nextInsn:AbstractInsnNode

an instruction of this list before which the instructions must be inserted.

insnList:InsnList

the instruction list to be inserted, which is cleared during the process. This list must be different from 'this'.

iteratorback to summary
public ListIterator<AbstractInsnNode> iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over the instructions in this list.

Returns:ListIterator<AbstractInsnNode>

an iterator over the instructions in this list.

Annotations
@Override
iteratorback to summary
public ListIterator<AbstractInsnNode> iterator(final int index)

Returns an iterator over the instructions in this list.

Parameters
index:int

index of instruction for the iterator to start at.

Returns:ListIterator<AbstractInsnNode>

an iterator over the instructions in this list.

Annotations
@SuppressWarnings:unchecked
removeback to summary
public void remove(final AbstractInsnNode insnNode)

Removes the given instruction from this list.

Parameters
insnNode:AbstractInsnNode

the instruction of this list that must be removed.

removeAllback to summary
pack-priv void removeAll(final boolean mark)

Removes all the instructions of this list.

Parameters
mark:boolean

if the instructions must be marked as no longer belonging to any InsnList.

resetLabelsback to summary
public void resetLabels()

Resets all the labels in the instruction list. This method should be called before reusing an instruction list between several ClassWriters.

setback to summary
public void set(final AbstractInsnNode oldInsnNode, final AbstractInsnNode newInsnNode)

Replaces an instruction of this list with another instruction.

Parameters
oldInsnNode:AbstractInsnNode

an instruction of this list.

newInsnNode:AbstractInsnNode

another instruction, which must not belong to any InsnList.

sizeback to summary
public int size()

Returns the number of instructions in this list.

Returns:int

the number of instructions in this list.

toArrayback to summary
public AbstractInsnNode[] toArray()

Returns an array containing all the instructions in this list.

Returns:AbstractInsnNode[]

an array containing all the instructions in this list.

org.objectweb.asm.tree back to summary

private final Class InsnList.InsnListIterator

extends Object
implements ListIterator
Class Inheritance
All Implemented Interfaces
java.util.ListIterator, java.util.Iterator
Annotations
@SuppressWarnings:rawtypes

Field Summary

Modifier and TypeField and Description
pack-priv AbstractInsnNode
pack-priv AbstractInsnNode
pack-priv AbstractInsnNode

Constructor Summary

AccessConstructor and Description
pack-priv
InsnListIterator(final int index)

Method Summary

Modifier and TypeMethod and Description
public void
add(final Object
the element to insert
o
)

Implements java.util.ListIterator.add.

Inserts the specified element into the list (optional operation).
public boolean
hasNext()

Implements java.util.ListIterator.hasNext.

Returns true if this list iterator has more elements when traversing the list in the forward direction.
public boolean
hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction.
public Object
next()

Implements java.util.ListIterator.next.

Returns the next element in the list and advances the cursor position.
public int
nextIndex()

Implements java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next.
public Object
previous()

Implements java.util.ListIterator.previous.

Returns the previous element in the list and moves the cursor position backwards.
public int
previousIndex()

Implements java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous.
public void
remove()

Implements java.util.ListIterator.remove.

Removes from the list the last element that was returned by next or previous (optional operation).
public void
set(final Object
the element with which to replace the last element returned by next or previous
o
)

Implements java.util.ListIterator.set.

Replaces the last element returned by next or previous with the specified element (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nextInsnback to summary
pack-priv AbstractInsnNode nextInsn
previousInsnback to summary
pack-priv AbstractInsnNode previousInsn
removeback to summary
pack-priv AbstractInsnNode remove

Constructor Detail

InsnListIteratorback to summary
pack-priv InsnListIterator(final int index)

Method Detail

addback to summary
public void add(final Object o)

Implements java.util.ListIterator.add.

Doc from java.util.ListIterator.add.

Inserts the specified element into the list (optional operation). The element is inserted immediately before the element that would be returned by next, if any, and after the element that would be returned by previous, if any. (If the list contains no elements, the new element becomes the sole element on the list.) The new element is inserted before the implicit cursor: a subsequent call to next would be unaffected, and a subsequent call to previous would return the new element. (This call increases by one the value that would be returned by a call to nextIndex or previousIndex.)

Parameters
o:Object

the element to insert

Annotations
@Override
hasNextback to summary
public boolean hasNext()

Implements java.util.ListIterator.hasNext.

Doc from java.util.ListIterator.hasNext.

Returns true if this list iterator has more elements when traversing the list in the forward direction. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the list iterator has more elements when traversing the list in the forward direction

Annotations
@Override
hasPreviousback to summary
public boolean hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Doc from java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction. (In other words, returns true if previous would return an element rather than throwing an exception.)

Returns:boolean

true if the list iterator has more elements when traversing the list in the reverse direction

Annotations
@Override
nextback to summary
public Object next()

Implements java.util.ListIterator.next.

Doc from java.util.ListIterator.next.

Returns the next element in the list and advances the cursor position. This method may be called repeatedly to iterate through the list, or intermixed with calls to previous to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

Returns:Object

the next element in the list

Annotations
@Override
nextIndexback to summary
public int nextIndex()

Implements java.util.ListIterator.nextIndex.

Doc from java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next. (Returns list size if the list iterator is at the end of the list.)

Returns:int

the index of the element that would be returned by a subsequent call to next, or list size if the list iterator is at the end of the list

Annotations
@Override
previousback to summary
public Object previous()

Implements java.util.ListIterator.previous.

Doc from java.util.ListIterator.previous.

Returns the previous element in the list and moves the cursor position backwards. This method may be called repeatedly to iterate through the list backwards, or intermixed with calls to next to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

Returns:Object

the previous element in the list

Annotations
@Override
previousIndexback to summary
public int previousIndex()

Implements java.util.ListIterator.previousIndex.

Doc from java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous. (Returns -1 if the list iterator is at the beginning of the list.)

Returns:int

the index of the element that would be returned by a subsequent call to previous, or -1 if the list iterator is at the beginning of the list

Annotations
@Override
removeback to summary
public void remove()

Implements java.util.ListIterator.remove.

Doc from java.util.ListIterator.remove.

Removes from the list the last element that was returned by next or previous (optional operation). This call can only be made once per call to next or previous. It can be made only if add has not been called after the last call to next or previous.

Annotations
@Override
setback to summary
public void set(final Object o)

Implements java.util.ListIterator.set.

Doc from java.util.ListIterator.set.

Replaces the last element returned by next or previous with the specified element (optional operation). This call can be made only if neither remove nor add have been called after the last call to next or previous.

Parameters
o:Object

the element with which to replace the last element returned by next or previous

Annotations
@Override