Class Code
- All Implemented Interfaces:
BCEntity
,VisitAcceptor
ListIterator
class. Note that the size and index
information of the code block will change as opcodes are added.
Code blocks are usually obtained from a BCMethod
, but can also
be constructed via the default constructor. Blocks created this way can
be used to provide template instructions to the various search/replace
methods in this class.
The code class contains methods named after most JVM instructions, each
of which adds the matching opcode to the code block at the
current iterator position. It also contains generic versions of various
JVM instructions whose opcodes are not set until their properties are set
with additional information. Almost all instruction types are able to
'morph' their opcode on the fly as the arguments to the instruction change.
Thus the developer can initially call, for example, the aload
opcode, but later change the type to load to int
and the
opcode will automatically morph to the iload
opcode.
- Author:
- Abe White
-
Constructor Summary
ConstructorsConstructorDescriptionCode()
The public constructor is for creating template code modules that produceInstruction
s used in matching through the varioussearch
andreplace
methods. -
Method Summary
Modifier and TypeMethodDescriptionaaload()
Load an object array value onto the stack; theaaload
opcode.aastore()
Store an object value from the stack into an array; theaastore
opcode.void
acceptVisit
(BCVisitor visit) Accept a visit from aBCVisitor
, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.add
(Instruction ins) Adds a copy of the given instruction.Add an exception handler to this code block.addExceptionHandler
(ExceptionHandler handler) Import the given exception handler from another code block.addExceptionHandler
(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, Class catchType) Add an exception handler to this code block.addExceptionHandler
(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, String catchType) Add an exception handler to this code block.addExceptionHandler
(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, BCClass catchType) Add an exception handler to this code block.void
after
(int index) Place the iterator after the given list index.void
after
(Instruction ins) Position the iterator just after the given instruction.void
Set the position of the instruction iterator to after the last opcode.aload()
Load an object local variable onto the stack.anew()
Create a new instance of an object; thenew
opcode.Create a new instance of an object array; theanew
opcode.areturn()
Return an object from a method; theareturn
opcode.Get the length of an array on the stack; thearraylength
opcode.astore()
Store an object value from the stack into a local variable.athrow()
Throw an exception; theathrow
opcode.baload()
Load a byte array value onto the stack; thebaload
opcode.bastore()
Store a byte value from the stack into an array; thebastore
opcode.void
before
(int index) Place the iterator before the given list index.void
before
(Instruction ins) Position the iterator just before the given instruction.void
Reset the position of the instruction iterator to the first opcode.void
Calculate and set the number of locals needed based on the instructions used and the parameters of the method this code block is a part of.void
Calculate and set the maximum stack depth needed for the instructions used.caload()
Load a char array value onto the stack; thecaload
opcode.castore()
Store a char value from the stack into an array; thecastore
opcode.Cast an object on the stack to another type; thecheckcast
opcode.Load a class constant onto the stack.void
Clear all exception handlers.constant()
Load some constant onto the stack.convert()
Convert the top stack value to another type.dadd()
Add the top two stack double values; thedadd
opcode.daload()
Load a double array value onto the stack; thedaload
opcode.dastore()
Store a double value from the stack into an array; thedastore
opcode.dcmpg()
Compare the top two stack values; thedcmpg
opcode.dcmpl()
Compare the top two stack values; thedcmpl
opcode.ddiv()
Divide the top two stack double values; theddiv
opcode.dload()
Load a double local variable onto the stack.dmul()
Multiply the top two stack double values; thedmul
opcode.dneg()
Negate the top stack double value; thedneg
opcode.drem()
Take the remainder of the top two double stack values; thedrem
opcode.dreturn()
Return a double from a method; thedreturn
opcode.dstore()
Store a double value from the stack into a local variable.dsub()
Subtract the top two stack double values; thedsub
opcode.dup()
Thedup
opcode.dup2()
Thedup2
opcode.dup2x1()
Thedup2x1
opcode.dup2x2()
Thedup2x2
opcode.dupx1()
Thedupx1
opcode.dupx2()
Thedupx2
opcode.fadd()
Add the top two stack float values; thefadd
opcode.faload()
Load a float array value onto the stack; thefaload
opcode.fastore()
Store a float value from the stack into an array; thefastore
opcode.fcmpg()
Compare the top two stack values; thefcmpg
opcode.fcmpl()
Compare the top two stack values; thefcmpl
opcode.fdiv()
Divide the top two stack float values; thefdiv
opcode.fload()
Load a float local variable onto the stack.fmul()
Multiply the top two stack float values; thefmul
opcode.fneg()
Negate the top stack float value; thefneg
opcode.frem()
Take the remainder of the top two float stack values; thefrem
opcode.freturn()
Return a float from a method; thefreturn
opcode.fstore()
Store a float value from the stack into a local variable.fsub()
Subtract the top two stack float values; thefsub
opcode.getExceptionHandler
(Class catchType) Return the exception handler that catches the given exception type; if multiple handlers catch the given type, which is returned is undefined.getExceptionHandler
(String catchType) Return the exception handler that catches the given exception type; if multiple handlers catch the given type, which is returned is undefined.getExceptionHandler
(BCClass catchType) Return the exception handler that catches the given exception type; if multiple handlers catch the given type, which is returned is undefined.Return the exception handlers active in this code block, or an empty array if none.getExceptionHandlers
(Class catchType) Return all exception handlers that catch the given exception type, or an empty array if none.getExceptionHandlers
(String catchType) Return all exception handlers that catch the given exception type, or an empty array if none.getExceptionHandlers
(BCClass catchType) Return all exception handlers that catch the given exception type, or an empty array if none.getfield()
Load the value from a field onto the stack; thegetfield
opcode.Return all the Instructions of this method.getLineNumberTable
(boolean add) Return line number information for the code.int
getLocalsIndex
(int paramIndex) Return the local variable index for the paramIndex'th parameter to the method.getLocalVariableTable
(boolean add) Return local variable information for the code.getLocalVariableTypeTable
(boolean add) Return local variable generics information for the code.int
Return the maximum number of local variables (including params) set for this method.int
Return the maximum stack depth set for this code block.The owning method.int
Return the next available local variable index.int
getParamsIndex
(int localIndex) Return the parameter index for the given local index, or -1 if the given local does not reference a param.Load the value from a static field onto the stack; thegetstatic
opcode.go2()
Thego2
opcode.boolean
hasNext()
Return true if a subsequent call tonext()
will return an instruction.boolean
Return true if a subsequent call toprevious()
will return an instruction.iadd()
Add the top two stack int values; theiadd
opcode.iaload()
Load an int array value onto the stack; theiaload
opcode.iand()
Take the mathematical and of the top two stack int values; theiand
opcode.iastore()
Store an int value from the stack into an array; theiastore
opcode.idiv()
Divide the top two stack int values; theidiv
opcode.ifacmpeq()
Theifacmpeq
opcode.ifacmpne()
Theifacmpne
opcode.ifeq()
Theifeq
opcode.ifge()
Theifge
opcode.ifgt()
Theifgt
opcode.ificmpeq()
Theificmpeq
opcode.ificmpge()
Theificmpge
opcode.ificmpgt()
Theificmpgt
opcode.ificmple()
Theificmple
opcode.ificmplt()
Theificmplt
opcode.ificmpne()
Theificmpne
opcode.ifle()
Theifle
opcode.iflt()
Theiflt
opcode.ifne()
Theifne
opcode.Theifnonnull
opcode.ifnull()
Theifnull
opcode.iinc()
Add theiinc
opcode.iload()
Load an int local variable onto the stack.imul()
Multiply the top two stack int values; theimul
opcode.ineg()
Negate the top stack int value; theineg
opcode.Invoke a dynamic method; theinvokedynamic
opcode.Invoke a method on an interface; theinvokeinterface
opcode.Invoke a method non-virtually, as for constructors and superclass methods; theinvokespecial
opcode.Invoke a static method; theinvokestatic
opcode.Invoke a virtual method; theinvokevirtual
opcode.ior()
Take the mathematical or of the top two stack int values; theior
opcode.irem()
Take the remainder of the top two int stack values; theirem
opcode.ireturn()
Return an int from a method; theireturn
opcode.ishl()
Shift the top stack int values; theishl
opcode.ishr()
Shift the top stack int values; theishr
opcode.Test if a stack object is an instance of a class; theinstanceof
opcode.istore()
Store an int value from the stack into a local variable.isub()
Subtract the top two stack int values; theisub
opcode.iushr()
Shift the top stack int values; theiushr
opcode.ixor()
Take the mathematical xor of the top two stack int values; theixor
opcode.jsr()
Thejsr
opcode used in implementingfinally
clauses.ladd()
Add the top two stack long values; theladd
opcode.laload()
Load a long array value onto the stack; thelaload
opcode.land()
Take the mathematical and of the top two stack long values; theland
opcode.lastore()
Store a long value from the stack into an array; thelastore
opcode.lcmp()
Compare the top two stack values; thelcmp
opcode.ldiv()
Divide the top two stack long values; theldiv
opcode.Returns another listIterator view of the Instructions in this code block.lload()
Load a long local variable onto the stack.lmul()
Multiply the top two stack long values; thelmul
opcode.lneg()
Negate the top stack long value; thelneg
opcode.Thelookupswitch
opcode.lor()
Take the mathematical or of the top two stack long values; thelor
opcode.lrem()
Take the remainder of the top two long stack values; thelrem
opcode.lreturn()
Return a long from a method; thelreturn
opcode.lshl()
Shift the top stack long values; thelshl
opcode.lshr()
Shift the top stack long values; thelshr
opcode.lstore()
Store a long value from the stack into a local variable.lsub()
Subtract the top two stack long values; thelsub
opcode.lushr()
Shift the top stack long values; thelushr
opcode.lxor()
Take the mathematical xor of the top two stack long values; thelxor
opcode.math()
Perform some math operation on the stack items.Themonitorenter
opcode.Themonitorexit
opcode.Create a new multidimensional array; themultianewarray
opcode.newarray()
Create a new array of a primitive type; thenewarray
opcode.next()
Return the next instruction.int
Return the index of the next instruction, orsize()
if at end.nop()
Add thenop
opcode.pop()
Thepop
opcode.pop2()
Thepop2
opcode.previous()
Return the previous instruction.int
Return the index of the previous instruction, or -1 if at beginning.putfield()
Place the value of a field onto the stack; theputfield
opcode.Place the value of a static field onto the stack; theputstatic
opcode.void
remove()
Remove the last iterated instruction.boolean
removeExceptionHandler
(Class catchType) Remove the exception handler that catches the given type.boolean
removeExceptionHandler
(String catchType) Remove the exception handler that catches the given type.boolean
removeExceptionHandler
(BCClass catchType) Remove the exception handler that catches the given type.boolean
removeExceptionHandler
(ExceptionHandler handler) Remove an exception handler from this code block.boolean
Remove the line number table for the code.boolean
Remove the local variable table for the code.boolean
Remove the local variable type table for the code.int
replace
(Instruction[] templates, Instruction[] with) Equivalent to looping over each given template/replacement pair and callingreplace(Instruction,Instruction)
for each.int
replace
(Instruction template, Instruction with) Replaces all the instructions in this code block that match the given template with the given instruction.ret()
Add theret
opcode, used in implementingfinally
clauses.saload()
Load a short array value onto the stack; thesaload
opcode.sastore()
Store a short value from the stack into an array; thesastore
opcode.boolean
searchBackward
(Instruction template) Find the closest previous instruction from the current iterator position that matches the given one, according to theObject.equals(java.lang.Object)
methods of the instruction types.boolean
searchForward
(Instruction template) Find the next instruction from the current iterator position that matches the given one, according to theObject.equals(java.lang.Object)
methods of the instruction types.set
(Instruction ins) Replaces the last iterated instruction with a copy of the given one.void
setExceptionHandlers
(ExceptionHandler[] handlers) Set the exception handlers for this code block.void
setMaxLocals
(int max) Set the maximum number of local variables (including params) in this method.void
setMaxStack
(int max) Set the maximum stack depth for this code block.int
size()
Return the number of instructions in the method.swap()
Theswap
opcode.Thetableswitch
opcode.vreturn()
Return void from a method; thereturn
opcode.wide()
Add thewide
opcode.xadd()
Add the top two stack values.xaload()
Load an array value onto the stack.xand()
Take the mathematical and of the top two stack values.xastore()
Store a value from the stack into an array.xcmp()
Compare the top two stack values.xdiv()
Divide the top two stack values.xload()
Load a local variable onto the stack.xmul()
Multiply the top two stack values.xneg()
Negate the top stack value.xor()
Take the mathematical or of the top two stack values.xrem()
Take the remainder of the top two stack values.xreturn()
Return from a method.xshl()
Shift the top stack values.xshr()
Shift the top stack values.xstore()
Store a value from the stack into a local variable.xsub()
Subtract the top two stack values.xushr()
Shift the top stack values.xxor()
Take the mathematical xor of the top two stack values.Methods inherited from class serp.bytecode.Attribute
getClassLoader, getName, getNameIndex, getOwner, getPool, getProject, isValid
Methods inherited from class serp.bytecode.Attributes
addAttribute, addAttribute, clearAttributes, getAttribute, getAttributes, getAttributes, removeAttribute, removeAttribute, setAttributes
-
Constructor Details
-
Code
public Code()The public constructor is for creating template code modules that produceInstruction
s used in matching through the varioussearch
andreplace
methods.
-
-
Method Details
-
getMethod
The owning method. -
getMaxStack
public int getMaxStack()Return the maximum stack depth set for this code block. -
setMaxStack
public void setMaxStack(int max) Set the maximum stack depth for this code block. -
getMaxLocals
public int getMaxLocals()Return the maximum number of local variables (including params) set for this method. -
setMaxLocals
public void setMaxLocals(int max) Set the maximum number of local variables (including params) in this method. -
getLocalsIndex
public int getLocalsIndex(int paramIndex) Return the local variable index for the paramIndex'th parameter to the method. Local variable indexes differ from parameter indexes because: a) non-static methods use the 0th local variable for the 'this' ptr, and b) double and long values occupy two spots in the local variable array. Returns -1 if the given index is not valid. -
getParamsIndex
public int getParamsIndex(int localIndex) Return the parameter index for the given local index, or -1 if the given local does not reference a param.- See Also:
-
getNextLocalsIndex
public int getNextLocalsIndex()Return the next available local variable index. -
calculateMaxLocals
public void calculateMaxLocals()Calculate and set the number of locals needed based on the instructions used and the parameters of the method this code block is a part of.- See Also:
-
calculateMaxStack
public void calculateMaxStack()Calculate and set the maximum stack depth needed for the instructions used.- See Also:
-
getExceptionHandlers
Return the exception handlers active in this code block, or an empty array if none. -
getExceptionHandler
Return the exception handler that catches the given exception type; if multiple handlers catch the given type, which is returned is undefined. -
getExceptionHandler
Return the exception handler that catches the given exception type; if multiple handlers catch the given type, which is returned is undefined. -
getExceptionHandler
Return the exception handler that catches the given exception type; if multiple handlers catch the given type, which is returned is undefined. -
getExceptionHandlers
Return all exception handlers that catch the given exception type, or an empty array if none. -
getExceptionHandlers
Return all exception handlers that catch the given exception type, or an empty array if none. -
getExceptionHandlers
Return all exception handlers that catch the given exception type, or an empty array if none. -
setExceptionHandlers
Set the exception handlers for this code block. This method is useful for importing all handlers from another code block. Set to null or empty array if none. -
addExceptionHandler
Import the given exception handler from another code block. -
addExceptionHandler
Add an exception handler to this code block. -
addExceptionHandler
public ExceptionHandler addExceptionHandler(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, String catchType) Add an exception handler to this code block.- Parameters:
tryStart
- the first instruction of the try {} blocktryEnd
- the last instruction of the try {} blockhandlerStart
- the first instruction of the catch {} blockcatchType
- the type of exception being caught
-
addExceptionHandler
public ExceptionHandler addExceptionHandler(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, Class catchType) Add an exception handler to this code block.- Parameters:
tryStart
- the first instruction of the try {} blocktryEnd
- the last instruction of the try {} blockhandlerStart
- the first instruction of the catch {} blockcatchType
- the type of exception being caught
-
addExceptionHandler
public ExceptionHandler addExceptionHandler(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, BCClass catchType) Add an exception handler to this code block.- Parameters:
tryStart
- the first instruction of the try {} blocktryEnd
- the last instruction of the try {} blockhandlerStart
- the first instruction of the catch {} blockcatchType
- the type of exception being caught
-
clearExceptionHandlers
public void clearExceptionHandlers()Clear all exception handlers. -
removeExceptionHandler
Remove the exception handler that catches the given type. -
removeExceptionHandler
Remove the exception handler that catches the given type.- Returns:
- true if the handler was removed, false otherwise
-
removeExceptionHandler
Remove the exception handler that catches the given type.- Returns:
- true if the handler was removed, false otherwise
-
removeExceptionHandler
Remove an exception handler from this code block. The given handler must belong to this code block. -
size
public int size()Return the number of instructions in the method. -
beforeFirst
public void beforeFirst()Reset the position of the instruction iterator to the first opcode. -
afterLast
public void afterLast()Set the position of the instruction iterator to after the last opcode. -
before
Position the iterator just before the given instruction. The instruction must belong to this method. -
after
Position the iterator just after the given instruction. The instruction must belong to this method. -
hasNext
public boolean hasNext()Return true if a subsequent call tonext()
will return an instruction. -
hasPrevious
public boolean hasPrevious()Return true if a subsequent call toprevious()
will return an instruction. -
next
Return the next instruction. -
nextIndex
public int nextIndex()Return the index of the next instruction, orsize()
if at end. -
previous
Return the previous instruction. -
previousIndex
public int previousIndex()Return the index of the previous instruction, or -1 if at beginning. -
before
public void before(int index) Place the iterator before the given list index. -
after
public void after(int index) Place the iterator after the given list index. -
searchForward
Find the next instruction from the current iterator position that matches the given one, according to theObject.equals(java.lang.Object)
methods of the instruction types. This allows for matching based on template instructions, as the equals methods of most instructions return true if the information for the given instruction has not been filled in. If a match is found, the iterator is placed after the matching Instruction. If no match is found, moves the iterator toafterLast()
.- Returns:
- true if match found
-
searchBackward
Find the closest previous instruction from the current iterator position that matches the given one, according to theObject.equals(java.lang.Object)
methods of the instruction types. This allows for matching based on template instructions, as the equals methods of most instructions return true if the information for the given instruction has not been filled in. If a match is found, the iterator is placed before the matching Instruction. If no match is found, moves the iterator tobeforeFirst()
.- Returns:
- true if match found
-
add
Adds a copy of the given instruction.- Returns:
- the newly added instruction
-
set
Replaces the last iterated instruction with a copy of the given one. This method will also make sure that all jump points that referenced the old opcode are updated correctly.- Returns:
- the newly added instruction
- See Also:
-
replace
Replaces all the instructions in this code block that match the given template with the given instruction. After this method, the iterator will beafterLast()
.- Returns:
- the number of substitutions made
-
replace
Equivalent to looping over each given template/replacement pair and callingreplace(Instruction,Instruction)
for each. -
remove
public void remove()Remove the last iterated instruction.- See Also:
-
classconstant
Load a class constant onto the stack. For primitive types, this translates into a getstatic for the TYPE field of the primitive's wrapper type. For non-primitives, things get much more complex. Suffice it to say that the operation involves adding synthetic static fields and even methods to the class. Note that this instruction requires up to 3 stack positions to execute. -
nop
Add thenop
opcode. -
constant
Load some constant onto the stack. TheConstantInstruction
type takes any constant and correctly translates it into the proper opcode, depending on the constant type and value. For example, if the constant value is set to 0L, the opcode will be set tolconst0
. -
xload
Load a local variable onto the stack. This instruction will result in anop
until its type and local index are set. -
iload
Load an int local variable onto the stack. This instruction will result in anop
until its local index is set. -
lload
Load a long local variable onto the stack. This instruction will result in anop
until its local index is set. -
fload
Load a float local variable onto the stack. This instruction will result in anop
until its local index is set. -
dload
Load a double local variable onto the stack. This instruction will result in anop
until its local index is set. -
aload
Load an object local variable onto the stack. This instruction will result in anop
until its local index is set. -
xstore
Store a value from the stack into a local variable. This instruction will result in anop
until its type and local index are set. -
istore
Store an int value from the stack into a local variable. This instruction will result in anop
until its local index is set. -
lstore
Store a long value from the stack into a local variable. This instruction will resultin anop
until its local index is set. -
fstore
Store a float value from the stack into a local variable. This instruction will result in anop
until its local index is set. -
dstore
Store a double value from the stack into a local variable. This instruction will result in anop
until its local index is set. -
astore
Store an object value from the stack into a local variable. This instruction will result in anop
until its local index is set. -
ret
Add theret
opcode, used in implementingfinally
clauses. -
iinc
Add theiinc
opcode. -
wide
Add thewide
opcode. -
xaload
Load an array value onto the stack. This instruction will result in anop
until its type is set. -
iaload
Load an int array value onto the stack; theiaload
opcode. -
laload
Load a long array value onto the stack; thelaload
opcode. -
faload
Load a float array value onto the stack; thefaload
opcode. -
daload
Load a double array value onto the stack; thedaload
opcode. -
aaload
Load an object array value onto the stack; theaaload
opcode. -
baload
Load a byte array value onto the stack; thebaload
opcode. -
caload
Load a char array value onto the stack; thecaload
opcode. -
saload
Load a short array value onto the stack; thesaload
opcode. -
xastore
Store a value from the stack into an array. This instruction will result in anop
until its type is set. -
iastore
Store an int value from the stack into an array; theiastore
opcode. -
lastore
Store a long value from the stack into an array; thelastore
opcode. -
fastore
Store a float value from the stack into an array; thefastore
opcode. -
dastore
Store a double value from the stack into an array; thedastore
opcode. -
aastore
Store an object value from the stack into an array; theaastore
opcode. -
bastore
Store a byte value from the stack into an array; thebastore
opcode. -
castore
Store a char value from the stack into an array; thecastore
opcode. -
sastore
Store a short value from the stack into an array; thesastore
opcode. -
pop
Thepop
opcode. -
pop2
Thepop2
opcode. -
dup
Thedup
opcode. -
dupx1
Thedupx1
opcode. -
dupx2
Thedupx2
opcode. -
dup2
Thedup2
opcode. -
dup2x1
Thedup2x1
opcode. -
dup2x2
Thedup2x2
opcode. -
swap
Theswap
opcode. -
math
Perform some math operation on the stack items. This instruction will result in anop
until its operation and type are set. -
xadd
Add the top two stack values. This instruction will result in anop
until its type is set. -
iadd
Add the top two stack int values; theiadd
opcode. -
ladd
Add the top two stack long values; theladd
opcode. -
fadd
Add the top two stack float values; thefadd
opcode. -
dadd
Add the top two stack double values; thedadd
opcode. -
xsub
Subtract the top two stack values. This instruction will result in anop
until its type is set. -
isub
Subtract the top two stack int values; theisub
opcode. -
lsub
Subtract the top two stack long values; thelsub
opcode. -
fsub
Subtract the top two stack float values; thefsub
opcode. -
dsub
Subtract the top two stack double values; thedsub
opcode. -
xmul
Multiply the top two stack values. This instruction will result in anop
until its type is set. -
imul
Multiply the top two stack int values; theimul
opcode. -
lmul
Multiply the top two stack long values; thelmul
opcode. -
fmul
Multiply the top two stack float values; thefmul
opcode. -
dmul
Multiply the top two stack double values; thedmul
opcode. -
xdiv
Divide the top two stack values. This instruction will result in anop
until its type is set. -
idiv
Divide the top two stack int values; theidiv
opcode. -
ldiv
Divide the top two stack long values; theldiv
opcode. -
fdiv
Divide the top two stack float values; thefdiv
opcode. -
ddiv
Divide the top two stack double values; theddiv
opcode. -
xrem
Take the remainder of the top two stack values. This instruction will result in anop
until its type is set. -
irem
Take the remainder of the top two int stack values; theirem
opcode. -
lrem
Take the remainder of the top two long stack values; thelrem
opcode. -
frem
Take the remainder of the top two float stack values; thefrem
opcode. -
drem
Take the remainder of the top two double stack values; thedrem
opcode. -
xneg
Negate the top stack value. This instruction will result in anop
until its type is set. -
ineg
Negate the top stack int value; theineg
opcode. -
lneg
Negate the top stack long value; thelneg
opcode. -
fneg
Negate the top stack float value; thefneg
opcode. -
dneg
Negate the top stack double value; thedneg
opcode. -
xshl
Shift the top stack values. This instruction will result in anop
until its type is set. -
ishl
Shift the top stack int values; theishl
opcode. -
lshl
Shift the top stack long values; thelshl
opcode. -
xshr
Shift the top stack values. This instruction will result in anop
until its type is set. -
ishr
Shift the top stack int values; theishr
opcode. -
lshr
Shift the top stack long values; thelshr
opcode. -
xushr
Shift the top stack values. This instruction will result in anop
until its type is set. -
iushr
Shift the top stack int values; theiushr
opcode. -
lushr
Shift the top stack long values; thelushr
opcode. -
xand
Take the mathematical and of the top two stack values. This instruction results in anop
until its type is set. -
iand
Take the mathematical and of the top two stack int values; theiand
opcode. -
land
Take the mathematical and of the top two stack long values; theland
opcode. -
xor
Take the mathematical or of the top two stack values. This instruction results in anop
until its type is set. -
ior
Take the mathematical or of the top two stack int values; theior
opcode. -
lor
Take the mathematical or of the top two stack long values; thelor
opcode. -
xxor
Take the mathematical xor of the top two stack values. This instruction results in anop
until its type is set. -
ixor
Take the mathematical xor of the top two stack int values; theixor
opcode. -
lxor
Take the mathematical xor of the top two stack long values; thelxor
opcode. -
convert
Convert the top stack value to another type. This instruction will result in anop
until the types to convert between are set. -
xcmp
Compare the top two stack values. This instruction will result in anop
until its type is set. -
lcmp
Compare the top two stack values; thelcmp
opcode. -
fcmpl
Compare the top two stack values; thefcmpl
opcode. -
fcmpg
Compare the top two stack values; thefcmpg
opcode. -
dcmpl
Compare the top two stack values; thedcmpl
opcode. -
dcmpg
Compare the top two stack values; thedcmpg
opcode. -
ifeq
Theifeq
opcode. -
ifne
Theifne
opcode. -
iflt
Theiflt
opcode. -
ifge
Theifge
opcode. -
ifgt
Theifgt
opcode. -
ifle
Theifle
opcode. -
ificmpeq
Theificmpeq
opcode. -
ificmpne
Theificmpne
opcode. -
ificmplt
Theificmplt
opcode. -
ificmpge
Theificmpge
opcode. -
ificmpgt
Theificmpgt
opcode. -
ificmple
Theificmple
opcode. -
ifacmpeq
Theifacmpeq
opcode. -
ifacmpne
Theifacmpne
opcode. -
ifnull
Theifnull
opcode. -
ifnonnull
Theifnonnull
opcode. -
go2
Thego2
opcode. -
jsr
Thejsr
opcode used in implementingfinally
clauses. -
tableswitch
Thetableswitch
opcode. -
lookupswitch
Thelookupswitch
opcode. -
xreturn
Return from a method. This method will result in anop
until its type is set. -
vreturn
Return void from a method; thereturn
opcode. -
ireturn
Return an int from a method; theireturn
opcode. -
lreturn
Return a long from a method; thelreturn
opcode. -
freturn
Return a float from a method; thefreturn
opcode. -
dreturn
Return a double from a method; thedreturn
opcode. -
areturn
Return an object from a method; theareturn
opcode. -
getfield
Load the value from a field onto the stack; thegetfield
opcode. -
getstatic
Load the value from a static field onto the stack; thegetstatic
opcode. -
putfield
Place the value of a field onto the stack; theputfield
opcode. -
putstatic
Place the value of a static field onto the stack; theputstatic
opcode. -
invokevirtual
Invoke a virtual method; theinvokevirtual
opcode. -
invokespecial
Invoke a method non-virtually, as for constructors and superclass methods; theinvokespecial
opcode. -
invokeinterface
Invoke a method on an interface; theinvokeinterface
opcode. -
invokestatic
Invoke a static method; theinvokestatic
opcode. -
invokedynamic
Invoke a dynamic method; theinvokedynamic
opcode. -
anew
Create a new instance of an object; thenew
opcode. -
anewarray
Create a new instance of an object array; theanew
opcode. -
checkcast
Cast an object on the stack to another type; thecheckcast
opcode. -
isinstance
Test if a stack object is an instance of a class; theinstanceof
opcode. -
multianewarray
Create a new multidimensional array; themultianewarray
opcode. -
newarray
Create a new array of a primitive type; thenewarray
opcode. -
arraylength
Get the length of an array on the stack; thearraylength
opcode. -
athrow
Throw an exception; theathrow
opcode. -
monitorenter
Themonitorenter
opcode. -
monitorexit
Themonitorexit
opcode. -
getInstructions
Return all the Instructions of this method. -
acceptVisit
Description copied from interface:VisitAcceptor
Accept a visit from aBCVisitor
, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one. -
getLineNumberTable
Return line number information for the code. Acts internally through theAttributes
interface.- Parameters:
add
- if true, a new line number table will be added if not already present- Returns:
- the line number information, or null if none
and the
add
param is set to false
-
removeLineNumberTable
public boolean removeLineNumberTable()Remove the line number table for the code. Acts internally through theAttributes
interface.- Returns:
- true if there was a table to remove
-
getLocalVariableTable
Return local variable information for the code. Acts internally through theAttributes
interface.- Parameters:
add
- if true, a new local variable table will be added if not already present- Returns:
- the local variable information, or null if none
and the
add
param is set to false
-
removeLocalVariableTables
public boolean removeLocalVariableTables()Remove the local variable table for the code. Acts internally through theAttributes
interface.- Returns:
- true if there was a table to remove
-
getLocalVariableTypeTable
Return local variable generics information for the code. Acts internally through theAttributes
interface.- Parameters:
add
- if true, a new local variable type table will be added if not already present- Returns:
- the local variable type information, or null if none
and the
add
param is set to false
-
removeLocalVariableTypeTables
public boolean removeLocalVariableTypeTables()Remove the local variable type table for the code. Acts internally through theAttributes
interface.- Returns:
- true if there was a table to remove
-
listIterator
Returns another listIterator view of the Instructions in this code block. Useful for performing read-only searches through Instructions without effecting the pointer location of the main code block.
-