Class ConstructorHead


  • public class ConstructorHead
    extends MethodHead

    Like HEAD, this injection point can be used to specify the first instruction in a method, but provides special handling for constructors. For regular method, the behaviour is identical to HEAD .

    By default, this injection point attempts to select the first instruction after any initialisers (including initialisers merged by mixins) but will fall back to selecting the first instruction after the delegate call (eg. a call to super() or this()) in the case where heuristic detection of the initialisers fails. This behaviour can be overridden by providing the enforce parameter to enforce selection of a specific location.

    enforce=POST_DELEGATE
    Select the instruction immediately after the delegate constructor
    enforce=POST_MIXIN
    Select the instruction immediately after all mixin-initialised field initialisers, this is similar to POST_DELEGATE if no applied mixins have initialisers for target class fields, except that the injection point will be after any mixin-supplied initialisers.
    enforce=PRE_BODY
    Selects the first instruction in the target method body, as determined by the line numbers. If the target method does not have line numbers available, the result is equivalent to POST_DELEGATE.

    Example default behaviour:

       @At(value = "CTOR_HEAD", unsafe = true)

    Example behaviour enforcing post-delegate injection point:

       @At(value = "CTOR_HEAD", unsafe = true, args="enforce=POST_DELEGATE")
       
    • Field Detail

      • logger

        protected final ILogger logger
        Logger
    • Method Detail

      • find

        public boolean find​(java.lang.String desc,
                            org.objectweb.asm.tree.InsnList insns,
                            java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes)
        Description copied from class: InjectionPoint
        Find injection points in the supplied insn list
        Overrides:
        find in class MethodHead
        Parameters:
        desc - Method descriptor, supplied to allow return types and arguments etc. to be determined
        insns - Insn list to search in, the strategy MUST ONLY add nodes from this list to the nodes collection
        nodes - Collection of nodes to populate. Injectors should NOT make any assumptions about the state of this collection and should only call the add() method
        Returns:
        true if one or more injection points were found