Class Bytecode


  • public final class Bytecode
    extends java.lang.Object
    Utility methods for working with bytecode via ASM
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method 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 java.lang.String describeNode​(org.objectweb.asm.tree.AbstractInsnNode node, boolean listFormat)
      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​(int opcode)
      Finds a constant name match for the supplied node's opcode
      static java.lang.String getOpcodeName​(org.objectweb.asm.tree.AbstractInsnNode node)
      Finds a constant name match for the supplied node's opcode
      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 org.objectweb.asm.Type[] getTypes​(java.lang.Class<?>... classes)
      Get an array of Types from an array of classes.
      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": Bytecode.Visibility.PRIVATE Bytecode.Visibility.PROTECTED Bytecode.Visibility.PACKAGE Bytecode.Visibility.PUBLIC
      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": Bytecode.Visibility.PRIVATE Bytecode.Visibility.PROTECTED Bytecode.Visibility.PACKAGE Bytecode.Visibility.PUBLIC
      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 int parseOpcodeName​(java.lang.String opcodeName)
      Finds a matching constant in the Opcodes interface for the specified opcode name.
      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.ClassNode classNode, int access)
      Set the visibility of the specified class, leaving other access flags unchanged
      static void setVisibility​(org.objectweb.asm.tree.ClassNode classNode, Bytecode.Visibility visibility)
      Set the visibility of the specified class, 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.FieldNode field, 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 setVisibility​(org.objectweb.asm.tree.MethodNode method, Bytecode.Visibility visibility)
      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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CONSTANTS_INT

        public static final int[] CONSTANTS_INT
        Integer constant opcodes
      • CONSTANTS_FLOAT

        public static final int[] CONSTANTS_FLOAT
        Float constant opcodes
      • CONSTANTS_DOUBLE

        public static final int[] CONSTANTS_DOUBLE
        Double constant opcodes
      • CONSTANTS_LONG

        public static final int[] CONSTANTS_LONG
        Long constant opcodes
      • CONSTANTS_ALL

        public static final int[] CONSTANTS_ALL
        All constant opcodes
    • Method Detail

      • findMethod

        public 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
        Parameters:
        classNode - the class to scan
        name - the method name
        desc - the method descriptor
        Returns:
        discovered method node or null
      • findInsn

        public 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
        Parameters:
        method - method to search
        opcode - opcode to search for
        Returns:
        found node or null if not found
      • findDelegateInit

        public 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. This attempts to locate the first call to <init> which isn't an inline call to another object ctor being passed into the super invocation.
        Parameters:
        ctor - ctor to scan
        superName - name of superclass
        ownerName - name of owning class
        Returns:
        Call to super(), this() or DelegateInitialiser.NONE if not found
      • textify

        public 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
        Parameters:
        classNode - class to textify
        out - output stream
      • textify

        public 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
        Parameters:
        methodNode - method to textify
        out - output stream
      • dumpClass

        public static void dumpClass​(org.objectweb.asm.tree.ClassNode classNode)
        Dumps the output of CheckClassAdapter.verify to System.out
        Parameters:
        classNode - the ClassNode to verify
      • dumpClass

        public static void dumpClass​(byte[] bytes)
        Dumps the output of CheckClassAdapter.verify to System.out
        Parameters:
        bytes - the bytecode of the class to check
      • printMethodWithOpcodeIndices

        public static void printMethodWithOpcodeIndices​(org.objectweb.asm.tree.MethodNode method)
        Prints a representation of a method's instructions to stderr
        Parameters:
        method - Method to print
      • printMethod

        public static void printMethod​(org.objectweb.asm.tree.MethodNode method)
        Prints a representation of a method's instructions to stderr
        Parameters:
        method - Method to print
      • printNode

        public static void printNode​(org.objectweb.asm.tree.AbstractInsnNode node)
        Prints a representation of the specified insn node to stderr
        Parameters:
        node - Node to print
      • describeNode

        public static java.lang.String describeNode​(org.objectweb.asm.tree.AbstractInsnNode node)
        Gets a description of the supplied node for debugging purposes
        Parameters:
        node - node to describe
        Returns:
        human-readable description of node
      • describeNode

        public static java.lang.String describeNode​(org.objectweb.asm.tree.AbstractInsnNode node,
                                                    boolean listFormat)
        Gets a description of the supplied node for debugging purposes
        Parameters:
        node - node to describe
        listFormat - format the returned string so that returned nodes line up (node names aligned to 14 chars)
        Returns:
        human-readable description of node
      • getOpcodeName

        public static java.lang.String getOpcodeName​(org.objectweb.asm.tree.AbstractInsnNode node)
        Finds a constant name match for the supplied node's opcode
        Parameters:
        node - Node to query for opcode
        Returns:
        opcode name
      • getOpcodeName

        public static java.lang.String getOpcodeName​(int opcode)
        Finds a constant name match for the supplied node's opcode
        Parameters:
        opcode - Opcode to look up
        Returns:
        opcode name
      • parseOpcodeName

        public static int parseOpcodeName​(java.lang.String opcodeName)
        Finds a matching constant in the Opcodes interface for the specified opcode name. Supported formats are raw numeric values, bare constant names (eg. ACONST_NULL) or qualified names (eg. Opcodes.ACONST_NULL). Returns the value if found or -1 if not matched. Note that no validation is performed on numeric opcode values.
        Parameters:
        opcodeName - Opcode string to match
        Returns:
        matched opcode value or -1 if not matched.
      • methodHasLineNumbers

        public static boolean methodHasLineNumbers​(org.objectweb.asm.tree.MethodNode method)
        Returns true if the supplied method contains any line number information
        Parameters:
        method - Method to scan
        Returns:
        true if a line number node is located
      • isStatic

        public static boolean isStatic​(org.objectweb.asm.tree.MethodNode method)
        Returns true if the supplied method node is static
        Parameters:
        method - method node
        Returns:
        true if the method has the Opcodes.ACC_STATIC flag
      • isStatic

        public static boolean isStatic​(org.objectweb.asm.tree.FieldNode field)
        Returns true if the supplied field node is static
        Parameters:
        field - field node
        Returns:
        true if the field has the Opcodes.ACC_STATIC flag
      • getFirstNonArgLocalIndex

        public 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
        Parameters:
        method - MethodNode to inspect
        Returns:
        first available local index which is NOT used by a method argument or "this"
      • getFirstNonArgLocalIndex

        public 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
        Parameters:
        args - Method arguments
        includeThis - Whether to include a slot for "this" (generally true for all non-static methods)
        Returns:
        first available local index which is NOT used by a method argument or "this"
      • getArgsSize

        public static int getArgsSize​(org.objectweb.asm.Type[] args)
        Get the size of the specified args array in local variable terms (eg. doubles and longs take two spaces)
        Parameters:
        args - Method argument types as array
        Returns:
        size of the specified arguments array in terms of stack slots
      • getArgsSize

        public 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. doubles and longs take two spaces) using startIndex (inclusive) and endIndex (exclusive) to determine which arguments to process.
        Parameters:
        args - Method argument types as array
        startIndex - Start index in the array, not related to arg size
        endIndex - End index (exclusive) in the array, not related to size
        Returns:
        size of the specified arguments array in terms of stack slots
      • loadArgs

        public 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
        Parameters:
        args - Argument types
        insns - Instruction List to inject into
        pos - Start position
      • loadArgs

        public 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)
        Parameters:
        args - Argument types
        insns - Instruction List to inject into
        start - Start position
        end - End position
      • loadArgs

        public 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)
        Parameters:
        args - Argument types
        insns - Instruction List to inject into
        start - Start position
        end - End position
        casts - Type casts array
      • getTypes

        public static org.objectweb.asm.Type[] getTypes​(java.lang.Class<?>... classes)
        Get an array of Types from an array of classes.
        Parameters:
        classes - Array of classes to convert
        Returns:
        Array of types
      • cloneLabels

        public 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. This is used to facilitate the use of AbstractInsnNode.clone(java.util.Map<org.objectweb.asm.tree.LabelNode, org.objectweb.asm.tree.LabelNode>).
        Parameters:
        source - instruction list
        Returns:
        map of existing labels to their cloned counterparts
      • generateDescriptor

        public static java.lang.String generateDescriptor​(org.objectweb.asm.Type returnType,
                                                          org.objectweb.asm.Type... args)
        Generate a bytecode descriptor from the supplied types.
        Parameters:
        returnType - the method return type, can be null for void
        args - argument types
      • generateDescriptor

        public static java.lang.String generateDescriptor​(java.lang.Object returnType,
                                                          java.lang.Object... args)
        Generate a bytecode descriptor from the supplied tokens. Each token can be a Type, a Class or otherwise is converted in-place by calling toString.
        Parameters:
        returnType - object representing the method return type, can be null for void
        args - objects representing argument types
      • getDescriptor

        public static java.lang.String getDescriptor​(org.objectweb.asm.Type... args)
        Generate a method descriptor without return type for the supplied args array
        Parameters:
        args - argument types
        Returns:
        method descriptor without return type
      • getDescriptor

        public static java.lang.String getDescriptor​(org.objectweb.asm.Type returnType,
                                                     org.objectweb.asm.Type... args)
        Generate a method descriptor with the specified types
        Parameters:
        returnType - return type
        args - argument types
        Returns:
        generated method descriptor
      • changeDescriptorReturnType

        public 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
        Parameters:
        desc - descriptor to modify
        returnType - new return type
        Returns:
        modified descriptor;
      • getSimpleName

        public static java.lang.String getSimpleName​(org.objectweb.asm.Type type)
        Returns the simple name of a type representing a class
        Parameters:
        type - type
        Returns:
        annotation's simple name
      • getSimpleName

        public static java.lang.String getSimpleName​(java.lang.String desc)
        Returns the simple name from an object type descriptor (in L...; format)
        Parameters:
        desc - type descriptor
        Returns:
        "simple" name
      • isConstant

        public static boolean isConstant​(org.objectweb.asm.tree.AbstractInsnNode insn)
        Gets whether the supplied instruction is a constant instruction (eg. ICONST_1)
        Parameters:
        insn - instruction to check
        Returns:
        true if the supplied instruction is a constant
      • getConstant

        public 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
        Parameters:
        insn - constant instruction to process
        Returns:
        the constant value or null if the value cannot be parsed (null constant is returned as Type.VOID_TYPE)
      • getConstantType

        public static org.objectweb.asm.Type getConstantType​(org.objectweb.asm.tree.AbstractInsnNode insn)
        Returns the Type of a particular constant instruction's payload
        Parameters:
        insn - constant instruction
        Returns:
        type of constant or null if it cannot be parsed ( null constant is returned as Type.VOID_TYPE)
      • hasFlag

        public static boolean hasFlag​(org.objectweb.asm.tree.ClassNode classNode,
                                      int flag)
        Check whether the specified flag is set on the specified class
        Parameters:
        classNode - class node
        flag - flag to check
        Returns:
        True if the specified flag is set in this method's access flags
      • hasFlag

        public static boolean hasFlag​(org.objectweb.asm.tree.MethodNode method,
                                      int flag)
        Check whether the specified flag is set on the specified method
        Parameters:
        method - method node
        flag - flag to check
        Returns:
        True if the specified flag is set in this method's access flags
      • hasFlag

        public static boolean hasFlag​(org.objectweb.asm.tree.FieldNode field,
                                      int flag)
        Check whether the specified flag is set on the specified field
        Parameters:
        field - field node
        flag - flag to check
        Returns:
        True if the specified flag is set in this field's access flags
      • compareFlags

        public 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.
        Parameters:
        m1 - First method
        m2 - Second method
        flag - flag to compare
        Returns:
        True if the flag is set to the same value on both members
      • compareFlags

        public 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.
        Parameters:
        f1 - First field
        f2 - Second field
        flag - flag to compare
        Returns:
        True if the flag is set to the same value on both members
      • isVirtual

        public static boolean isVirtual​(org.objectweb.asm.tree.MethodNode method)
        Checks whether the supplied method is virtual. Specifically this method returns true if the method is non-static and has an access level greater than private.
        Parameters:
        method - Method to test
        Returns:
        true if virtual
      • setVisibility

        public static void setVisibility​(org.objectweb.asm.tree.ClassNode classNode,
                                         Bytecode.Visibility visibility)
        Set the visibility of the specified class, leaving other access flags unchanged
        Parameters:
        classNode - class to change
        visibility - new visibility
      • setVisibility

        public static void setVisibility​(org.objectweb.asm.tree.MethodNode method,
                                         Bytecode.Visibility visibility)
        Set the visibility of the specified member, leaving other access flags unchanged
        Parameters:
        method - method to change
        visibility - new visibility
      • setVisibility

        public static void setVisibility​(org.objectweb.asm.tree.FieldNode field,
                                         Bytecode.Visibility visibility)
        Set the visibility of the specified member, leaving other access flags unchanged
        Parameters:
        field - field to change
        visibility - new visibility
      • setVisibility

        public static void setVisibility​(org.objectweb.asm.tree.ClassNode classNode,
                                         int access)
        Set the visibility of the specified class, leaving other access flags unchanged
        Parameters:
        classNode - class to change
        access - new visibility
      • setVisibility

        public static void setVisibility​(org.objectweb.asm.tree.MethodNode method,
                                         int access)
        Set the visibility of the specified member, leaving other access flags unchanged
        Parameters:
        method - method to change
        access - new visibility
      • setVisibility

        public static void setVisibility​(org.objectweb.asm.tree.FieldNode field,
                                         int access)
        Set the visibility of the specified member, leaving other access flags unchanged
        Parameters:
        field - field to change
        access - new visibility
      • getMaxLineNumber

        public static int getMaxLineNumber​(org.objectweb.asm.tree.ClassNode classNode,
                                           int min,
                                           int pad)
        Compute the largest line number found in the specified class
        Parameters:
        classNode - Class to inspect
        min - minimum value to return
        pad - amount to pad at the end of files
        Returns:
        computed max
      • getBoxingType

        public static java.lang.String getBoxingType​(org.objectweb.asm.Type type)
        Get the boxing type name for the specified type, if it is a primitive. For non-primitive types, null is returned
        Parameters:
        type - type to box
        Returns:
        boxing type or null
      • getUnboxingMethod

        public static java.lang.String getUnboxingMethod​(org.objectweb.asm.Type type)
        Get the unboxing method name for the specified primitive type's corresponding reference type. For example, if the type passed in is int, then the return value will be intValue. Returns null for non-primitive types.
        Parameters:
        type - primitive type to get unboxing method for
        Returns:
        unboxing method name or null
      • compareBridgeMethods

        public 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.
        Parameters:
        a - Incumbent method
        b - Incoming method
      • merge

        public 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
        Parameters:
        source - Source ClassNode to merge from
        dest - Destination ClassNode to merge to
      • replace

        public 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
        Parameters:
        source - Source ClassNode to merge from
        dest - Destination ClassNode to merge to