Skip to content

Instantly share code, notes, and snippets.

@LlamaLad7
Last active August 20, 2023 17:05
Show Gist options
  • Save LlamaLad7/0c78ad5ce6d15d3c3fc87606e5717918 to your computer and use it in GitHub Desktop.
Save LlamaLad7/0c78ad5ce6d15d3c3fc87606e5717918 to your computer and use it in GitHub Desktop.
MixinExtras forwards-compatibility system

MixinExtras 0.2.0-beta.10 introduces a new forwards-compatibility system to ensure that old code doesn't get in the way of any future versions. Currently most people use JiJ for MixinExtras anyway, meaning only the latest version is active, but when people shade and relocate MixinExtras, things become more complicated.

There are several places where different relocated instances need to communicate with each other, such as to share mutable @Local references and to ensure @WrapOperations all get applied with the right priority. Since beta 2 these different relocated instances have communicated with each other in limited ways, but the problem remains that older active versions could always cause problems for newer ones.

The new approach is to mimic how things work when everyone uses JiJ. Starting with 0.2.0-beta.10, all instances of MixinExtras will be handled by the latest active version. If there are multiple instances of the latest version then which one gets picked is not well-defined, but crucially it will only be one of them.

Key takeaways:

  • Do not interact with any internal parts of MixinExtras. This has always been the case but is especially true now you may not be interacting with an active version. You must only interact with obviously exposed parts such as the bootstrap, the annotations, and user-facing types like Local...Ref and Operation.
  • Error messages from MixinExtras may have stacktraces from unexpected packages. If you shade and relocate a new version of MixinExtras, errors from other mods may appear to have come from your package since it will be handling all MixinExtras instances. Hopefully the name of the mixin config being included in the error anyway means this isn't too confusing. Unfortunately there's no way around it.
  • If you ship a modified version of MixinExtras, please don't. Any changes you make may not affect your mixins and may affect other people's mixins. If you believe you have a valid reason to do this then please let me know so we can discuss it.
  • The new initialization procedure means you may encounter errors if initializing MixinExtras too late (after the first mixin has been applied). If you encounter any errors relating to the MixinExtras Service, either in your own usage or if you see anyone else encountering them, please let me know so I can try to sort them out.
  • MixinExtrasBootstrap#getVersion has been deprecated. Its result does not make much sense since it may not be the active version. I don't think anyone actually used it anyway. If you still need it for whatever reason then let me know so I can think about introducing an alternative.
  • Support for earlier betas is very limited. New versions will forcefully take over sugar from these versions, but not injectors. In particular, WrapOperations from these versions are no longer guaranteed to apply in the right order relative to new versions. I suggest updating once this version has had a bit more testing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment