Class ConstructorHead
java.lang.Object
org.spongepowered.asm.mixin.injection.InjectionPoint
org.spongepowered.asm.mixin.injection.points.MethodHead
org.spongepowered.asm.mixin.injection.points.ConstructorHead
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")
-
Nested Class Summary
Nested classes/interfaces inherited from class org.spongepowered.asm.mixin.injection.InjectionPoint
InjectionPoint.AtCode, InjectionPoint.Flags, InjectionPoint.RestrictTargetLevel, InjectionPoint.Specifier -
Field Summary
FieldsFields inherited from class org.spongepowered.asm.mixin.injection.InjectionPoint
DEFAULT_ALLOWED_SHIFT_BY, MAX_ALLOWED_SHIFT_BY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanfind(String desc, org.objectweb.asm.tree.InsnList insns, Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes) Find injection points in the supplied insn listMethods inherited from class org.spongepowered.asm.mixin.injection.points.MethodHead
checkPriorityMethods inherited from class org.spongepowered.asm.mixin.injection.InjectionPoint
addMessage, after, and, before, getAtCode, getId, getSlice, getSpecifier, getTargetRestriction, nextNode, or, parse, parse, parse, parse, parse, parse, parse, parse, register, register, setTargetRestriction, shift, toString
-
Field Details
-
logger
Logger
-
-
Constructor Details
-
ConstructorHead
-
-
Method Details
-
find
public boolean find(String desc, org.objectweb.asm.tree.InsnList insns, Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes) Description copied from class:InjectionPointFind injection points in the supplied insn list- Overrides:
findin classMethodHead- Parameters:
desc- Method descriptor, supplied to allow return types and arguments etc. to be determinedinsns- Insn list to search in, the strategy MUST ONLY add nodes from this list to thenodescollectionnodes- 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
-