mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-21 03:22:17 +00:00
Export transformed class even if verification fails to allow inspection
This commit is contained in:
1 parent
fd495c58db
commit
6b43ea7de6
2 files changed
+33
-6
No files matched your search
@@ -37,9 +37,6 @@ import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -55,11 +52,16 @@ import org.spongepowered.asm.mixin.MixinEnvironment.Phase;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinErrorHandler;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinErrorHandler.ErrorAction;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTransformerModuleCheckClass.ValidationFailedException;
|
||||
import org.spongepowered.asm.mixin.transformer.debug.IDecompiler;
|
||||
import org.spongepowered.asm.mixin.transformer.debug.IHotSwap;
|
||||
import org.spongepowered.asm.mixin.transformer.meta.MixinMerged;
|
||||
import org.spongepowered.asm.transformers.TreeTransformer;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
|
||||
/**
|
||||
* Transformer which manages the mixin configuration and application process
|
||||
*/
|
||||
@@ -615,7 +617,15 @@ public class MixinTransformer extends TreeTransformer {
|
||||
|
||||
this.preApply(transformedName, targetClass, mixins);
|
||||
this.apply(transformedName, targetClass, mixins);
|
||||
this.postApply(transformedName, targetClass, mixins);
|
||||
try {
|
||||
this.postApply(transformedName, targetClass, mixins);
|
||||
} catch (ValidationFailedException ex) {
|
||||
this.logger.info(ex.getMessage());
|
||||
// If verify is enabled and failed, write out the bytecode to allow us to inspect it
|
||||
if (MixinEnvironment.getCurrentEnvironment().getOption(Option.DEBUG_EXPORT)) {
|
||||
this.writeClass(transformedName, targetClass);
|
||||
}
|
||||
}
|
||||
|
||||
return this.writeClass(transformedName, targetClass);
|
||||
}
|
||||
|
||||
+19
-2
@@ -36,6 +36,24 @@ import org.spongepowered.asm.lib.util.CheckClassAdapter;
|
||||
* bytecode
|
||||
*/
|
||||
public class MixinTransformerModuleCheckClass implements IMixinTransformerModule {
|
||||
|
||||
public static class ValidationFailedException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ValidationFailedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ValidationFailedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ValidationFailedException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.spongepowered.asm.mixin.transformer.IMixinTransformerModule
|
||||
@@ -56,8 +74,7 @@ public class MixinTransformerModuleCheckClass implements IMixinTransformerModule
|
||||
try {
|
||||
targetClass.accept(new CheckClassAdapter(new MixinClassWriter(ClassWriter.COMPUTE_FRAMES)));
|
||||
} catch (RuntimeException ex) {
|
||||
System.err.printf("%s\n", ex.getMessage());
|
||||
throw ex;
|
||||
throw new ValidationFailedException(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user