Add refmapper debugging/runtime flags

This commit is contained in:
Mumfrey committed 2016-01-07 16:29:58 +00:00
1 parent 30e2530d34
commit fb2360cce7
3 files changed
+50 -4

No files matched your search

@@ -317,7 +317,27 @@ public class MixinEnvironment implements ITokenProvider {
/**
* Enables the hot-swap agent
*/
HOT_SWAP("hotSwap");
HOT_SWAP("hotSwap"),
/**
* Parent for environment settings
*/
ENVIRONMENT("env") {
@Override
boolean getBooleanValue() {
return false;
}
},
/**
* Force refmap obf type when required
*/
OBFUSCATION_TYPE(Option.ENVIRONMENT, "obf"),
/**
* Disable refmap when required
*/
DISABLE_REFMAP(Option.ENVIRONMENT, "disableRefMap");
/**
* Prefix for mixin options
@@ -925,6 +945,17 @@ public class MixinEnvironment implements ITokenProvider {
return this.obfuscationContext;
}
/**
* Get the current obfuscation context
*/
public String getRefmapObfuscationContext() {
String overrideObfuscationType = Option.OBFUSCATION_TYPE.getStringValue();
if (overrideObfuscationType != null) {
return overrideObfuscationType;
}
return this.obfuscationContext;
}
/**
* Get the remapper chain for this environment
*/
@@ -38,18 +38,27 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public final class ReferenceMapper implements Serializable {
private static final long serialVersionUID = 2L;
public static final String DEFAULT_RESOURCE = "mixin.refmap.json";
public static final ReferenceMapper DEFAULT_MAPPER = new ReferenceMapper(true);
private final Map<String, Map<String, String>> mappings = Maps.newHashMap();
private final Map<String, Map<String, Map<String, String>>> data = Maps.newHashMap();
private final transient boolean readOnly;
private transient String context = null;
public ReferenceMapper() {
this(false);
}
private ReferenceMapper(boolean readOnly) {
this.readOnly = readOnly;
}
public String getContext() {
@@ -93,6 +102,9 @@ public final class ReferenceMapper implements Serializable {
}
public void addMapping(String context, String className, String reference, String newReference) {
if (this.readOnly) {
return;
}
Map<String, Map<String, String>> mappings = this.mappings;
if (context != null) {
mappings = this.data.get(context);
@@ -119,7 +131,7 @@ public final class ReferenceMapper implements Serializable {
reader = new InputStreamReader(Launch.classLoader.getResourceAsStream(resource));
return ReferenceMapper.read(reader);
} catch (Exception ex) {
return new ReferenceMapper();
return ReferenceMapper.DEFAULT_MAPPER;
} finally {
if (reader != null) {
try {
@@ -440,7 +440,10 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
* Get the reference remapper for injectors
*/
public ReferenceMapper getReferenceMapper() {
this.refMapper.setContext(this.env.getObfuscationContext());
if (this.env.getOption(Option.DISABLE_REFMAP)) {
return ReferenceMapper.DEFAULT_MAPPER;
}
this.refMapper.setContext(this.env.getRefmapObfuscationContext());
return this.refMapper;
}