public final class Bytecode
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
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.spongepowered.asm.lib.tree.LabelNode,org.spongepowered.asm.lib.tree.LabelNode> |
cloneLabels(org.spongepowered.asm.lib.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.spongepowered.asm.lib.tree.MethodNode a,
org.spongepowered.asm.lib.tree.MethodNode b)
Compares two synthetic bridge methods and throws an exception if they are
not compatible.
|
static boolean |
compareFlags(org.spongepowered.asm.lib.tree.FieldNode f1,
org.spongepowered.asm.lib.tree.FieldNode f2,
int flag)
Check whether the status of the specified flag matches on both of the
supplied arguments.
|
static boolean |
compareFlags(org.spongepowered.asm.lib.tree.MethodNode m1,
org.spongepowered.asm.lib.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.spongepowered.asm.lib.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.spongepowered.asm.lib.tree.ClassNode classNode)
Dumps the output of CheckClassAdapter.verify to System.out
|
static boolean |
fieldIsStatic(org.spongepowered.asm.lib.tree.FieldNode field)
Returns true if the supplied field node is static
|
static org.spongepowered.asm.lib.tree.AbstractInsnNode |
findInsn(org.spongepowered.asm.lib.tree.MethodNode method,
int opcode)
Find the first insn node with a matching opcode in the specified method
|
static org.spongepowered.asm.lib.tree.MethodNode |
findMethod(org.spongepowered.asm.lib.tree.ClassNode classNode,
java.lang.String name,
java.lang.String desc)
Finds a method given the method descriptor
|
static org.spongepowered.asm.lib.tree.MethodInsnNode |
findSuperInit(org.spongepowered.asm.lib.tree.MethodNode method,
java.lang.String superName)
Find the call to super() in a constructor.
|
static java.lang.String |
generateDescriptor(java.lang.Object returnType,
java.lang.Object... args)
Generate a bytecode descriptor from the supplied tokens.
|
static int |
getArgsSize(org.spongepowered.asm.lib.Type[] args)
Get the size of the specified args array in local variable terms (eg.
|
static java.lang.String |
getBoxingType(org.spongepowered.asm.lib.Type type)
Get the boxing type name for the specified type, if it is a primitive.
|
static java.lang.Object |
getConstant(org.spongepowered.asm.lib.tree.AbstractInsnNode insn)
If the supplied instruction is a constant, returns the constant value
from the instruction
|
static org.spongepowered.asm.lib.Type |
getConstantType(org.spongepowered.asm.lib.tree.AbstractInsnNode insn)
Returns the
Type of a particular constant instruction's payload |
static java.lang.String |
getDescriptor(org.spongepowered.asm.lib.Type[] args)
Generate a method descriptor without return type for the supplied args
array
|
static java.lang.String |
getDescriptor(org.spongepowered.asm.lib.Type[] args,
org.spongepowered.asm.lib.Type returnType)
Generate a method descriptor with the specified types
|
static int |
getFirstNonArgLocalIndex(org.spongepowered.asm.lib.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.spongepowered.asm.lib.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.spongepowered.asm.lib.tree.ClassNode classNode,
int min,
int pad)
Compute the largest line number found in the specified class
|
static java.lang.String |
getOpcodeName(org.spongepowered.asm.lib.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.spongepowered.asm.lib.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 |
getUnboxingMethod(org.spongepowered.asm.lib.Type type)
Get the unboxing method name for the specified primitive type's
corresponding reference type.
|
static Bytecode.Visibility |
getVisibility(org.spongepowered.asm.lib.tree.FieldNode field)
Returns the ordinal visibility of the supplied argument where a
higher value equals higher "visibility":
|
static Bytecode.Visibility |
getVisibility(org.spongepowered.asm.lib.tree.MethodNode method)
Returns the ordinal visibility of the supplied argument where a
higher value equals higher "visibility":
|
static boolean |
hasFlag(org.spongepowered.asm.lib.tree.ClassNode classNode,
int flag)
Check whether the specified flag is set on the specified class
|
static boolean |
hasFlag(org.spongepowered.asm.lib.tree.FieldNode field,
int flag)
Check whether the specified flag is set on the specified field
|
static boolean |
hasFlag(org.spongepowered.asm.lib.tree.MethodNode method,
int flag)
Check whether the specified flag is set on the specified method
|
static boolean |
isConstant(org.spongepowered.asm.lib.tree.AbstractInsnNode insn)
Gets whether the supplied instruction is a constant instruction (eg.
|
static void |
loadArgs(org.spongepowered.asm.lib.Type[] args,
org.spongepowered.asm.lib.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.spongepowered.asm.lib.Type[] args,
org.spongepowered.asm.lib.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 and ending at end
|
static void |
loadArgs(org.spongepowered.asm.lib.Type[] args,
org.spongepowered.asm.lib.tree.InsnList insns,
int start,
int end,
org.spongepowered.asm.lib.Type[] casts)
Injects appropriate LOAD opcodes into the supplied InsnList appropriate
for each entry in the args array starting at start and ending at end
|
static void |
mergeAnnotations(org.spongepowered.asm.lib.tree.ClassNode from,
org.spongepowered.asm.lib.tree.ClassNode to)
Merge annotations from the specified source ClassNode to the destination
ClassNode, replaces annotations of the equivalent type on the target with
annotations from the source.
|
static void |
mergeAnnotations(org.spongepowered.asm.lib.tree.FieldNode from,
org.spongepowered.asm.lib.tree.FieldNode to)
Merge annotations from the specified source FieldNode to the destination
FieldNode, replaces annotations of the equivalent type on the target with
annotations from the source.
|
static void |
mergeAnnotations(org.spongepowered.asm.lib.tree.MethodNode from,
org.spongepowered.asm.lib.tree.MethodNode to)
Merge annotations from the specified source MethodNode to the destination
MethodNode, replaces annotations of the equivalent type on the target
with annotations from the source.
|
static boolean |
methodHasLineNumbers(org.spongepowered.asm.lib.tree.MethodNode method)
Returns true if the supplied method contains any line number information
|
static boolean |
methodIsStatic(org.spongepowered.asm.lib.tree.MethodNode method)
Returns true if the supplied method node is static
|
static void |
printMethod(org.spongepowered.asm.lib.tree.MethodNode method)
Prints a representation of a method's instructions to stderr
|
static void |
printMethodWithOpcodeIndices(org.spongepowered.asm.lib.tree.MethodNode method)
Prints a representation of a method's instructions to stderr
|
static void |
printNode(org.spongepowered.asm.lib.tree.AbstractInsnNode node)
Prints a representation of the specified insn node to stderr
|
static void |
setVisibility(org.spongepowered.asm.lib.tree.FieldNode field,
Bytecode.Visibility visibility)
Set the visibility of the specified member, leaving other access flags
unchanged
|
static void |
setVisibility(org.spongepowered.asm.lib.tree.FieldNode field,
int access)
Set the visibility of the specified member, leaving other access flags
unchanged
|
static void |
setVisibility(org.spongepowered.asm.lib.tree.MethodNode method,
Bytecode.Visibility visibility)
Set the visibility of the specified member, leaving other access flags
unchanged
|
static void |
setVisibility(org.spongepowered.asm.lib.tree.MethodNode method,
int access)
Set the visibility of the specified member, leaving other access flags
unchanged
|
static void |
textify(org.spongepowered.asm.lib.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.spongepowered.asm.lib.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.spongepowered.asm.lib.tree.MethodNode findMethod(org.spongepowered.asm.lib.tree.ClassNode classNode,
java.lang.String name,
java.lang.String desc)
classNode - the class to scanname - the method namedesc - the method descriptorpublic static org.spongepowered.asm.lib.tree.AbstractInsnNode findInsn(org.spongepowered.asm.lib.tree.MethodNode method,
int opcode)
method - method to searchopcode - opcode to search forpublic static org.spongepowered.asm.lib.tree.MethodInsnNode findSuperInit(org.spongepowered.asm.lib.tree.MethodNode method,
java.lang.String superName)
method - ctor to scansuperName - name of superclasspublic static void textify(org.spongepowered.asm.lib.tree.ClassNode classNode,
java.io.OutputStream out)
classNode - class to textifyout - output streampublic static void textify(org.spongepowered.asm.lib.tree.MethodNode methodNode,
java.io.OutputStream out)
methodNode - method to textifyout - output streampublic static void dumpClass(org.spongepowered.asm.lib.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.spongepowered.asm.lib.tree.MethodNode method)
method - Method to printpublic static void printMethod(org.spongepowered.asm.lib.tree.MethodNode method)
method - Method to printpublic static void printNode(org.spongepowered.asm.lib.tree.AbstractInsnNode node)
node - Node to printpublic static java.lang.String describeNode(org.spongepowered.asm.lib.tree.AbstractInsnNode node)
node - node to describepublic static java.lang.String getOpcodeName(org.spongepowered.asm.lib.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.spongepowered.asm.lib.tree.MethodNode method)
method - Method to scanpublic static boolean methodIsStatic(org.spongepowered.asm.lib.tree.MethodNode method)
method - method nodeOpcodes.ACC_STATIC flagpublic static boolean fieldIsStatic(org.spongepowered.asm.lib.tree.FieldNode field)
field - field nodeOpcodes.ACC_STATIC flagpublic static int getFirstNonArgLocalIndex(org.spongepowered.asm.lib.tree.MethodNode method)
method - MethodNode to inspectpublic static int getFirstNonArgLocalIndex(org.spongepowered.asm.lib.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.spongepowered.asm.lib.Type[] args)
args - Method argument types as arraypublic static void loadArgs(org.spongepowered.asm.lib.Type[] args,
org.spongepowered.asm.lib.tree.InsnList insns,
int pos)
args - Argument typesinsns - Instruction List to inject intopos - Start positionpublic static void loadArgs(org.spongepowered.asm.lib.Type[] args,
org.spongepowered.asm.lib.tree.InsnList insns,
int start,
int end)
args - Argument typesinsns - Instruction List to inject intostart - Start positionend - End positionpublic static void loadArgs(org.spongepowered.asm.lib.Type[] args,
org.spongepowered.asm.lib.tree.InsnList insns,
int start,
int end,
org.spongepowered.asm.lib.Type[] casts)
args - Argument typesinsns - Instruction List to inject intostart - Start positionend - End positioncasts - Type casts arraypublic static java.util.Map<org.spongepowered.asm.lib.tree.LabelNode,org.spongepowered.asm.lib.tree.LabelNode> cloneLabels(org.spongepowered.asm.lib.tree.InsnList source)
AbstractInsnNode.clone(java.util.Map<org.spongepowered.asm.lib.tree.LabelNode, org.spongepowered.asm.lib.tree.LabelNode>).source - instruction listpublic 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.spongepowered.asm.lib.Type[] args)
args - argument typespublic static java.lang.String getDescriptor(org.spongepowered.asm.lib.Type[] args,
org.spongepowered.asm.lib.Type returnType)
args - argument typesreturnType - return typepublic 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.spongepowered.asm.lib.tree.AnnotationNode annotation)
annotation - annotation nodepublic static java.lang.String getSimpleName(java.lang.String desc)
desc - type descriptorpublic static boolean isConstant(org.spongepowered.asm.lib.tree.AbstractInsnNode insn)
insn - instruction to checkpublic static java.lang.Object getConstant(org.spongepowered.asm.lib.tree.AbstractInsnNode insn)
insn - constant instruction to processpublic static org.spongepowered.asm.lib.Type getConstantType(org.spongepowered.asm.lib.tree.AbstractInsnNode insn)
Type of a particular constant instruction's payloadinsn - constant instructionpublic static boolean hasFlag(org.spongepowered.asm.lib.tree.ClassNode classNode,
int flag)
classNode - class nodeflag - flag to checkpublic static boolean hasFlag(org.spongepowered.asm.lib.tree.MethodNode method,
int flag)
method - method nodeflag - flag to checkpublic static boolean hasFlag(org.spongepowered.asm.lib.tree.FieldNode field,
int flag)
field - field nodeflag - flag to checkpublic static boolean compareFlags(org.spongepowered.asm.lib.tree.MethodNode m1,
org.spongepowered.asm.lib.tree.MethodNode m2,
int flag)
m1 - First methodm2 - Second methodflag - flag to comparepublic static boolean compareFlags(org.spongepowered.asm.lib.tree.FieldNode f1,
org.spongepowered.asm.lib.tree.FieldNode f2,
int flag)
f1 - First fieldf2 - Second fieldflag - flag to comparepublic static Bytecode.Visibility getVisibility(org.spongepowered.asm.lib.tree.MethodNode method)
method - method to get visibility forpublic static Bytecode.Visibility getVisibility(org.spongepowered.asm.lib.tree.FieldNode field)
field - field to get visibility forpublic static void setVisibility(org.spongepowered.asm.lib.tree.MethodNode method,
Bytecode.Visibility visibility)
method - method to changevisibility - new visibilitypublic static void setVisibility(org.spongepowered.asm.lib.tree.FieldNode field,
Bytecode.Visibility visibility)
field - field to changevisibility - new visibilitypublic static void setVisibility(org.spongepowered.asm.lib.tree.MethodNode method,
int access)
method - method to changeaccess - new visibilitypublic static void setVisibility(org.spongepowered.asm.lib.tree.FieldNode field,
int access)
field - field to changeaccess - new visibilitypublic static int getMaxLineNumber(org.spongepowered.asm.lib.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.spongepowered.asm.lib.Type type)
type - type to boxpublic static java.lang.String getUnboxingMethod(org.spongepowered.asm.lib.Type type)
type - primitive type to get unboxing method forpublic static void mergeAnnotations(org.spongepowered.asm.lib.tree.ClassNode from,
org.spongepowered.asm.lib.tree.ClassNode to)
from - ClassNode to merge annotations fromto - ClassNode to merge annotations topublic static void mergeAnnotations(org.spongepowered.asm.lib.tree.MethodNode from,
org.spongepowered.asm.lib.tree.MethodNode to)
from - MethodNode to merge annotations fromto - MethodNode to merge annotations topublic static void mergeAnnotations(org.spongepowered.asm.lib.tree.FieldNode from,
org.spongepowered.asm.lib.tree.FieldNode to)
from - FieldNode to merge annotations fromto - FieldNode to merge annotations topublic static void compareBridgeMethods(org.spongepowered.asm.lib.tree.MethodNode a,
org.spongepowered.asm.lib.tree.MethodNode b)
a - Incumbent methodb - Incoming method