Class Constructor

  • All Implemented Interfaces:
    java.lang.Comparable<Target>, java.lang.Iterable<org.objectweb.asm.tree.AbstractInsnNode>

    public class Constructor
    extends Target
    A Target which is a constructor
    • Constructor Detail

      • Constructor

        public Constructor​(ClassInfo classInfo,
                           org.objectweb.asm.tree.ClassNode classNode,
                           org.objectweb.asm.tree.MethodNode method)
    • Method Detail

      • findDelegateInitNode

        public Bytecode.DelegateInitialiser findDelegateInitNode()
        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.
        Returns:
        Call to super(), this() or DelegateInitialiser.NONE if not found
      • isInjectable

        public boolean isInjectable()
        Get whether this constructor should have mixin initialisers injected into it based on whether a delegate initialiser call is absent or is a call to super()
      • findInitialiserInjectionPoint

        public org.objectweb.asm.tree.AbstractInsnNode findInitialiserInjectionPoint​(Initialiser.InjectionMode mode)
        Find the injection point for injected initialiser insns in the target ctor. This starts by assuming that initialiser instructions should be placed immediately after the delegate initialiser call, but then searches for field assignments and selects the last unique field assignment in the ctor body which represents a reasonable heuristic for the end of the existing initialisers.
        Parameters:
        mode - Injection mode for this specific environment
        Returns:
        target node
      • findFirstBodyInsn

        public org.objectweb.asm.tree.AbstractInsnNode findFirstBodyInsn()
        Find the injection point
      • getRange

        public static InsnRange getRange​(org.objectweb.asm.tree.MethodNode ctor)
        Identifies line numbers in the supplied ctor which correspond to the start and end of the method body.
        Parameters:
        ctor - constructor to scan
        Returns:
        range indicating the line numbers of the specified constructor and the position of the superclass ctor invocation