Java

README.MD

Build Status

Mixin Logo

Mixin is a trait/mixin framework for Java using ASM and hooking into the runtime class-loading process via Mojang's LegacyLauncher system.

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 #spongedev on the Espernet IRC network.

Building Mixin

Mixin uses the Gradle build automation system. To perform a build, use gradle version 2.11 and execute

gradle

from within the project root directory. (If you do not have Gradle installed on your system you can instead run the supplied Gradle wrapper gradlew)

Integration with Eclipse IDE

The Mixin project can be integrated easily with Eclipse using Buildship. Simply choose Import -> Gradle Project and follow the prompts.

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 (for Sponge this can be found in Sponge/build/srgs/mcp-srg.srg)
  1. Click OK to apply the changes

Integration with IntelliJ IDEA IDE

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

Version History

Version Date Features / Changes
0.7.10 June 2018
  • Log an error when a mixin class is subject to classloader restrictions
0.7.9 April 2018
  • Allow certain injectors to target mixin methods.
0.7.8 April 2018
  • Bug fixes for member declaration validation, non-wild ctor redirects, and internal errors in Args subclass generator
0.7.7 March 2018
  • Fixes for handling of log message triggers for INIT phase and error when running with unexpected logger configurations
  • Add warnings for invalid slice points and narrowing conversion in ModifyConstant handlers
0.7.6 November 2017
  • Fix inheritance for string system properties
0.7.5 October 2017
  • Add support for @Coerce on redirect injectors.
0.7.4 September 2017
  • Added @Dynamic annotation for decorating mixin elements with dynamically-injected targets.
0.7.3 August 2017
  • Internal changes to provide for support modlauncher and java 9
0.7.2 August 2017
  • Add profiler for inspecting mixin performance.
0.7.1 August 2017
  • Fixes and improvements to the Mixin AP, fixing handling of multi- dimensional arrays and resolving methods in superclasses of derived types of obfuscated classes
  • Add runtime refmap remapping to support using deobfCompile dependencies with different mapping versions.
0.7 July 2017
  • All official binaries are now signed
  • Upgrade to ASM 5.2
  • Add support for inner classes in Mixins
  • Injectors can now have multiple explicit targets
  • @At annotations can now have their own id
  • Add support for using @Overwrite on non-obfuscated methods as a way of verifying that an overwrite target exists
  • Improve support for synthetic bridges, detect conflicting bridge methods
  • Detect and warn of excessive At.Shift.BY values
  • ModifyConstant can now support multiple slices
  • Add allow to injectors to detect over-injection
0.6.15 July 2017
  • Add support for multiple constants in ModifyConstant
  • Add CONSTANT as general-purpose injection point
  • Add support for redirecting array length access in field redirectors
0.6.14 July 2017
  • Add support for using @Coerce on reference types in Callback Injectors to support derived types.
0.6.13 July 2017
  • Add support for conforming visibility of overwrite methods to match target class. Fixes issues where a target class method has been modified by an Access Transformer to have higher visibility
0.6.12 June 2017
  • Add slice argument to @ModifyConstant
  • Add @ModifyArgs injector which can change multiple method call arguments with a single handler.
0.6.11 June 2017
  • Fix handling of @Unique when the same unique method exists in more than one mixin targetting the same class
  • Fix handling of merged lambdas so that lambdas from mixins are applied correctly when lambdas already exist in the target class (both in the original class and when applied by earlier mixins)
0.6.10 May 2017
  • (0.6.9) Minor fix to remove dependence on deprecated helper
  • Respect remap on Mixin for contained @At
  • Require redirectors which occur before call to superctor to be static
0.6.8 February 2017
  • Allow @ModifyConstant to hook implicit zero in comparisons
0.6.7 January 2017
  • Add support for @Redirect on array access
0.6.6 January 2017
  • Allow static methods in accessor mixins in Java 8 and above
0.6.5 January 2017
  • Add support for injector slices
0.6.4 January 2017
  • Allow descriptors on NEW injection points
0.6.3 December 2016
  • SourceDebugExtension support
0.6.2 December 2016
  • Add support for @Pseudo (virtual target) mixins
0.6.1 November 2016
  • Process soft-implements annotations in the AP
0.6 October 2016
  • Accessor Mixin support
0.5.17 October 2016
  • Allow @Redirect injectors to target NEW opcodes for constructor redirection
0.5.16 October 2016
  • Annotation Processor improvements. Support shadows and overrides in multi-target mixins
  • Support pluggable obfuscation environments in AP
0.5.14 September 2016
  • Add async decompilation support
0.5.13 September 2016
  • Add alternative strategy for injecting field initialisers
0.5.10 June 2016
  • Support @Unique on fields
0.5.9 June 2016
  • Hard fail if a required mixin target was already transformed
0.5.8 June 2016
  • Support constraints on injectors
0.5.7 June 2016
  • Add @Unique annotation
0.5.6 May 2016
  • Environment changes, support environment via agents
0.5.5 April 2016
  • Add @ModifyConstant injector
  • Add @Debug annotation
  • Allow static @ModifyArg handlers in instance methods
0.5.4 April 2016
  • Error handlers also receive mixin prepare errors
0.5.3 February 2016
  • Conform injectors
  • Enable hotswapper automatically if agent is active
  • Fix multiple issues with generics in Annotation Processors
0.5.2 February 2016
  • Support ID on injectors
  • Support priority for injectors
0.5.1 February 2016
  • Overhaul injectors, injectors from all mixins now scan before any injectors are actually processed. Makes injectors more deterministic.
0.4.19 February 2016
  • Add support for @Redirect on fields as well as methods
0.4.18 February 2016
  • Add @ModifyLocal injector
0.4.17 January 2016
  • Support ExtraSRGs in Annotation Processor
  • Include constructors in reference map
  • Add @Mutable annotation to suppress @Final warnings
0.4.15 January 2016
  • Include soft targets in refmap
0.4.14 January 2016
  • Add support for interface mixins
0.4.13 January 2016
  • Add @Final annotation
0.4.11 January 2016
  • Add support for injector grouping and config-wide require value
0.4.10 December 2015
  • Runtime remapping support using RemapperChain
  • Ignore class transformers decorated with @Resource
  • Support @reason and @author validation on overwrites
0.4.8 December 2015
  • Annotation Processor improved to support MixinGradle
  • Support multiple target obfuscation environments in refmaps
0.4.6 September 2015
  • Add INIT phase for handling early FML startup
  • Add support for lambdas in mixins
  • Add support for hot code replacement in mixins
  • Improve Java 8 feature support
0.4.4 July 2015
  • Add constraints for overwrites
0.4.3 May 2015
  • Add INVOKE_ASSIGN injection point
  • Support injector callbacks without args
  • Support coercion of covariant parameter types in callbacks
  • Support truncating local-capturing injector handlers
  • Runtime decompilation of exported classes using fernflower
  • Add export filter
0.4 May 2015
  • Shade relocated ASM package and use throughout
0.3.2 April 2015
  • Error handler support
0.3.1 April 2015
  • Annotation Merging
  • Allow Overwrite methods to be aliased
0.3 March 2015
  • Implemented Environments
  • Intrinsic method support
  • Enabled local variable capture
  • Alias support
0.2 March 2015
  • Added supermixin support (mixins inheriting from other mixins)
0.1 January 2015
  • Basic Mixin Support
  • Basic Injector Support
  • Annotation Processor