Class ElementNode<TNode>

  • Type Parameters:
    TNode - node type

    public abstract class ElementNode<TNode>
    extends java.lang.Object
    Wrapper for all node types supported by target selectors (FieldNode, MethodNode, FieldInsnNode, MethodInsnNode and InvokeDynamicInsnNode) which allows access to common properties of things which are basically "arbitrary node with owner, name and descriptor"
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ElementNode.NodeType
      Element node type, returned by getType so consumers don't need to do instanceof checks, and allows switching on element type in a more expressive way
    • Constructor Summary

      Constructors 
      Constructor Description
      ElementNode()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Iterable<ElementNode<org.objectweb.asm.tree.AbstractInsnNode>> dynamicInsnList​(org.objectweb.asm.tree.InsnList insns)
      Get a wrapped version of the supplied insn list which returns element nodes for every INVOKEDYNAMIC instruction only
      static java.util.List<ElementNode<org.objectweb.asm.tree.FieldNode>> fieldList​(org.objectweb.asm.tree.ClassNode owner)
      Get a list of wrapped ElementNodes for the fields of the supplied owner class
      abstract TNode get()
      Returns the node with horrible duck typing
      java.lang.String getDelegateDesc()
      For INVOKEDYNAMIC elements, returns original descriptor of the delegate.
      abstract java.lang.String getDesc()
      Get the element descriptor.
      org.objectweb.asm.tree.FieldNode getField()
      Get the FieldNode if this member is a field, otherwise returns null
      java.lang.String getImplDesc()
      For INVOKEDYNAMIC elements, returns specialised descriptor of the delegate (lambda descriptor without prepended captures), can be the same as the delegate descriptor or more specialised.
      org.objectweb.asm.tree.AbstractInsnNode getInsn()
      Get the instruction if this member is an insn, otherwise returns null
      org.objectweb.asm.tree.MethodNode getMethod()
      Get the MethodNode if this member is a method, otherwise returns null
      abstract java.lang.String getName()
      Get the element name
      abstract java.lang.String getOwner()
      Get the element owner's name, if this element has an owner, otherwise returns null
      abstract java.lang.String getSignature()
      Get the element signature, can be null
      java.lang.String getSyntheticName()
      Get the synthetic element name.
      abstract ElementNode.NodeType getType()
      Get the type of this ElementNode, the return value can be used to determine which accessor (getMethod(), getField()
      static java.lang.Iterable<ElementNode<org.objectweb.asm.tree.AbstractInsnNode>> insnList​(org.objectweb.asm.tree.InsnList insns)
      Get a wrapped version of the supplied insn list which returns element nodes for each (supported) instruction (FieldInsnNode, MethodInsnNode and InvokeDynamicInsnNode).
      boolean isField()
      Get whether this element is a field type and the descriptor is a bare type descriptor without arguments.
      static <TNode> java.util.List<ElementNode<TNode>> listOf​(org.objectweb.asm.tree.ClassNode owner, java.util.List<TNode> list)
      Convert the supplied list of nodes to a list of wrapped ElementNodes
      static java.util.List<ElementNode<org.objectweb.asm.tree.MethodNode>> methodList​(org.objectweb.asm.tree.ClassNode owner)
      Get a list of wrapped ElementNodes for the methods of the supplied owner class
      static ElementNode<org.objectweb.asm.tree.FieldNode> of​(org.objectweb.asm.tree.ClassNode owner, org.objectweb.asm.tree.FieldNode field)
      Create an ElementNode wrapper for the supplied field node
      static ElementNode<org.objectweb.asm.tree.MethodNode> of​(org.objectweb.asm.tree.ClassNode owner, org.objectweb.asm.tree.MethodNode method)
      Create an ElementNode wrapper for the supplied method node
      static <TNode> ElementNode<TNode> of​(org.objectweb.asm.tree.ClassNode owner, TNode node)
      Create an ElementNode wrapper for the supplied node object
      static <TNode extends org.objectweb.asm.tree.AbstractInsnNode>
      ElementNode<TNode>
      of​(TNode node)
      Create an ElementNode wrapper for the supplied node object
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ElementNode

        public ElementNode()
    • Method Detail

      • isField

        public boolean isField()
        Get whether this element is a field type and the descriptor is a bare type descriptor without arguments. Otherwise assumes the descriptor is a method descriptor.
      • getMethod

        public org.objectweb.asm.tree.MethodNode getMethod()
        Get the MethodNode if this member is a method, otherwise returns null
      • getField

        public org.objectweb.asm.tree.FieldNode getField()
        Get the FieldNode if this member is a field, otherwise returns null
      • getInsn

        public org.objectweb.asm.tree.AbstractInsnNode getInsn()
        Get the instruction if this member is an insn, otherwise returns null
      • getOwner

        public abstract java.lang.String getOwner()
        Get the element owner's name, if this element has an owner, otherwise returns null
      • getName

        public abstract java.lang.String getName()
        Get the element name
      • getSyntheticName

        public java.lang.String getSyntheticName()
        Get the synthetic element name. For INVOKEDYNAMIC elements this is the real name of the lambda method implementing the delegate.
      • getDesc

        public abstract java.lang.String getDesc()
        Get the element descriptor. For INVOKEDYNAMIC this is the full descriptor of the lambda (including prepended captures).
      • getDelegateDesc

        public java.lang.String getDelegateDesc()
        For INVOKEDYNAMIC elements, returns original descriptor of the delegate.
      • getImplDesc

        public java.lang.String getImplDesc()
        For INVOKEDYNAMIC elements, returns specialised descriptor of the delegate (lambda descriptor without prepended captures), can be the same as the delegate descriptor or more specialised.
      • getSignature

        public abstract java.lang.String getSignature()
        Get the element signature, can be null
      • get

        public abstract TNode get()
        Returns the node with horrible duck typing
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • of

        public static ElementNode<org.objectweb.asm.tree.MethodNode> of​(org.objectweb.asm.tree.ClassNode owner,
                                                                        org.objectweb.asm.tree.MethodNode method)
        Create an ElementNode wrapper for the supplied method node
        Parameters:
        owner - class which owns the method or null
        method - Method node to wrap
        Returns:
        ElementNode
      • of

        public static ElementNode<org.objectweb.asm.tree.FieldNode> of​(org.objectweb.asm.tree.ClassNode owner,
                                                                       org.objectweb.asm.tree.FieldNode field)
        Create an ElementNode wrapper for the supplied field node
        Parameters:
        owner - class which owns the field or null
        field - Field node to wrap
        Returns:
        ElementNode
      • of

        public static <TNode> ElementNode<TNode> of​(org.objectweb.asm.tree.ClassNode owner,
                                                    TNode node)
        Create an ElementNode wrapper for the supplied node object
        Type Parameters:
        TNode - Node type
        Parameters:
        owner - class which owns the node or null
        node - Node to wrap
        Returns:
        ElementNode
        Throws:
        java.lang.IllegalArgumentException - if the supplied argument is not a MethodNode or FieldNode
      • of

        public static <TNode extends org.objectweb.asm.tree.AbstractInsnNode> ElementNode<TNode> of​(TNode node)
        Create an ElementNode wrapper for the supplied node object
        Type Parameters:
        TNode - Node type
        Parameters:
        node - Node to wrap
        Returns:
        ElementNode
        Throws:
        java.lang.IllegalArgumentException - if the supplied argument is not a MethodNode or FieldNode
      • listOf

        public static <TNode> java.util.List<ElementNode<TNode>> listOf​(org.objectweb.asm.tree.ClassNode owner,
                                                                        java.util.List<TNode> list)
        Convert the supplied list of nodes to a list of wrapped ElementNodes
        Type Parameters:
        TNode - Node type
        Parameters:
        owner - Owner of the supplied nodes, can be null
        list - List of nodes
        Returns:
        List of wrapped nodes
      • fieldList

        public static java.util.List<ElementNode<org.objectweb.asm.tree.FieldNode>> fieldList​(org.objectweb.asm.tree.ClassNode owner)
        Get a list of wrapped ElementNodes for the fields of the supplied owner class
        Parameters:
        owner - Class to get fields, must not be null
        Returns:
        List of wrapped nodes
      • methodList

        public static java.util.List<ElementNode<org.objectweb.asm.tree.MethodNode>> methodList​(org.objectweb.asm.tree.ClassNode owner)
        Get a list of wrapped ElementNodes for the methods of the supplied owner class
        Parameters:
        owner - Class to get methods, must not be null
        Returns:
        List of wrapped nodes
      • insnList

        public static java.lang.Iterable<ElementNode<org.objectweb.asm.tree.AbstractInsnNode>> insnList​(org.objectweb.asm.tree.InsnList insns)
        Get a wrapped version of the supplied insn list which returns element nodes for each (supported) instruction (FieldInsnNode, MethodInsnNode and InvokeDynamicInsnNode).
        Parameters:
        insns - Insn list to wrap
        Returns:
        Wrapper for insn list
      • dynamicInsnList

        public static java.lang.Iterable<ElementNode<org.objectweb.asm.tree.AbstractInsnNode>> dynamicInsnList​(org.objectweb.asm.tree.InsnList insns)
        Get a wrapped version of the supplied insn list which returns element nodes for every INVOKEDYNAMIC instruction only
        Parameters:
        insns - Insn list to wrap
        Returns:
        Wrapper for insn list