Class ReferenceMapper
java.lang.Object
org.spongepowered.asm.mixin.refmap.ReferenceMapper
- All Implemented Interfaces:
Serializable,IReferenceMapper
Stores runtime information allowing field, method and type references which
cannot be hard remapped by the reobfuscation process to be remapped in a
"soft" manner at runtime. Refmaps are generated by the Annotation
Processor at compile time and must be bundled with an obfuscated binary
to allow obfuscated references in injectors and other String-defined targets
to be remapped to the target obfsucation environment as appropriate. If the
refmap is absent the environment is assumed to be deobfuscated (eg. dev-time)
and injections and other transformations will fail if this is not the case.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ReferenceMapperPassthrough mapper, used as failoverstatic final StringResource to attempt to load if no source is specified explicitly -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMapping(String context, String className, String reference, String newReference) Add a mapping to this refmapGet the current contextGet the resource name this refmap was loaded from (if available).Get a user-readable "status" string for this refmap for use in error messagesbooleanGet whether this mapper is defaulted.static ReferenceMapperRead a new refmap instance from the specified readerstatic ReferenceMapperRead a new refmap from the specified resourceRemap a reference for the specified owning class in the current contextremapWithContext(String context, String className, String reference) Remap a reference for the specified owning class in the specified contextvoidsetContext(String context) Set the current remap context, can be nullvoidwrite(Appendable writer) Write this refmap out to the specified writer
-
Field Details
-
DEFAULT_RESOURCE
Resource to attempt to load if no source is specified explicitly- See Also:
-
DEFAULT_MAPPER
Passthrough mapper, used as failover
-
-
Constructor Details
-
ReferenceMapper
public ReferenceMapper()Create an empty refmap
-
-
Method Details
-
isDefault
public boolean isDefault()Description copied from interface:IReferenceMapperGet whether this mapper is defaulted. Use this flag rather than reference comparison toDEFAULT_MAPPERbecause of classloader shenanigans- Specified by:
isDefaultin interfaceIReferenceMapper- Returns:
- true if this mapper is a defaulted mapper
-
getResourceName
Description copied from interface:IReferenceMapperGet the resource name this refmap was loaded from (if available).- Specified by:
getResourceNamein interfaceIReferenceMapper- Returns:
- name of the resource
-
getStatus
Description copied from interface:IReferenceMapperGet a user-readable "status" string for this refmap for use in error messages- Specified by:
getStatusin interfaceIReferenceMapper- Returns:
- status message
-
getContext
Description copied from interface:IReferenceMapperGet the current context- Specified by:
getContextin interfaceIReferenceMapper- Returns:
- current context key, can be null
-
setContext
Description copied from interface:IReferenceMapperSet the current remap context, can be null- Specified by:
setContextin interfaceIReferenceMapper- Parameters:
context- remap context
-
remap
Description copied from interface:IReferenceMapperRemap a reference for the specified owning class in the current context- Specified by:
remapin interfaceIReferenceMapper- Parameters:
className- Owner classreference- Reference to remap- Returns:
- remapped reference, returns original reference if not remapped
-
remapWithContext
Description copied from interface:IReferenceMapperRemap a reference for the specified owning class in the specified context- Specified by:
remapWithContextin interfaceIReferenceMapper- Parameters:
context- Remap context to useclassName- Owner classreference- Reference to remap- Returns:
- remapped reference, returns original reference if not remapped
-
addMapping
Add a mapping to this refmap- Parameters:
context- Obfuscation context, can be nullclassName- Class which owns this mapping, cannot be nullreference- Reference to remap, cannot be nullnewReference- Remapped value, cannot be null- Returns:
- replaced value, per the contract of
Map.put(K, V)
-
write
Write this refmap out to the specified writer- Parameters:
writer- Writer to write to
-
read
Read a new refmap from the specified resource- Parameters:
resourcePath- Resource to read from- Returns:
- new refmap or
DEFAULT_MAPPERif reading fails
-
read
Read a new refmap instance from the specified reader- Parameters:
reader- Reader to read fromname- Name of the resource being read from- Returns:
- new refmap
-