SkillAgentSearch skills...

Mixin

Mixin is a trait/mixin and bytecode weaving framework for Java using ASM

Install / Use

/learn @SpongePowered/Mixin
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Build Status

Mixin Logo

Mixin is a trait/mixin framework for Java using ASM and hooking into the runtime classloading process via a set of pluggable built-in or user-provided services. Built-in services currently support Mojang's LegacyLauncher system, though this is deprecated in favour of ModLauncher by cpw, which has greater extensibility and has support for Java 8 and later.

Documentation

The main documentation for Mixin can be found in the Wiki.

Additional documentation for individual features and annotations can be found in the extensive Javadoc. For additional help use the channel #mixin on the Sponge Discord Server.

Binaries

Mixin binaries are available via Jenkins and are published to the following maven repositories:

  • https://repo.spongepowered.org/repository/maven-public/ - SNAPHOTs and RELEASE builds
  • https://files.minecraftforge.net/maven/ - RELEASE builds only

Tooling

For handling obfuscation tasks, Mixin provides an Annotation Processor which works at compile time to generate obfuscation mappings for your toolchain to apply. If using Gradle 5 or later, annotation processors are no longer automatically loaded from compile configurations and must be specified explicitly via annotationProcessor configurations. For this purpose, Mixin provides "fat jar" artefacts containing all required dependencies via the :processor classifier. For example if your build uses the dependency org.spongepowered:mixin:1.2.3 then your annotationProcessor configuration should specify dependency org.spongepowered:mixin:1.2.3:processor.

If you are using Mixin in a Minecraft Forge project then the MixinGradle plugin can be used to simplify the configuration of the Mixin Annotation Processor. It provides a simple syntax for configuring the Mixin AP for your project, see the MixinGradle README for how to configure MixinGradle.

Integration with Eclipse

When developing using Mixin, you can use the Mixin Annotation Processor within Eclipse to provide context-sensitive errors and warnings to help you more easily troubleshoot your mixins. To do so:

  1. Run the gradle build command to generate the mixin jar
  2. Open the properties of your eclipse project and navigate to Java Compiler -> Annotation Processing -> Factory Path
  3. Check the Enable project specific settings checkbox
  4. Click the Add External JARs button and select the generated mixin jar with the suffix -processor (hint: it should be in Mixin/build/libs)
  5. Navigate up one level to Java Compiler -> Annotation Processing
  6. Check the Enable project specific settings checkbox
  7. Check the Enable annotation processing checkbox
  8. Click the New... button next to the Processor options box
  • Set Key to reobfSrgFile
  • Set Value to the fully-qualified path to the mcp-srg.srg file (the location of the mapping file varies by platform, if you are unsure where to find it please follow the discord link below).
  1. Click OK to apply the changes

Integration with IntelliJ IDEA

Enhanced functionality for working with Mixin in IntelliJ IDEA is available via the Minecraft Development for IntelliJ IDEA plugin developed by DemonWav.

Version History

Specifying the minVersion property in your configurations is extrememly important. The following version history can be used to determine when features were introduced (and sometimes when major bugs are squashed) in order to help you determine which minVersion you should specify.

<table width="100%"> <thead> <tr> <th width="15%">Version</th> <th width="20%">Date</th> <th width="65%">Features / Changes</th> </tr> </thead> <tbody> <tr> <td valign="top"><b>0.8.3</b></td> <td valign="top">February 2021</td> <td valign="top"> <ul> <li>Added dynamic target selector support and <tt>&#64;Desc</tt> target selector</li> <li>Added pattern target selector</li> <li>Added more expressive quantifier support to explicit target selectors</li> <li>Facelift and overall improvements to javadoc</li> </ul> </td> </tr> <tr> <td valign="top"><b><s>0.8.1</s> (0.8.2)</b></td> <td valign="top">September 2020</td> <td valign="top"> <ul> <li><b>Hotfix for supporting ModLauncher 7.0</b></li> <li>Fix critical issue with resolving obfuscated members in inherited interfaces</li> <li><b>Updated to ASM 7.2</b></li> </ul> </td> </tr> <tr> <td valign="top"><b>0.8</b></td> <td valign="top">January 2020</td> <td valign="top"> <ul> <li><b>Updated to ASM 6.2</b></li> <li><b>Support for <a href="https://github.com/cpw/modlauncher/"> ModLauncher</a></b></li> <li>Added recognition for Java 9 and 10</li> <li>Support for <em>ForgeGradle 3+</em> tsrg obfuscation tables <li>Configs can now inherit from other configs</li> <li><tt>&#064;Invoke</tt> can now be used to expose constructors</li> <li>Dramatically improved context reporting of unexpected applicator and preprocessor exceptions, making it easier to diagnose when an agent chokes on a specific opcode</li> <li>Bug fixes for <ul> <li>Calling members of accessor mixins from inside mixin code</li> <li>Incorrect handling of spaces in explicit target declarations</li> <li>Unexpected behaviour when attempting to redirect a ctor</li> <li>Properly detect incompatible accessor overlap and ignore valid ones (don't warn)</li> <li>Interface static accessors now correctly conform target if interface is classloaded before target class</li> <li>Staticness mismatch for accessor correctly detected and reported instead of causing crash</li> <li>Fixed generator and injector errors relating to double-word operands on the stack needing DUP2</li> <li>Fixed issue in LVT generator folded in from FabricMC</li> <li>Fail-fast when a <tt>final</tt> method is accidentally hidden by a mixin</li> <li>Fix the appearance of stray <tt>CallbackInfo</tt> instances in local capture injector LVTs</li> </ul> </li> <li>Apache Commons-IO Dependency removed</li> <li>Renamed shaded ASM removed</li> <li>Improved resolution of local variables for local variable capture injections</li> <li><tt>&#064;Coerce</tt> on callback injectors and redirects can now resolve super interfaces including mixed-in interfaces</li> </ul> </td> </tr> <tr> <td valign="top"><b>0.7.11</b></td> <td valign="top">July 2018</td> <td valign="top"> <ul> <li>Fixes for 3 minor bugs: handling of maxShiftBy fixed, improved BeforeInvoke permissive search, disable generic signature merging unless decompiler is active.</li> </ul> </td> </tr> <tr> <td valign="top"><b>0.7.10</b></td> <td valign="top">June 2018</td> <td valign="top"> <ul> <li>Log an error when a mixin class is subject to classloader restrictions</li> </ul> </td> </tr> <tr> <td valign="top"><b>0.7.9</b></td> <td valign="top">April 2018</td> <td valign="top"> <ul> <li>Allow certain injectors to target mixin methods.</li> </ul> </td> </tr> <tr> <td valign="top"><b>0.7.8</b></td> <td valign="top">April 2018</td> <td valign="top"> <ul> <li>Bug fixes for member declaration validation, non-wild ctor redirects, and internal errors in <tt>Args</tt> subclass generator</li> </ul> </td> </tr> <tr> <td valign="top"><b>0.7.7</b></td> <td valign="top">March 2018</td> <td valign="top"> <ul> <li>Fixes for handling of log message triggers for INIT phase and error when running with unexpected logger configurations</li> <li>Add warnings for invalid slice points and narrowing conversion in ModifyConstant handlers</li> </ul> </td> </tr> <tr> <td valign="top"><b>0.7.6</b></td> <td valign="top">November 2017</td> <td valign="top"> <ul> <li>Fix inheritance for string system properties</li> </ul> </td> </tr> <tr> <td valign="top"><b>0.7.5</b></td> <td valign="top">October 2017</td> <td valign="top"> <ul> <li>Add support for <tt>&#064;Coerce</tt> on redirect injectors.</li> </ul> </td> </tr> <tr> <td valign="top"><b>0.7.4</b></td> <td valign="top">September 2017</td> <td valign
View on GitHub
GitHub Stars1.7k
CategoryDevelopment
Updated1d ago
Forks215

Languages

Java

Security Score

100/100

Audited on Mar 26, 2026

No findings