Disable signature merging unless decompiler is active, closes #254

This commit is contained in:
Mumfrey committed 2018-07-03 13:08:56 +01:00
1 parent 09b2a04ab2
commit 2c72246fe0
3 files changed
+46 -4

No files matched your search

@@ -238,6 +238,15 @@ public final class MixinEnvironment implements ITokenProvider {
*/
DEBUG_EXPORT_DECOMPILE_THREADED(Option.DEBUG_EXPORT_DECOMPILE, Inherit.ALLOW_OVERRIDE, "async"),
/**
* By default, if the runtime export decompiler is active, mixin generic
* signatures are merged into target classes. However this can cause
* problems with some runtime subsystems which attempt to reify generics
* using the signature data. Set this option to <tt>false</tt> to
* disable generic signature merging.
*/
DEBUG_EXPORT_DECOMPILE_MERGESIGNATURES(Option.DEBUG_EXPORT_DECOMPILE, Inherit.ALLOW_OVERRIDE, "mergeGenericSignatures"),
/**
* Run the CheckClassAdapter on all classes after mixins are applied,
* also enables stricter checks on mixins for use at dev-time, promotes
@@ -56,6 +56,7 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.transformer.ClassInfo.Field;
import org.spongepowered.asm.mixin.transformer.ext.extensions.ExtensionClassExporter;
import org.spongepowered.asm.mixin.transformer.meta.MixinMerged;
import org.spongepowered.asm.mixin.transformer.meta.MixinRenamed;
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
@@ -237,10 +238,22 @@ class MixinApplicatorStandard {
*/
protected final Profiler profiler = MixinEnvironment.getProfiler();
/**
* Flag to track whether signatures from applied mixins should be merged
* into target classes. This is only true when the runtime decompiler is
* active. If this is disabled, signatures on merged mixin methods are
* stripped instead of remapped.
*/
protected final boolean mergeSignatures;
MixinApplicatorStandard(TargetClassContext context) {
this.context = context;
this.targetName = context.getClassName();
this.targetClass = context.getClassNode();
ExtensionClassExporter exporter = context.getExtensions().<ExtensionClassExporter>getExtension(ExtensionClassExporter.class);
this.mergeSignatures = exporter.isDecompilerActive()
&& MixinEnvironment.getCurrentEnvironment().getOption(Option.DEBUG_EXPORT_DECOMPILE_MERGESIGNATURES);
}
/**
@@ -316,7 +329,9 @@ class MixinApplicatorStandard {
}
protected void applySignature(MixinTargetContext mixin) {
this.context.mergeSignature(mixin.getSignature());
if (this.mergeSignatures) {
this.context.mergeSignature(mixin.getSignature());
}
}
/**
@@ -389,6 +404,16 @@ class MixinApplicatorStandard {
if (target == null) {
// This is just a local field, so add it
this.targetClass.fields.add(field);
if (field.signature != null) {
if (this.mergeSignatures) {
SignatureVisitor sv = mixin.getSignature().getRemapper();
new SignatureReader(field.signature).accept(sv);
field.signature = sv.toString();
} else {
field.signature = null;
}
}
}
}
}
@@ -468,9 +493,13 @@ class MixinApplicatorStandard {
mixin.methodMerged(method);
if (method.signature != null) {
SignatureVisitor sv = mixin.getSignature().getRemapper();
new SignatureReader(method.signature).accept(sv);
method.signature = sv.toString();
if (this.mergeSignatures) {
SignatureVisitor sv = mixin.getSignature().getRemapper();
new SignatureReader(method.signature).accept(sv);
method.signature = sv.toString();
} else {
method.signature = null;
}
}
}
@@ -75,6 +75,10 @@ public class ExtensionClassExporter implements IExtension {
}
}
public boolean isDecompilerActive() {
return this.decompiler != null;
}
private IDecompiler initDecompiler(MixinEnvironment env, File outputPath) {
if (!env.getOption(Option.DEBUG_EXPORT_DECOMPILE)) {
return null;