Class MicromixinRemapper

java.lang.Object
org.stianloader.micromixin.remapper.MicromixinRemapper

public class MicromixinRemapper extends Object
  • Field Details

    • CALLBACK_INFO_CLASS

      @NotNull @Internal public static final @NotNull String CALLBACK_INFO_CLASS
      See Also:
    • CALLBACK_INFO_RETURNABLE_CLASS

      @NotNull @Internal public static final @NotNull String CALLBACK_INFO_RETURNABLE_CLASS
      See Also:
  • Constructor Details

    • MicromixinRemapper

      public MicromixinRemapper(@NotNull @NotNull org.stianloader.remapper.MappingLookup lookup, @NotNull @NotNull org.stianloader.remapper.MappingSink sink, @NotNull @NotNull MemberLister lister)
  • Method Details

    • forbidRemappingInterfaceMembers

      protected boolean forbidRemappingInterfaceMembers(@NotNull @NotNull String name, @NotNull @NotNull Collection<@NotNull String> targets)
      Queries whether interface members may be renamed as a result of a remapClass(ClassNode) pass. This method mainly exist as a way to prevent collateral damage when inappropriately implementing interfaces when using annotations such as @Shadow or @Overwrite alongside the Override.

      The default implementation always returns true as an overly cautious way of weeding out potentially inappropriate usages of mixins.

      Parameters:
      name - The internal name of the interface whose member may be modified
      targets - A collection of internal names of the targeted classes by the mixin (in case one wishes to perform hierarchy validation)
      Returns:
      True if renaming it's members is forbidden, false if allowed.
    • logUnimplementedFeature

      @OverrideOnly protected void logUnimplementedFeature(@NotNull @NotNull String featureDescription) throws MissingFeatureException
      The error handler that is invoked whenever an unimplemented or unknown feature is encountered.

      Being able to track down these cases may help narrow down why the remapper failed remapping something or remapped something in an unexpected way.

      By default it'll cause an MissingFeatureException to be thrown, but it is possible to overwrite this behaviour with a logging call. In that case, the remapper will try to continue on a best-effort basis.

      Parameters:
      featureDescription - The description of the feature that is not implemented and what caused the issue to occur.
      Throws:
      MissingFeatureException - Thrown if the error handler is configured to stop execution of the remapper in a fail-fast manner.
    • lookupSelector

      @Nullable @MustBeInvokedByOverriders @Contract(pure=true) protected @Nullable AtSelector lookupSelector(@NotNull @NotNull String atValue)
    • remapAt

      @Internal public void remapAt(@NotNull @NotNull String owner, @NotNull @NotNull String member, int ordinal, @NotNull @NotNull Collection<String> targets, org.objectweb.asm.tree.AnnotationNode annot) throws IllegalMixinException, MissingFeatureException
      Throws:
      IllegalMixinException
      MissingFeatureException
    • remapAtArray

      @Internal public void remapAtArray(@NotNull @NotNull String owner, @NotNull @NotNull String method, @NotNull @NotNull Collection<String> targets, Object nodes) throws IllegalMixinException, MissingFeatureException
      Throws:
      IllegalMixinException
      MissingFeatureException
    • remapClass

      public void remapClass(@NotNull @NotNull org.objectweb.asm.tree.ClassNode node) throws IllegalMixinException, MissingFeatureException
      Remap a ClassNode and all the member MethodNodes and FieldNodes within the class. Note that in order for the micromixin remapping process to work correctly and account for inter-class relationships (mixin inheritance), this method needs to be executed before the actual remapping process through Remapper.remapNode(ClassNode, StringBuilder). More concisely, this method expect that Remapper.remapNode(ClassNode, StringBuilder) will be run after remapClass(ClassNode).

      Modifications to this remapper's underlying MappingSink instance (set through the constructor) are expected to be applied to the Remapper instance. It is highly recommended that the MappingSink is aware of class hierarchy remapping. Additionally, it may be useful to be able to verify that the MappingSink instance does not accidentally or not remap non-mixin classes. If a mapping request emitted by this method (or any of the method is is delegating to) ends up remapping an unrelated class, then the mixin should be considered illegal.

      It is permissible for the provided mixin class to not be an @Mixin-annotated class, in which case the class is skipped.

      Parameters:
      node - The ClassNode to remap
      Throws:
      IllegalMixinException - Thrown if the mixin contains illegal code (e.g. invalid targets in the @Mixin or @Shadow collisions while implementing an interface).
      MissingFeatureException - Thrown due to logUnimplementedFeature(String), this exception is reserved for purposes where the remapper encounters mixin features it is not aware of at the current point in time.
    • remapMethodSelectorList

      @Internal public void remapMethodSelectorList(List<?> selectors, @NotNull @NotNull String originName, org.objectweb.asm.tree.MethodNode originMethod, @NotNull @NotNull Collection<String> targets, @Nullable @Nullable Predicate<@NotNull String> inferredDescriptorPredicate) throws IllegalMixinException, MissingFeatureException
      Throws:
      IllegalMixinException
      MissingFeatureException
    • remapSlice

      @Internal public void remapSlice(@NotNull @NotNull String owner, @NotNull @NotNull String member, int ordinal, @NotNull @NotNull Collection<String> targets, org.objectweb.asm.tree.AnnotationNode annot) throws IllegalMixinException, MissingFeatureException
      Throws:
      IllegalMixinException
      MissingFeatureException