Table of Contents

:!: This page is a draft, and as such is not intended to be viewed by most of the Wiki readers!

Injectors (DRAFT)

Mixin provides many ways to modify classes, but the one modders should prioritize the most is injectors. Injectors are a type of tool which includes @Inject, @WrapOperation, @ModifyArg to only mention a few.
Injectors are characterized by the fact that they do not remove any of the target class's bytecode. This allows for highly compatible modifications that can chain with others directed at the same target. Following the broader principle that Mixin modifications should be as compatible and precise as possible, injectors are therefore the primary tool for adding new operations or modifying existing ones.

Injectors make modifications to methods in the target class's bytecode, this includes synthetic methods like lambdas or areas of a class that are implicitly a method such as the static initializer containing a class's field.

Structure

In the Mixin Class

In the source code of a Mixin class, an injector consists of two elements: the annotation, and the “handler” method, also called just the handler, decorated by the annotation. The typical structure of an injector's annotation and method will look as follows:

@InjectorAnnotation(method = "<target method name or descriptor>", at = @At(value = "<INJECTION POINT>"))
private ReturnType handlerMethod(<Parameters>) {
 
}

The handler method's return type and parameters are highly dependent on the specific injector, as they vary based on how the handler method is integrated into the