java.lang.Object
org.spongepowered.asm.mixin.injection.struct.MemberInfo
All Implemented Interfaces:
ITargetSelector, ITargetSelectorByName, ITargetSelectorConstructor, ITargetSelectorRemappable

public final class MemberInfo
extends java.lang.Object
implements ITargetSelectorRemappable, ITargetSelectorConstructor

Target selector, also used as a general-purpose information bundle about a member (method or field) parsed from a String token in another annotation, this is used where target members need to be specified as Strings in order to parse the String representation to something useful. See ITargetSelector for other supported selector types.

Some examples:

   // references a method or field called func_1234_a, if there are multiple
   // members with the same signature, matches the first occurrence
   func_1234_a
   
   // references a method or field called func_1234_a, if there are multiple
   // members with the same signature, matches all occurrences
   func_1234_a*
   
   // references a method called func_1234_a which takes 3 ints and returns
   // a bool
   func_1234_a(III)Z
   
   // references a field called field_5678_z which is a String
   field_5678_z:Ljava/lang/String;
   
   // references a ctor which takes a single String argument 
   <init>(Ljava/lang/String;)V
   
   // references a method called func_1234_a in class foo.bar.Baz
   Lfoo/bar/Baz;func_1234_a
  
   // references a field called field_5678_z in class com.example.Dave
   Lcom/example/Dave;field_5678_z
  
   // references a method called func_1234_a in class foo.bar.Baz which takes
   // three doubles and returns void
   Lfoo/bar/Baz;func_1234_a(DDD)V
   
   // alternate syntax for the same
   foo.bar.Baz.func_1234_a(DDD)V
  • Constructor Summary

    Constructors
    Constructor Description
    MemberInfo​(java.lang.String name, boolean matchAll)
    ctor
    MemberInfo​(java.lang.String name, java.lang.String owner, boolean matchAll)
    ctor
    MemberInfo​(java.lang.String name, java.lang.String owner, java.lang.String desc)
    ctor
    MemberInfo​(java.lang.String name, java.lang.String owner, java.lang.String desc, boolean matchAll)
    ctor
    MemberInfo​(java.lang.String name, java.lang.String owner, java.lang.String desc, boolean matchAll, java.lang.String unparsed)
    ctor
    MemberInfo​(org.objectweb.asm.tree.AbstractInsnNode insn)
    Initialise a MemberInfo using the supplied insn which must be an instance of MethodInsnNode or FieldInsnNode.
    MemberInfo​(IMapping<?> mapping)
    Initialise a MemberInfo using the supplied mapping object
  • Method Summary

    Modifier and Type Method Description
    MappingField asFieldMapping()
    Returns this MemberInfo as a mapping field
    IMapping<?> asMapping()
    Returns this MemberInfo as a MappingField or MappingMethod
    MappingMethod asMethodMapping()
    Returns this MemberInfo as a mapping method
    ITargetSelector attach​(IMixinContext context)
    Attach this selector to the specified context.
    ITargetSelector configure​(java.lang.String... args)
    Configure and return a modified version of this selector by consuming the supplied arguments.
    boolean equals​(java.lang.Object obj)  
    static MemberInfo fromMapping​(IMapping<?> mapping)
    Return the supplied mapping parsed as a MemberInfo
    java.lang.String getDesc()
    Get the member descriptor, can be null
    int getMatchCount()
    Number of candidates which this selector should match
    java.lang.String getName()
    Get the member name, can be null
    java.lang.String getOwner()
    Get the member owner, can be null
    int hashCode()  
    boolean isClassInitialiser()
    Get whether this member represents a class initialiser
    boolean isConstructor()
    Get whether this member represents a constructor
    boolean isField()
    Get whether this MemberInfo is definitely a field, the output of this method is undefined if isFullyQualified() returns false.
    boolean isFullyQualified()
    Get whether this reference is fully qualified
    boolean isInitialiser()
    Get whether this member represents a constructor or class initialiser
    MatchResult match​(org.objectweb.asm.tree.AbstractInsnNode insn)
    Test whether this selector matches the supplied instruction node
    <TNode> MatchResult match​(ElementNode<TNode> node)
    Test whether this selector matches the supplied element node
    MatchResult matches​(java.lang.String owner, java.lang.String name, java.lang.String desc)
    Test whether this selector matches the supplied values.
    ITargetSelectorRemappable move​(java.lang.String newOwner)
    Create a new version of this member with a different owner
    ITargetSelector next()
    Get the next target selector in this path (or null if this selector is the last selector in the chain.
    static MemberInfo parse​(java.lang.String input, IReferenceMapper refMapper, java.lang.String className)
    Parse a MemberInfo from a string
    ITargetSelectorRemappable remapUsing​(MappingMethod srgMethod, boolean setOwner)
    Create a remapped version of this member using the supplied method data
    java.lang.String toCtorDesc()
    Returns the constructor descriptor represented by this MemberInfo, returns null if no descriptor is present.
    java.lang.String toCtorType()
    Returns the constructor type represented by this MemberInfo
    java.lang.String toDescriptor()
    Returns this MemberInfo as a java-style descriptor
    java.lang.String toSrg()
    Deprecated.
    use m.asMethodMapping().serialise() instead
    java.lang.String toString()  
    ITargetSelectorRemappable transform​(java.lang.String newDesc)
    Create a new version of this member with a different descriptor
    MemberInfo validate()
    Perform ultra-simple validation of the descriptor, checks that the parts of the descriptor are basically sane.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MemberInfo

      public MemberInfo​(java.lang.String name, boolean matchAll)
      ctor
      Parameters:
      name - Member name, must not be null
      matchAll - true if this info should match all matching references, or only the first
    • MemberInfo

      public MemberInfo​(java.lang.String name, java.lang.String owner, boolean matchAll)
      ctor
      Parameters:
      name - Member name, must not be null
      owner - Member owner, can be null otherwise must be in internal form without L;
      matchAll - true if this info should match all matching references, or only the first
    • MemberInfo

      public MemberInfo​(java.lang.String name, java.lang.String owner, java.lang.String desc)
      ctor
      Parameters:
      name - Member name, must not be null
      owner - Member owner, can be null otherwise must be in internal form without L;
      desc - Member descriptor, can be null
    • MemberInfo

      public MemberInfo​(java.lang.String name, java.lang.String owner, java.lang.String desc, boolean matchAll)
      ctor
      Parameters:
      name - Member name, must not be null
      owner - Member owner, can be null otherwise must be in internal form without L;
      desc - Member descriptor, can be null
      matchAll - True to match all matching members, not just the first
    • MemberInfo

      public MemberInfo​(java.lang.String name, java.lang.String owner, java.lang.String desc, boolean matchAll, java.lang.String unparsed)
      ctor
      Parameters:
      name - Member name, must not be null
      owner - Member owner, can be null otherwise must be in internal form without L;
      desc - Member descriptor, can be null
      matchAll - True to match all matching members, not just the first
    • MemberInfo

      public MemberInfo​(org.objectweb.asm.tree.AbstractInsnNode insn)
      Initialise a MemberInfo using the supplied insn which must be an instance of MethodInsnNode or FieldInsnNode.
      Parameters:
      insn - instruction node to copy values from
    • MemberInfo

      public MemberInfo​(IMapping<?> mapping)
      Initialise a MemberInfo using the supplied mapping object
      Parameters:
      mapping - Mapping object to copy values from
  • Method Details

    • next

      public ITargetSelector next()
      Description copied from interface: ITargetSelector
      Get the next target selector in this path (or null if this selector is the last selector in the chain. Called at recurse points in the subject in order to match against the child subject.
      Specified by:
      next in interface ITargetSelector
    • getOwner

      public java.lang.String getOwner()
      Description copied from interface: ITargetSelectorByName
      Get the member owner, can be null
      Specified by:
      getOwner in interface ITargetSelectorByName
    • getName

      public java.lang.String getName()
      Description copied from interface: ITargetSelectorByName
      Get the member name, can be null
      Specified by:
      getName in interface ITargetSelectorByName
    • getDesc

      public java.lang.String getDesc()
      Description copied from interface: ITargetSelectorByName
      Get the member descriptor, can be null
      Specified by:
      getDesc in interface ITargetSelectorByName
    • getMatchCount

      public int getMatchCount()
      Description copied from interface: ITargetSelector
      Number of candidates which this selector should match
      Specified by:
      getMatchCount in interface ITargetSelector
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • toSrg

      @Deprecated public java.lang.String toSrg()
      Deprecated.
      use m.asMethodMapping().serialise() instead
      Return this MemberInfo as an SRG mapping
      Returns:
      SRG representation of this MemberInfo
    • toDescriptor

      public java.lang.String toDescriptor()
      Returns this MemberInfo as a java-style descriptor
      Specified by:
      toDescriptor in interface ITargetSelectorByName
    • toCtorType

      public java.lang.String toCtorType()
      Returns the constructor type represented by this MemberInfo
      Specified by:
      toCtorType in interface ITargetSelectorConstructor
    • toCtorDesc

      public java.lang.String toCtorDesc()
      Returns the constructor descriptor represented by this MemberInfo, returns null if no descriptor is present.
      Specified by:
      toCtorDesc in interface ITargetSelectorConstructor
    • asMapping

      public IMapping<?> asMapping()
      Returns this MemberInfo as a MappingField or MappingMethod
      Specified by:
      asMapping in interface ITargetSelectorRemappable
    • asMethodMapping

      public MappingMethod asMethodMapping()
      Returns this MemberInfo as a mapping method
      Specified by:
      asMethodMapping in interface ITargetSelectorRemappable
    • asFieldMapping

      public MappingField asFieldMapping()
      Returns this MemberInfo as a mapping field
      Specified by:
      asFieldMapping in interface ITargetSelectorRemappable
    • isFullyQualified

      public boolean isFullyQualified()
      Description copied from interface: ITargetSelectorByName
      Get whether this reference is fully qualified
      Specified by:
      isFullyQualified in interface ITargetSelectorByName
      Returns:
      true if all components of this reference are non-null
    • isField

      public boolean isField()
      Get whether this MemberInfo is definitely a field, the output of this method is undefined if isFullyQualified() returns false.
      Specified by:
      isField in interface ITargetSelectorByName
      Returns:
      true if this is definitely a field
    • isConstructor

      public boolean isConstructor()
      Get whether this member represents a constructor
      Specified by:
      isConstructor in interface ITargetSelectorByName
      Returns:
      true if member name is <init>
    • isClassInitialiser

      public boolean isClassInitialiser()
      Get whether this member represents a class initialiser
      Specified by:
      isClassInitialiser in interface ITargetSelectorByName
      Returns:
      true if member name is <clinit>
    • isInitialiser

      public boolean isInitialiser()
      Get whether this member represents a constructor or class initialiser
      Specified by:
      isInitialiser in interface ITargetSelectorByName
      Returns:
      true if member name is <init> or <clinit>
    • validate

      public MemberInfo validate() throws InvalidMemberDescriptorException
      Perform ultra-simple validation of the descriptor, checks that the parts of the descriptor are basically sane.
      Specified by:
      validate in interface ITargetSelector
      Returns:
      fluent
      Throws:
      InvalidMemberDescriptorException - if any validation check fails
    • match

      public <TNode> MatchResult match​(ElementNode<TNode> node)
      Description copied from interface: ITargetSelector
      Test whether this selector matches the supplied element node
      Specified by:
      match in interface ITargetSelector
      Type Parameters:
      TNode - node type
      Parameters:
      node - node node to test
      Returns:
      true if this selector can match the supplied field
    • match

      public MatchResult match​(org.objectweb.asm.tree.AbstractInsnNode insn)
      Description copied from interface: ITargetSelector
      Test whether this selector matches the supplied instruction node
      Specified by:
      match in interface ITargetSelector
      Parameters:
      insn - instruction node to test
      Returns:
      true if this selector can match the supplied instruction
    • matches

      public MatchResult matches​(java.lang.String owner, java.lang.String name, java.lang.String desc)
      Description copied from interface: ITargetSelectorByName
      Test whether this selector matches the supplied values. Null values are ignored.
      Specified by:
      matches in interface ITargetSelectorByName
      Parameters:
      owner - Owner to compare with, null to skip
      name - Name to compare with, null to skip
      desc - Signature to compare with, null to skip
      Returns:
      true if all non-null values in this reference match non-null arguments supplied to this method
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • configure

      public ITargetSelector configure​(java.lang.String... args)
      Description copied from interface: ITargetSelector
      Configure and return a modified version of this selector by consuming the supplied arguments. Results from this method should be idempotent in terms of the configuration of the returned object, but do not have to necessarily return the same object if the callee already matches the supplied configuration, though this is generally the case.

      In other words, calling configure("foo") when this object is already configured according to "foo" may simply return this object, or might return an identically-configured copy.

      Specified by:
      configure in interface ITargetSelector
      Parameters:
      args - Configuration arguments
      Returns:
      Configured selector, may return this selector if the specified condition is already satisfied
    • attach

      public ITargetSelector attach​(IMixinContext context) throws InvalidSelectorException
      Description copied from interface: ITargetSelector
      Attach this selector to the specified context. Should return this selector unmodified if all is well, or a new selector to be used for further processing of the supplied context. If the supplied context is invalid, an InvalidSelectorException is thrown.
      Specified by:
      attach in interface ITargetSelector
      Parameters:
      context - Context to attach to
      Returns:
      Attached selector
      Throws:
      InvalidSelectorException
    • move

      public ITargetSelectorRemappable move​(java.lang.String newOwner)
      Create a new version of this member with a different owner
      Specified by:
      move in interface ITargetSelectorRemappable
      Parameters:
      newOwner - New owner for this member
    • transform

      public ITargetSelectorRemappable transform​(java.lang.String newDesc)
      Create a new version of this member with a different descriptor
      Specified by:
      transform in interface ITargetSelectorRemappable
      Parameters:
      newDesc - New descriptor for this member
    • remapUsing

      public ITargetSelectorRemappable remapUsing​(MappingMethod srgMethod, boolean setOwner)
      Create a remapped version of this member using the supplied method data
      Specified by:
      remapUsing in interface ITargetSelectorRemappable
      Parameters:
      srgMethod - SRG method data to use
      setOwner - True to set the owner as well as the name
      Returns:
      New MethodInfo with remapped values
    • parse

      public static MemberInfo parse​(java.lang.String input, IReferenceMapper refMapper, java.lang.String className)
      Parse a MemberInfo from a string
      Parameters:
      input - String to parse MemberInfo from
      refMapper - Reference mapper to use
      className - Class context to use for remapping
      Returns:
      parsed MemberInfo
    • fromMapping

      public static MemberInfo fromMapping​(IMapping<?> mapping)
      Return the supplied mapping parsed as a MemberInfo
      Parameters:
      mapping - mapping to parse
      Returns:
      new MemberInfo