public final class Bytecode
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Bytecode.DelegateInitialiser
Information bundle returned from
findDelegateInit(org.objectweb.asm.tree.MethodNode, java.lang.String, java.lang.String) |
static class |
Bytecode.Visibility
Ordinal member visibility level.
|
| Modifier and Type | Field and Description |
|---|---|
static int[] |
CONSTANTS_ALL
All constant opcodes
|
static int[] |
CONSTANTS_DOUBLE
Double constant opcodes
|
static int[] |
CONSTANTS_FLOAT
Float constant opcodes
|
static int[] |
CONSTANTS_INT
Integer constant opcodes
|
static int[] |
CONSTANTS_LONG
Long constant opcodes
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
changeDescriptorReturnType(java.lang.String desc,
java.lang.String returnType)
Changes the return type of a method descriptor to the specified symbol
|
static java.util.Map<org.objectweb.asm.tree.LabelNode,org.objectweb.asm.tree.LabelNode> |
cloneLabels(org.objectweb.asm.tree.InsnList source)
Clones all of the labels in the source instruction list and returns the
clones in a map of old label -> new label.
|
static void |
compareBridgeMethods(org.objectweb.asm.tree.MethodNode a,
org.objectweb.asm.tree.MethodNode b)
Compares two synthetic bridge methods and throws an exception if they are
not compatible.
|
static boolean |
compareFlags(org.objectweb.asm.tree.FieldNode f1,
org.objectweb.asm.tree.FieldNode f2,
int flag)
Check whether the status of the specified flag matches on both of the
supplied arguments.
|
static boolean |
compareFlags(org.objectweb.asm.tree.MethodNode m1,
org.objectweb.asm.tree.MethodNode m2,
int flag)
Check whether the status of the specified flag matches on both of the
supplied arguments.
|
static java.lang.String |
describeNode(org.objectweb.asm.tree.AbstractInsnNode node)
Gets a description of the supplied node for debugging purposes
|
static void |
dumpClass(byte[] bytes)
Dumps the output of CheckClassAdapter.verify to System.out
|
static void |
dumpClass(org.objectweb.asm.tree.ClassNode classNode)
Dumps the output of CheckClassAdapter.verify to System.out
|
static Bytecode.DelegateInitialiser |
findDelegateInit(org.objectweb.asm.tree.MethodNode ctor,
java.lang.String superName,
java.lang.String ownerName)
Find the call to super() or this() in a constructor.
|
static org.objectweb.asm.tree.AbstractInsnNode |
findInsn(org.objectweb.asm.tree.MethodNode method,
int opcode)
Find the first insn node with a matching opcode in the specified method
|
static org.objectweb.asm.tree.MethodNode |
findMethod(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String name,
java.lang.String desc)
Finds a method given the method descriptor
|
static java.lang.String |
generateDescriptor(java.lang.Object returnType,
java.lang.Object... args)
Generate a bytecode descriptor from the supplied tokens.
|
static java.lang.String |
generateDescriptor(org.objectweb.asm.Type returnType,
org.objectweb.asm.Type... args)
Generate a bytecode descriptor from the supplied types.
|
static int |
getArgsSize(org.objectweb.asm.Type[] args)
Get the size of the specified args array in local variable terms (eg.
|
static int |
getArgsSize(org.objectweb.asm.Type[] args,
int startIndex,
int endIndex)
Get the size of the specified args array in local variable terms (eg.
|
static java.lang.String |
getBoxingType(org.objectweb.asm.Type type)
Get the boxing type name for the specified type, if it is a primitive.
|
static java.lang.Object |
getConstant(org.objectweb.asm.tree.AbstractInsnNode insn)
If the supplied instruction is a constant, returns the constant value
from the instruction
|
static org.objectweb.asm.Type |
getConstantType(org.objectweb.asm.tree.AbstractInsnNode insn)
Returns the
Type of a particular constant instruction's payload |
static java.lang.String |
getDescriptor(org.objectweb.asm.Type... args)
Generate a method descriptor without return type for the supplied args
array
|
static java.lang.String |
getDescriptor(org.objectweb.asm.Type returnType,
org.objectweb.asm.Type... args)
Generate a method descriptor with the specified types
|
static int |
getFirstNonArgLocalIndex(org.objectweb.asm.tree.MethodNode method)
Get the first variable index in the supplied method which is not an
argument or "this" reference, this corresponds to the size of the
arguments passed in to the method plus an extra spot for "this" if the
method is non-static
|
static int |
getFirstNonArgLocalIndex(org.objectweb.asm.Type[] args,
boolean includeThis)
Get the first non-arg variable index based on the supplied arg array and
whether to include the "this" reference, this corresponds to the size of
the arguments passed in to the method plus an extra spot for "this" is
specified
|
static int |
getMaxLineNumber(org.objectweb.asm.tree.ClassNode classNode,
int min,
int pad)
Compute the largest line number found in the specified class
|
static java.lang.String |
getOpcodeName(org.objectweb.asm.tree.AbstractInsnNode node)
Uses reflection to find an approximate constant name match for the
supplied node's opcode
|
static java.lang.String |
getOpcodeName(int opcode)
Uses reflection to find an approximate constant name match for the
supplied opcode
|
static java.lang.String |
getSimpleName(org.objectweb.asm.tree.AnnotationNode annotation)
Returns the simple name of an annotation, mainly used for printing
annotation names in error messages/user-facing strings
|
static java.lang.String |
getSimpleName(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns the simple name of an annotation, mainly used for printing
annotation names in error messages/user-facing strings
|
static java.lang.String |
getSimpleName(java.lang.String desc)
Returns the simple name from an object type descriptor (in L...; format)
|
static java.lang.String |
getSimpleName(org.objectweb.asm.Type type)
Returns the simple name of a type representing a class
|
static java.lang.String |
getUnboxingMethod(org.objectweb.asm.Type type)
Get the unboxing method name for the specified primitive type's
corresponding reference type.
|
static Bytecode.Visibility |
getVisibility(org.objectweb.asm.tree.FieldNode field)
Returns the ordinal visibility of the supplied argument where a
higher value equals higher "visibility":
|
static Bytecode.Visibility |
getVisibility(org.objectweb.asm.tree.MethodNode method)
Returns the ordinal visibility of the supplied argument where a
higher value equals higher "visibility":
|
static boolean |
hasFlag(org.objectweb.asm.tree.ClassNode classNode,
int flag)
Check whether the specified flag is set on the specified class
|
static boolean |
hasFlag(org.objectweb.asm.tree.FieldNode field,
int flag)
Check whether the specified flag is set on the specified field
|
static boolean |
hasFlag(org.objectweb.asm.tree.MethodNode method,
int flag)
Check whether the specified flag is set on the specified method
|
static boolean |
isConstant(org.objectweb.asm.tree.AbstractInsnNode insn)
Gets whether the supplied instruction is a constant instruction (eg.
|
static boolean |
isStatic(org.objectweb.asm.tree.FieldNode field)
Returns true if the supplied field node is static
|
static boolean |
isStatic(org.objectweb.asm.tree.MethodNode method)
Returns true if the supplied method node is static
|
static boolean |
isVirtual(org.objectweb.asm.tree.MethodNode method)
Checks whether the supplied method is virtual.
|
static void |
loadArgs(org.objectweb.asm.Type[] args,
org.objectweb.asm.tree.InsnList insns,
int pos)
Injects appropriate LOAD opcodes into the supplied InsnList appropriate
for each entry in the args array starting at pos
|
static void |
loadArgs(org.objectweb.asm.Type[] args,
org.objectweb.asm.tree.InsnList insns,
int start,
int end)
Injects appropriate LOAD opcodes into the supplied InsnList appropriate
for each entry in the args array starting at start (inclusive) and ending
at end (inclusive)
|
static void |
loadArgs(org.objectweb.asm.Type[] args,
org.objectweb.asm.tree.InsnList insns,
int start,
int end,
org.objectweb.asm.Type[] casts)
Injects appropriate LOAD opcodes into the supplied InsnList appropriate
for each entry in the args array starting at start (inclusive) and ending
at end (inclusive)
|
static void |
merge(org.objectweb.asm.tree.ClassNode source,
org.objectweb.asm.tree.ClassNode dest)
Perform a naïve merge of ClassNode members onto a target ClassNode
|
static boolean |
methodHasLineNumbers(org.objectweb.asm.tree.MethodNode method)
Returns true if the supplied method contains any line number information
|
static void |
printMethod(org.objectweb.asm.tree.MethodNode method)
Prints a representation of a method's instructions to stderr
|
static void |
printMethodWithOpcodeIndices(org.objectweb.asm.tree.MethodNode method)
Prints a representation of a method's instructions to stderr
|
static void |
printNode(org.objectweb.asm.tree.AbstractInsnNode node)
Prints a representation of the specified insn node to stderr
|
static void |
replace(org.objectweb.asm.tree.ClassNode source,
org.objectweb.asm.tree.ClassNode dest)
Replace all values in a target ClassNode with values from the Source
|
static void |
setVisibility(org.objectweb.asm.tree.FieldNode field,
Bytecode.Visibility visibility)
Set the visibility of the specified member, leaving other access flags
unchanged
|
static void |
setVisibility(org.objectweb.asm.tree.FieldNode field,
int access)
Set the visibility of the specified member, leaving other access flags
unchanged
|
static void |
setVisibility(org.objectweb.asm.tree.MethodNode method,
Bytecode.Visibility visibility)
Set the visibility of the specified member, leaving other access flags
unchanged
|
static void |
setVisibility(org.objectweb.asm.tree.MethodNode method,
int access)
Set the visibility of the specified member, leaving other access flags
unchanged
|
static void |
textify(org.objectweb.asm.tree.ClassNode classNode,
java.io.OutputStream out)
Runs textifier on the specified class node and dumps the output to the
specified output stream
|
static void |
textify(org.objectweb.asm.tree.MethodNode methodNode,
java.io.OutputStream out)
Runs textifier on the specified method node and dumps the output to the
specified output stream
|
public static final int[] CONSTANTS_INT
public static final int[] CONSTANTS_FLOAT
public static final int[] CONSTANTS_DOUBLE
public static final int[] CONSTANTS_LONG
public static final int[] CONSTANTS_ALL
public static org.objectweb.asm.tree.MethodNode findMethod(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String name,
java.lang.String desc)
classNode - the class to scanname - the method namedesc - the method descriptorpublic static org.objectweb.asm.tree.AbstractInsnNode findInsn(org.objectweb.asm.tree.MethodNode method,
int opcode)
method - method to searchopcode - opcode to search forpublic static Bytecode.DelegateInitialiser findDelegateInit(org.objectweb.asm.tree.MethodNode ctor, java.lang.String superName, java.lang.String ownerName)
ctor - ctor to scansuperName - name of superclassownerName - name of owning classpublic static void textify(org.objectweb.asm.tree.ClassNode classNode,
java.io.OutputStream out)
classNode - class to textifyout - output streampublic static void textify(org.objectweb.asm.tree.MethodNode methodNode,
java.io.OutputStream out)
methodNode - method to textifyout - output streampublic static void dumpClass(org.objectweb.asm.tree.ClassNode classNode)
classNode - the ClassNode to verifypublic static void dumpClass(byte[] bytes)
bytes - the bytecode of the class to checkpublic static void printMethodWithOpcodeIndices(org.objectweb.asm.tree.MethodNode method)
method - Method to printpublic static void printMethod(org.objectweb.asm.tree.MethodNode method)
method - Method to printpublic static void printNode(org.objectweb.asm.tree.AbstractInsnNode node)
node - Node to printpublic static java.lang.String describeNode(org.objectweb.asm.tree.AbstractInsnNode node)
node - node to describepublic static java.lang.String getOpcodeName(org.objectweb.asm.tree.AbstractInsnNode node)
node - Node to query for opcodeOpcodes class have the same value as opcodespublic static java.lang.String getOpcodeName(int opcode)
opcode - Opcode to look upOpcodes class have the same value as opcodespublic static boolean methodHasLineNumbers(org.objectweb.asm.tree.MethodNode method)
method - Method to scanpublic static boolean isStatic(org.objectweb.asm.tree.MethodNode method)
method - method nodeOpcodes.ACC_STATIC flagpublic static boolean isStatic(org.objectweb.asm.tree.FieldNode field)
field - field nodeOpcodes.ACC_STATIC flagpublic static int getFirstNonArgLocalIndex(org.objectweb.asm.tree.MethodNode method)
method - MethodNode to inspectpublic static int getFirstNonArgLocalIndex(org.objectweb.asm.Type[] args,
boolean includeThis)
args - Method argumentsincludeThis - Whether to include a slot for "this" (generally true
for all non-static methods)public static int getArgsSize(org.objectweb.asm.Type[] args)
args - Method argument types as arraypublic static int getArgsSize(org.objectweb.asm.Type[] args,
int startIndex,
int endIndex)
args - Method argument types as arraystartIndex - Start index in the array, not related to arg sizeendIndex - End index (exclusive) in the array, not related to sizepublic static void loadArgs(org.objectweb.asm.Type[] args,
org.objectweb.asm.tree.InsnList insns,
int pos)
args - Argument typesinsns - Instruction List to inject intopos - Start positionpublic static void loadArgs(org.objectweb.asm.Type[] args,
org.objectweb.asm.tree.InsnList insns,
int start,
int end)
args - Argument typesinsns - Instruction List to inject intostart - Start positionend - End positionpublic static void loadArgs(org.objectweb.asm.Type[] args,
org.objectweb.asm.tree.InsnList insns,
int start,
int end,
org.objectweb.asm.Type[] casts)
args - Argument typesinsns - Instruction List to inject intostart - Start positionend - End positioncasts - Type casts arraypublic static java.util.Map<org.objectweb.asm.tree.LabelNode,org.objectweb.asm.tree.LabelNode> cloneLabels(org.objectweb.asm.tree.InsnList source)
AbstractInsnNode.clone(java.util.Map<org.objectweb.asm.tree.LabelNode, org.objectweb.asm.tree.LabelNode>).source - instruction listpublic static java.lang.String generateDescriptor(org.objectweb.asm.Type returnType,
org.objectweb.asm.Type... args)
returnType - the method return type, can be null for
voidargs - argument typespublic static java.lang.String generateDescriptor(java.lang.Object returnType,
java.lang.Object... args)
Type, a Class or otherwise is converted in-place by
calling toString.returnType - object representing the method return type, can be
null for voidargs - objects representing argument typespublic static java.lang.String getDescriptor(org.objectweb.asm.Type... args)
args - argument typespublic static java.lang.String getDescriptor(org.objectweb.asm.Type returnType,
org.objectweb.asm.Type... args)
returnType - return typeargs - argument typespublic static java.lang.String changeDescriptorReturnType(java.lang.String desc,
java.lang.String returnType)
desc - descriptor to modifyreturnType - new return typepublic static java.lang.String getSimpleName(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
annotationType - annotationpublic static java.lang.String getSimpleName(org.objectweb.asm.Type type)
type - typepublic static java.lang.String getSimpleName(org.objectweb.asm.tree.AnnotationNode annotation)
annotation - annotation nodepublic static java.lang.String getSimpleName(java.lang.String desc)
desc - type descriptorpublic static boolean isConstant(org.objectweb.asm.tree.AbstractInsnNode insn)
insn - instruction to checkpublic static java.lang.Object getConstant(org.objectweb.asm.tree.AbstractInsnNode insn)
insn - constant instruction to processpublic static org.objectweb.asm.Type getConstantType(org.objectweb.asm.tree.AbstractInsnNode insn)
Type of a particular constant instruction's payloadinsn - constant instructionpublic static boolean hasFlag(org.objectweb.asm.tree.ClassNode classNode,
int flag)
classNode - class nodeflag - flag to checkpublic static boolean hasFlag(org.objectweb.asm.tree.MethodNode method,
int flag)
method - method nodeflag - flag to checkpublic static boolean hasFlag(org.objectweb.asm.tree.FieldNode field,
int flag)
field - field nodeflag - flag to checkpublic static boolean compareFlags(org.objectweb.asm.tree.MethodNode m1,
org.objectweb.asm.tree.MethodNode m2,
int flag)
m1 - First methodm2 - Second methodflag - flag to comparepublic static boolean compareFlags(org.objectweb.asm.tree.FieldNode f1,
org.objectweb.asm.tree.FieldNode f2,
int flag)
f1 - First fieldf2 - Second fieldflag - flag to comparepublic static boolean isVirtual(org.objectweb.asm.tree.MethodNode method)
method - Method to testpublic static Bytecode.Visibility getVisibility(org.objectweb.asm.tree.MethodNode method)
method - method to get visibility forpublic static Bytecode.Visibility getVisibility(org.objectweb.asm.tree.FieldNode field)
field - field to get visibility forpublic static void setVisibility(org.objectweb.asm.tree.MethodNode method,
Bytecode.Visibility visibility)
method - method to changevisibility - new visibilitypublic static void setVisibility(org.objectweb.asm.tree.FieldNode field,
Bytecode.Visibility visibility)
field - field to changevisibility - new visibilitypublic static void setVisibility(org.objectweb.asm.tree.MethodNode method,
int access)
method - method to changeaccess - new visibilitypublic static void setVisibility(org.objectweb.asm.tree.FieldNode field,
int access)
field - field to changeaccess - new visibilitypublic static int getMaxLineNumber(org.objectweb.asm.tree.ClassNode classNode,
int min,
int pad)
classNode - Class to inspectmin - minimum value to returnpad - amount to pad at the end of filespublic static java.lang.String getBoxingType(org.objectweb.asm.Type type)
type - type to boxpublic static java.lang.String getUnboxingMethod(org.objectweb.asm.Type type)
type - primitive type to get unboxing method forpublic static void compareBridgeMethods(org.objectweb.asm.tree.MethodNode a,
org.objectweb.asm.tree.MethodNode b)
a - Incumbent methodb - Incoming methodpublic static void merge(org.objectweb.asm.tree.ClassNode source,
org.objectweb.asm.tree.ClassNode dest)
source - Source ClassNode to merge fromdest - Destination ClassNode to merge topublic static void replace(org.objectweb.asm.tree.ClassNode source,
org.objectweb.asm.tree.ClassNode dest)
source - Source ClassNode to merge fromdest - Destination ClassNode to merge to