Annotation Type Overwrite


  • @Target(METHOD)
    @Retention(RUNTIME)
    public @interface Overwrite

    Annotation used to indicate a mixin class member which must overwrite a method in the target class.

    The default behaviour of mixin classes when merging mixin methods is to replace methods in the target class which already exist, and simply add any other methods to the target class body as new members. This default behaviour allows methods in the target class to be easily overwritten by simply creating a method in the mixin with a signature matching the member to be overwritten.

    This is not sufficient for obfuscated methods however, since as mixins traverse the obfuscation boundary, this association with the target method is lost because the method name will change. The Overwrite annotation is used to indicate to the annotation processor that this method is intended to overwrite a member in the target class, and should be added to the obfuscation table if remap() is true.

    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String[] aliases
      Supplies possible aliases for this method.
      java.lang.String constraints
      Returns constraints which must be validated for this overwrite to succeed.
      boolean remap
      By default, the annotation processor will attempt to locate an obfuscation mapping for all Overwrite methods since it is anticipated that in general the target of a Overwrite annotation will be an obfuscated method in the target class.
    • Element Detail

      • constraints

        java.lang.String constraints
        Returns constraints which must be validated for this overwrite to succeed. See ConstraintParser.Constraint for details of constraint formats.
        Returns:
        Constraints for this annotation
        Default:
        ""
      • aliases

        java.lang.String[] aliases
        Supplies possible aliases for this method. This should only be used in the following scenarios:
        • When shadowing a sythetic method which can have differen names at development time because it is regenerated by the compiler.
        • When another mod or transformer is known to change the name of a field
        Returns:
        Aliases for this member
        Default:
        {}
      • remap

        boolean remap
        By default, the annotation processor will attempt to locate an obfuscation mapping for all Overwrite methods since it is anticipated that in general the target of a Overwrite annotation will be an obfuscated method in the target class. However since it is possible to also overwrite methods in non-obfuscated targets it may be necessary to suppress the compiler error which would otherwise be generated. Setting this value to false will cause the annotation processor to skip this annotation when attempting to build the obfuscation table for the mixin.
        Returns:
        True to instruct the annotation processor to search for obfuscation mappings for this method
        Default:
        true