Interface MemberLister
MemberLister presents a way of obtaining metadata about potential mixin target classes
that facilitate the remapping process. The main function of the MemberLister is to resolve
not fully qualified references to a fully qualified reference or to detect cases where the remapping
process would need to tear apart name hierarchies - this is especially prominent for overwrites - be
it explicit or implicit.
This interface does not define any behaviour on how the remapper needs to react to such mapping difficulties. Instead, the interface provides the means of making a well-informed decision that is more specific to the encountered scenario.
-
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable Collection<org.stianloader.remapper.MemberRef>getReportedClassMembers(@NotNull String owner) List all known members of a given class.booleanhasMemberInHierarchy(@NotNull String clazz, @NotNull String name, @NotNull String desc) Check whether a member with the given name and descriptor exists with the classclazzor any of it's supertypes.@NotNull Collection<org.stianloader.remapper.MemberRef>tryInferMember(@NotNull String owner, @Nullable String name, @Nullable String desc) Try to infer the members (stored as amember referencein the source namespace) of a classownerthat match the given name or descriptor.
-
Method Details
-
getReportedClassMembers
@Nullable default @Nullable Collection<org.stianloader.remapper.MemberRef> getReportedClassMembers(@NotNull @NotNull String owner) throws UnsupportedOperationException List all known members of a given class.Solely used for debugging purposes, that is this method will only be used to guide the end user when something went wrong in the remapping process, typically in conjunction with interactions related to
tryInferMember(String, String, String).The
MemberRefstored in the returned collection are in the source namespace, as is the input parameterowner.Implementors are allowed to throw a
UnsupportedOperationExceptionunconditionally (in fact, this is the default implementation), if the implementation ofMemberListerdoes not support the specific functionality. Doing so should have no impact on the actual remapping process, but will result in degraded error reporting.Similarly, if the implementation cannot find any member from the class (that is, to the implementation the class does not exist, since a class should always have at least one constructor and the clinit method),
nullis returned. Here too, no impact on the remapping process should occur outside of degraded error reporting.- Parameters:
owner- The class defining the members that need to be listed.- Returns:
- All known members within the given class, or null if the class is not known.
- Throws:
UnsupportedOperationException
-
hasMemberInHierarchy
boolean hasMemberInHierarchy(@NotNull @NotNull String clazz, @NotNull @NotNull String name, @NotNull @NotNull String desc) Check whether a member with the given name and descriptor exists with the classclazzor any of it's supertypes. Subtypes should not be considered.This method may also be called on fields. Whether a member is a field or a method can quickly be validated by checking the first character of the descriptor: If it is '(' it is a method, else it is a field.
This method is most critically used to detect mapping tears as well as to handle implicit overwrites and the shadow annotation.
- Parameters:
clazz- The owner to start searching in, in the source namespace.name- The name of the member, in the source namespace.desc- The descriptor of the member, in the source namespace.- Returns:
- True if the member was found in the hierarchy, false otherwise.
-
tryInferMember
@NotNull @NotNull Collection<org.stianloader.remapper.MemberRef> tryInferMember(@NotNull @NotNull String owner, @Nullable @Nullable String name, @Nullable @Nullable String desc) Try to infer the members (stored as amember referencein the source namespace) of a classownerthat match the given name or descriptor. If name or descriptor is null, then the part should be considered unknown.If multiple members match the criterions laid out by the method call, then implementors should return all members that match within the returned
Collection. Similarly, if no members match the criterions, then an empty collection should be returned.The
MemberRefstored in the collection are in the source namespace, as are the input parameters of this method.This method is used for purposes of remapping string target selectors. That being said, at this point in time it is not being used for mapping string target selectors within
@Atannotations. This is largely caused by the fact that the spongeian mixin specification explicitly states that the references within@Ats should be full qualified or otherwise there may be issues at obfuscation time.Implementors are not required to resolve the members within superclasses or elsewhere in the inheritance hierarchy. In fact, callers might expect that
MemberRef.getOwner()equals toownerfor allMemberRefinstances returned by this method.- Parameters:
owner- The internal name of the owner of the members to collect.name- The name of the member within the source namespace.desc- The descriptor of the member.- Returns:
- A
Collectionof allmember referencesthat match the criterions.
-