Table of Contents
this page is a draft! Feedback is appreciated but the page is currently not ready to be read by users of the Wiki!
Mixin Glossary (DRAFT)
Preamble
This page aims to address terms, acronyms, abbreviations, expressions, etc. and define them within as broad a scope as possible without instructing how to use the associated tools. It is complementary to actual documentation on how to use the tools and subsystem of Mixin and should only be used to get a quick, general idea of what a term means in the context of Mixin usage and learning. This glossary should also be taken with a grain of salt, as much as feedback will try to be used to make the definitions as accurate as possible, it can be as unreliable as any Wiki page.
It is advised to read the Introduction to Mixins (WIP) page.
Contributing
Seeing as this page is likely to change a lot with time as terms, both official and common usage ones, may vary over time and need many amendments as both Mixin and associated libraries evolve and get used in different contexts; it feels wise to add a section on best practices for contributing to this page in the long run.
If you wish to contribute it is appreciated to use references to external sources when relevant, preferably the official Mixin Wiki, the Mixin javadoc and the official MixinExtras Wiki. If not, base your definitions on feedback from experienced devs and be willing to be scrutinized.
Due to the amount of potential areas that could be edited, it would also be appreciated to always specify which definitions you're adding or editing in your edit summary messages. If necessary, split your edit into different smaller edits to be able to more clearly indicate which definitions were modified.
Formatting and TODOs
When you are doubtful on a term's definition, add a FIXME above the relevant text with text in italics until a more confident definition can be found. Definitions should generally take the form of itemized lists with the term above the list's first items. Synonyms should be grouped together. Footnotes references describing the same resource and so on should use the exact same text so that they both redirect to the same footnote.
TODO notes should always describe what should be added there and should ideally be in italics
This is under heavy construction and probably contains inaccuracies, likely redundancies, certainly inefficient definitions and most definitely is missing relatively important terms
Definitions
General/Misc. Terms
The defs for lambda funs and anon classes are really barebone so far and should be improved.
Lambda Functions
- (Java) Unnamed function that can be defined within a method body, consisting of parameters followed by a method body or expression. Variables of a functional interface type, such as Java's
Consumer<T>
, may also be used to hold a lambda function. Lambdas must be mixed into separately from the rest of the encapsulating class's methods.
Anonymous Classes
- A nameless inner class declared and instantiated a single time. As with any inner class, anonymous classes must be mixed into specifically rather than outer classes.
Enclosing Method
- The method containing the relevant subject. For instance, an anonymous class or lambda's enclosing method.
Mixin, Mixin Class
- When used as a single term in the form of a proper noun, references the Mixin Subsystem as a whole. Mixin is a subsystem with the primary purpose of allowing a developer to describe modifications to be made at runtime using code. See Introduction to Mixins (WIP)
- “a Mixin” or “a Mixin Class” refers to classes or interfaces that are annotated with
@Mixin
, and will be merged with a target class as a means to transform it. Non-accessor Mixins will not be available at runtime due to the merging process.
Target Class
- A class with contents being targeted by the relevant Mixin Class's transformations.
Target Method
- A method within a target class being targeted by transformations from a Mixin class.
Merging, to merge
- In the context of Mixin, merging most of members and new interface implementations from the Mixin class into the target class's bytecode.
MixinExtras
- A companion library for the Mixin subsystem. MixinExtras focuses on giving more versatile, precise and compatible injectors and general Mixin usage utility. MixinExtras is bundled with Fabric since Loader version 0.15; MixinExtras 0.5.0 has been bundled with Fabric since Loader version 0.17.0; See the MixinExtras Wiki.
To mix into, to Mixin to
- Expressions referring to using Mixin to modify a target. For instance, “mixing into ServerLevel” would mean using a Mixin to modify the
ServerLevel
class.
MCDev
- References the IntelliJ Minecraft Development Plugin. It is very frequently used for Mixin development due to the added convenience, autocompletion and error detection it provides. See the plugin's home page.
ASM
- Java framework used by Mixin and other tools to modify and manipulate JVM bytecode at runtime.
- In general programming contexts, may refer to Assembly.
Bytecode
As opposed to Source code
- Bytecode is a set of less readable, computer-oriented instructions, which code running on the Java Virtual Machine will be compiled into. Mixin works with bytecode as opposed to “Source” code, both for the Mixins to be applied and the code to target, “source” code being the decompiled/pre-compilation code, and as such, whilst source code can be used to infer bytecode, one should always prioritize bytecode for precise targeting or for certain targets which may not be reliably in the same position or order in the bytecode compared to a decompilation. See Reading the Minecraft source's relevant section on bytecode.
Signatures
- A class signature encodes type information about a class or interface declaration. It describes any type parameters of the class or interface, and lists its direct superclass and direct superinterfaces, if any. A type parameter is described by its name, followed by any class bound and interface bounds.
- A method signature encodes the name, modifiers and type information about a method declaration. It describes any type parameters of the method, the types of any formal parameters, the return type, and the types of any exceptions declared in the method's throws clause.
- A field signature encodes the name and the type of a field, formal parameter, local variable, or record component declaration.
Field Descriptor
- A field descriptor represents the type of a field, parameter, local variable, or value.
- See the below table for possible field descriptors.
FieldType term | Type |
---|---|
B | byte |
C | char |
D | double |
F | float |
I | int |
J | long |
L ClassName ; | Named class or interface type |
S | short |
Z | boolean |
[ ComponentType | Array of given component type |
Method Descriptor
- A method descriptor contains zero or more parameter descriptors, representing the types of parameters that the method takes, and a return descriptor, representing the type of the value that the method returns. Note this does not include the name.
- For example the descriptor of
Object method(int i, double d, Thread t) {...}
is
(IDLjava/lang/Thread;)Ljava/lang/Object;
Synthetic members/constructs
- In Java, synthetic members and constructs refers to constructs added by the Java compiler into the compiled bytecode that do not have a source code equivalent. For instance, an anonymous class is given synthetic
final
fields which are used to be able to reference values of the enclosing method the anonymous class is declared in.- Synthetic members may be targeted by Mixin, such as with
@Shadow
or an Accessor but will require carefully reading the relevant bytecode.
Injectors
Injector
- Also known as “callback injectors”. Used through the form of annotations such as
@Inject
decorating a “handler” method. Upon the handler being merged, Mixin will use information specified within the injector's annotation to inject a set of “callback” instructions that will call back to the handler at a specific point.- Typically only refers to injectors that can chain and do not remove the targeted operations, which excludes redirectors such as
@Redirect
.
Handler method / Handler
- (Mixins) a method decorated by an injector annotation and then merged into the target class. It is then invoked/called within “callback” instructions that will be injected by Mixin based on the annotation's information.
Callback
- A series of injected instructions invoking the associated handler method based on that method's injection point definition.
Injection Point
- An injection point is the primary value used by Mixin to determine where to insert the callback instructions for a given injector. Injection points are typically passed in the
@At
annotation'svalue
field. Certain injection points are self-sufficient, such as“HEAD”
as it will simply try and target the earliest possible point in the target method, whilst others may necessitate more discriminators to have a specific target like“INVOKE”
which will need to specify the method whose call should be targeted. Injection points are used to search for specific Bytecode operations within the boundaries of the target method.- The injection point “reference” refers to the documentation of Mixin's built-in injection points. See the Mixin Wiki's injection point reference page.
- In some cases, injection point may refer to the specific point an injector's callback instructions will be inserted, resulting both from an injection point and other discriminators.
WrapOp, @WrapOperation
- Injector from MixinExtras, used primarily to replace or modify operations such as method calls, field get/set operations, etc.
MEV, @ModifyExpressionValue
- Injector from MixinExtras, used to modify the resultant value of a very wide range of expressions and operations.
MRV, @ModifyReturnValue
- Injector from Mixinextras, used to modify the return value of a method in a compatible fashion.
Inject
- (Verb) To use a Mixin injector to add to or modify existing operations.
- Reference to the
@Inject
injector, used to insert a method call to the handler at a desired point.
Local
- (General programming) Value confined to the relevant scope.
- When working with Mixins, the relevant scope will be the target method and its locals.
- Reference to the
@Local
annotation from MixinExtras, used to be able to capture the values of locals within a handler method's parameters.- See the official Wiki article
Cancel, Cancellable
- (Verb) In the context of injectors, means to cancel the remaining operations of the target method.
- (Annotation) Reference to the
@Cancellable
annotation from MixinExtras or a usage of it. Used to be able to cancel a target method without needing to use@Inject
- See the official Wiki article
Share, Sharing
@Share
annotation from MixinExtras and its usages. Used to share values between handler methods injecting into the same target method.- See the official Wiki article
Targeting Tools
Slice, Slicing
- Reference to the
@Slice
annotation and its usages, used to narrow the scope of the injector to be between two points within the target method.
Expressions
- Added in MixinExtras 0.5.0; a tool consisting of injection point
“MIXINEXTRAS:EXPRESSION”
and associated tools. Used to allow injectors to target a very wide range of expressions in a target method. MixinExtras 0.5.0 is bundled with Fabric Loader 0.17.0 and later.- To “use an expression” may refer to using MixinExtras Expressions to target with an injector.
- See the official wiki articles
Ordinal
- Zero-indexed integer value used to select a single target within the list of potential targets based on other discriminators and targeting tools. An ordinal of 0 would target the first of the potential targets by order of appearance in bytecode, for instance.
- Ordinals are generally a more brittle and less recommended discriminator for targeting using injectors.