mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-21 08:02:13 +00:00
Deprecate/merge stuff to prepare for 0.6, version bump to 0.5.6
This commit is contained in:
1 parent
36b4392576
commit
ad64bc1d6d
73 files changed
+1090
-579
No files matched your search
@@ -60,7 +60,7 @@ public abstract class MixinBootstrap {
|
||||
/**
|
||||
* Subsystem version
|
||||
*/
|
||||
public static final String VERSION = "0.5.5";
|
||||
public static final String VERSION = "0.5.6";
|
||||
|
||||
/**
|
||||
* Blackboard key where the subsystem version will be stored to indicate
|
||||
|
||||
@@ -42,10 +42,13 @@ public class MixinLaunchAgentDefault extends MixinLaunchAgentAbstract {
|
||||
super(uri);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void prepare() {
|
||||
String compatibilityLevel = this.attributes.get(MixinLaunchAgentDefault.MFATT_COMPATIBILITY);
|
||||
if (compatibilityLevel != null) {
|
||||
MixinLaunchAgentAbstract.logger.warn("{} Setting mixin compatibility level via manifest is deprecated, "
|
||||
+ "use 'compatibilityLevel' key in config instead", this.container);
|
||||
MixinTweaker.setCompatibilityLevel(compatibilityLevel);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.CompatibilityLevel;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Phase;
|
||||
import org.spongepowered.asm.mixin.Mixins;
|
||||
|
||||
import net.minecraft.launchwrapper.ITweaker;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
@@ -213,6 +214,7 @@ public class MixinTweaker implements ITweaker {
|
||||
*
|
||||
* @param level compatibility level as a string
|
||||
*/
|
||||
@Deprecated
|
||||
static void setCompatibilityLevel(String level) {
|
||||
try {
|
||||
CompatibilityLevel value = CompatibilityLevel.valueOf(level.toUpperCase());
|
||||
@@ -234,13 +236,14 @@ public class MixinTweaker implements ITweaker {
|
||||
static void addConfig(String config) {
|
||||
if (config.endsWith(".json")) {
|
||||
MixinTweaker.logger.debug("Registering mixin config: {}", config);
|
||||
MixinEnvironment.getDefaultEnvironment().addConfiguration(config);
|
||||
Mixins.addConfiguration(config);
|
||||
} else if (config.contains(".json@")) {
|
||||
int pos = config.indexOf(".json@");
|
||||
String phaseName = config.substring(pos + 6);
|
||||
config = config.substring(0, pos + 5);
|
||||
Phase phase = Phase.forName(phaseName);
|
||||
if (phase != null) {
|
||||
MixinTweaker.logger.warn("Setting config phase via manifest is deprecated: {}. Specify target in config instead", config);
|
||||
MixinTweaker.logger.debug("Registering mixin config: {}", config);
|
||||
MixinEnvironment.getEnvironment(phase).addConfiguration(config);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.transformer.InvalidMixinException;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
|
||||
/**
|
||||
* This annotation has two uses:
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -51,7 +50,9 @@ import org.spongepowered.asm.launch.MixinBootstrap;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.mixin.extensibility.IEnvironmentTokenProvider;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.throwables.MixinException;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTransformer;
|
||||
import org.spongepowered.asm.obfuscation.RemapperChain;
|
||||
import org.spongepowered.asm.util.ITokenProvider;
|
||||
import org.spongepowered.asm.util.JavaVersion;
|
||||
import org.spongepowered.asm.util.PrettyPrinter;
|
||||
@@ -69,7 +70,7 @@ import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
* The mixin environment manages global state information for the mixin
|
||||
* subsystem.
|
||||
*/
|
||||
public class MixinEnvironment implements ITokenProvider {
|
||||
public final class MixinEnvironment implements ITokenProvider {
|
||||
|
||||
/**
|
||||
* Environment phase, deliberately not implemented as an enum
|
||||
@@ -440,9 +441,9 @@ public class MixinEnvironment implements ITokenProvider {
|
||||
*/
|
||||
public static enum CompatibilityLevel {
|
||||
|
||||
JAVA_6(Opcodes.V1_6, false),
|
||||
JAVA_6(6, Opcodes.V1_6, false),
|
||||
|
||||
JAVA_7(Opcodes.V1_7, false) {
|
||||
JAVA_7(7, Opcodes.V1_7, false) {
|
||||
|
||||
@Override
|
||||
boolean isSupported() {
|
||||
@@ -451,7 +452,7 @@ public class MixinEnvironment implements ITokenProvider {
|
||||
|
||||
},
|
||||
|
||||
JAVA_8(Opcodes.V1_8, true) {
|
||||
JAVA_8(8, Opcodes.V1_8, true) {
|
||||
|
||||
@Override
|
||||
boolean isSupported() {
|
||||
@@ -460,15 +461,25 @@ public class MixinEnvironment implements ITokenProvider {
|
||||
|
||||
};
|
||||
|
||||
private final int ver;
|
||||
|
||||
private final int classVersion;
|
||||
|
||||
private final boolean supportsMethodsInInterfaces;
|
||||
|
||||
private CompatibilityLevel(int classVersion, boolean resolveMethodsInInterfaces) {
|
||||
private CompatibilityLevel maxCompatibleLevel;
|
||||
|
||||
private CompatibilityLevel(int ver, int classVersion, boolean resolveMethodsInInterfaces) {
|
||||
this.ver = ver;
|
||||
this.classVersion = classVersion;
|
||||
this.supportsMethodsInInterfaces = resolveMethodsInInterfaces;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setMaxCompatibleLevel(CompatibilityLevel maxCompatibleLevel) {
|
||||
this.maxCompatibleLevel = maxCompatibleLevel;
|
||||
}
|
||||
|
||||
boolean isSupported() {
|
||||
return true;
|
||||
}
|
||||
@@ -482,7 +493,22 @@ public class MixinEnvironment implements ITokenProvider {
|
||||
}
|
||||
|
||||
public boolean isAtLeast(CompatibilityLevel level) {
|
||||
return this.ordinal() >= level.ordinal();
|
||||
return this.ver >= level.ver;
|
||||
}
|
||||
|
||||
public boolean canElevateTo(CompatibilityLevel level) {
|
||||
if (level == null || this.maxCompatibleLevel == null) {
|
||||
return true;
|
||||
}
|
||||
return level.ver <= this.maxCompatibleLevel.ver;
|
||||
}
|
||||
|
||||
public boolean canSupport(CompatibilityLevel level) {
|
||||
if (level == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return level.canElevateTo(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -640,10 +666,7 @@ public class MixinEnvironment implements ITokenProvider {
|
||||
*/
|
||||
private final boolean[] options;
|
||||
|
||||
/**
|
||||
* Error handlers for environment
|
||||
*/
|
||||
private final Set<String> errorHandlers = new LinkedHashSet<String>();
|
||||
// private final Map<String, MixinConfig> configs;
|
||||
|
||||
/**
|
||||
* List of token provider classes
|
||||
@@ -758,7 +781,9 @@ public class MixinEnvironment implements ITokenProvider {
|
||||
* Get mixin configurations from the blackboard
|
||||
*
|
||||
* @return list of registered mixin configs
|
||||
* @deprecated no replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public List<String> getMixinConfigs() {
|
||||
List<String> mixinConfigs = Blackboard.<List<String>>get(this.configsKey);
|
||||
if (mixinConfigs == null) {
|
||||
@@ -773,23 +798,31 @@ public class MixinEnvironment implements ITokenProvider {
|
||||
*
|
||||
* @param config Name of configuration resource to add
|
||||
* @return fluent interface
|
||||
* @deprecated use Mixins::addConfiguration instead
|
||||
*/
|
||||
@Deprecated
|
||||
public MixinEnvironment addConfiguration(String config) {
|
||||
Mixins.addConfiguration(config, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
void registerConfig(String config) {
|
||||
List<String> configs = this.getMixinConfigs();
|
||||
if (!configs.contains(config)) {
|
||||
configs.add(config);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new error handler class to this environment
|
||||
*
|
||||
* @param handlerName Handler class to add
|
||||
* @return fluent interface
|
||||
* @deprecated use Mixins::registerErrorHandlerClass
|
||||
*/
|
||||
@Deprecated
|
||||
public MixinEnvironment registerErrorHandlerClass(String handlerName) {
|
||||
this.errorHandlers.add(handlerName);
|
||||
Mixins.registerErrorHandlerClass(handlerName);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -858,9 +891,11 @@ public class MixinEnvironment implements ITokenProvider {
|
||||
* Get all registered error handlers for this environment
|
||||
*
|
||||
* @return set of error handler class names
|
||||
* @deprecated use Mixins::getErrorHandlerClasses
|
||||
*/
|
||||
@Deprecated
|
||||
public Set<String> getErrorHandlerClasses() {
|
||||
return Collections.<String>unmodifiableSet(this.errorHandlers);
|
||||
return Mixins.getErrorHandlerClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1160,7 +1195,9 @@ public class MixinEnvironment implements ITokenProvider {
|
||||
*
|
||||
* @param level Level to set, ignored if less than the current level
|
||||
* @throws IllegalArgumentException if the specified level is not supported
|
||||
* @deprecated set compatibility level in configuration
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setCompatibilityLevel(CompatibilityLevel level) throws IllegalArgumentException {
|
||||
if (level != MixinEnvironment.compatibility && level.isAtLeast(MixinEnvironment.compatibility)) {
|
||||
if (!level.isSupported()) {
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* This file is part of Mixin, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) SpongePowered <https://www.spongepowered.org>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.launch.Blackboard;
|
||||
import org.spongepowered.asm.mixin.transformer.Config;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
|
||||
/**
|
||||
* Entry point for registering global mixin resources. Compatibility with
|
||||
* pre-0.6 versions is maintained via the methods on {@link MixinEnvironment}
|
||||
* delegating to the methods here.
|
||||
*/
|
||||
public class Mixins {
|
||||
|
||||
/**
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger logger = LogManager.getLogger("mixin");
|
||||
|
||||
/**
|
||||
* Blackboard key storing mixin configs which are pending
|
||||
*/
|
||||
private static final String CONFIGS_KEY = Blackboard.Keys.CONFIGS + ".queue";
|
||||
|
||||
/**
|
||||
* Error handlers for environment
|
||||
*/
|
||||
private static final Set<String> errorHandlers = new LinkedHashSet<String>();
|
||||
|
||||
/**
|
||||
* Add a mixin configuration resource
|
||||
*
|
||||
* @param configFile path to configuration resource
|
||||
*/
|
||||
public static void addConfiguration(String configFile) {
|
||||
Mixins.addConfiguration(configFile, MixinEnvironment.getDefaultEnvironment());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
static void addConfiguration(String configFile, MixinEnvironment fallback) {
|
||||
Config config = null;
|
||||
|
||||
try {
|
||||
config = Config.create(configFile, fallback);
|
||||
} catch (Exception ex) {
|
||||
Mixins.logger.error("Error encountered reading mixin config " + configFile + ": " + ex.getClass().getName() + " " + ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
if (config != null) {
|
||||
MixinEnvironment env = config.getEnvironment();
|
||||
if (env != null) {
|
||||
env.registerConfig(configFile);
|
||||
}
|
||||
Mixins.getConfigs().add(config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current pending configs set, only configs which have yet to be
|
||||
* consumed are present in this set
|
||||
*/
|
||||
public static Set<Config> getConfigs() {
|
||||
Set<Config> mixinConfigs = Blackboard.<Set<Config>>get(Mixins.CONFIGS_KEY);
|
||||
if (mixinConfigs == null) {
|
||||
mixinConfigs = new LinkedHashSet<Config>();
|
||||
Launch.blackboard.put(Mixins.CONFIGS_KEY, mixinConfigs);
|
||||
}
|
||||
return mixinConfigs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a gloabl error handler class
|
||||
*
|
||||
* @param handlerName Fully qualified class name
|
||||
*/
|
||||
public static void registerErrorHandlerClass(String handlerName) {
|
||||
if (handlerName != null) {
|
||||
Mixins.errorHandlers.add(handlerName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current error handlers
|
||||
*/
|
||||
public static Set<String> getErrorHandlerClasses() {
|
||||
return Collections.<String>unmodifiableSet(Mixins.errorHandlers);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.spongepowered.asm.mixin.transformer.InvalidMixinException;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
|
||||
/**
|
||||
* Used to indicate a Mixin class member which is acting as a placeholder for a
|
||||
|
||||
@@ -51,8 +51,9 @@ public interface IMixinErrorHandler {
|
||||
WARN(Level.WARN),
|
||||
|
||||
/**
|
||||
* Throw a {@link org.spongepowered.asm.mixin.MixinApplyError} to halt
|
||||
* further processing if possible
|
||||
* Throw a
|
||||
* {@link org.spongepowered.asm.mixin.throwables.MixinApplyError} to
|
||||
* halt further processing if possible
|
||||
*/
|
||||
ERROR(Level.FATAL);
|
||||
|
||||
|
||||
@@ -106,11 +106,4 @@ public interface IMixinInfo {
|
||||
*/
|
||||
public abstract Phase getPhase();
|
||||
|
||||
/**
|
||||
* Get whether this is an interface mixin or not
|
||||
*
|
||||
* @return true if this is an interface mixin
|
||||
*/
|
||||
public abstract boolean isInterfaceMixin();
|
||||
|
||||
}
|
||||
@@ -32,6 +32,8 @@ import java.lang.annotation.Target;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InjectionError;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
|
||||
/**
|
||||
* Specifies that this mixin method should inject a callback (or
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.spongepowered.asm.mixin.injection.points.BeforeStringInvoke;
|
||||
import org.spongepowered.asm.mixin.injection.points.JumpInsnPoint;
|
||||
import org.spongepowered.asm.mixin.injection.points.MethodHead;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionPointData;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.spongepowered.asm.lib.tree.AnnotationNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InjectionValidationException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,8 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InjectionError;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
|
||||
/**
|
||||
* Specifies that this mixin method should inject an argument modifier to itself
|
||||
|
||||
@@ -30,6 +30,8 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InjectionError;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
|
||||
/**
|
||||
* Specifies that this mixin method should inject a constant modifier callback
|
||||
|
||||
@@ -30,6 +30,8 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InjectionError;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
|
||||
/**
|
||||
* Specifies that this mixin method should inject a variable modifier callback
|
||||
|
||||
@@ -30,6 +30,8 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InjectionError;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
|
||||
/**
|
||||
* <p>Specifies that this mixin method should redirect the specified
|
||||
|
||||
@@ -31,15 +31,15 @@ import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.Type;
|
||||
import org.spongepowered.asm.lib.tree.*;
|
||||
import org.spongepowered.asm.mixin.injection.Coerce;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionError;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionNodes.InjectionNode;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionPoint;
|
||||
import org.spongepowered.asm.mixin.injection.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.injection.Surrogate;
|
||||
import org.spongepowered.asm.mixin.injection.code.Injector;
|
||||
import org.spongepowered.asm.mixin.injection.points.BeforeReturn;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InjectionError;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
import org.spongepowered.asm.util.Locals;
|
||||
|
||||
@@ -42,9 +42,9 @@ import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionNodes.InjectionNode;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionPoint;
|
||||
import org.spongepowered.asm.mixin.injection.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
@@ -34,10 +34,10 @@ import org.spongepowered.asm.lib.tree.MethodInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.VarInsnNode;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionNodes.InjectionNode;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionPoint;
|
||||
import org.spongepowered.asm.mixin.injection.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.injection.code.Injector;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
|
||||
/**
|
||||
* Base class for injectors which inject at method invokes
|
||||
|
||||
@@ -31,11 +31,11 @@ import org.spongepowered.asm.lib.Type;
|
||||
import org.spongepowered.asm.lib.tree.InsnList;
|
||||
import org.spongepowered.asm.lib.tree.MethodInsnNode;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionPoint;
|
||||
import org.spongepowered.asm.mixin.injection.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionNodes.InjectionNode;
|
||||
import org.spongepowered.asm.mixin.injection.code.Injector;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
|
||||
/**
|
||||
* A bytecode injector which allows a single argument of a chosen method call to
|
||||
|
||||
+1
-1
@@ -30,9 +30,9 @@ import org.spongepowered.asm.lib.tree.AbstractInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.InsnList;
|
||||
import org.spongepowered.asm.lib.tree.VarInsnNode;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionNodes.InjectionNode;
|
||||
import org.spongepowered.asm.mixin.injection.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,11 +36,11 @@ import org.spongepowered.asm.lib.tree.MethodInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.VarInsnNode;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionNodes.InjectionNode;
|
||||
import org.spongepowered.asm.mixin.injection.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.code.Injector;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.injection.modify;
|
||||
|
||||
import org.spongepowered.asm.mixin.MixinException;
|
||||
import org.spongepowered.asm.mixin.throwables.MixinException;
|
||||
|
||||
/**
|
||||
* Thrown when an <em>implicit</em> discriminator (no args) fails to identify
|
||||
|
||||
+1
-1
@@ -35,11 +35,11 @@ import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.lib.tree.VarInsnNode;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionNodes.InjectionNode;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionPoint;
|
||||
import org.spongepowered.asm.mixin.injection.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.code.Injector;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.PrettyPrinter;
|
||||
|
||||
@@ -41,19 +41,19 @@ import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionError;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionNodes.InjectionNode;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionPoint;
|
||||
import org.spongepowered.asm.mixin.injection.InjectorGroupInfo;
|
||||
import org.spongepowered.asm.mixin.injection.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
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.injection.code.Injector;
|
||||
import org.spongepowered.asm.mixin.transformer.InvalidMixinException;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InjectionError;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
import org.spongepowered.asm.mixin.transformer.meta.MixinMerged;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.Map;
|
||||
import org.spongepowered.asm.lib.tree.AnnotationNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.InvalidInjectionPointException;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionPointException;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.injection.struct;
|
||||
|
||||
import org.spongepowered.asm.mixin.MixinException;
|
||||
import org.spongepowered.asm.mixin.throwables.MixinException;
|
||||
|
||||
/**
|
||||
* Thrown when a {@link MemberInfo} fails basic syntax validation
|
||||
|
||||
@@ -28,8 +28,9 @@ import org.spongepowered.asm.lib.Type;
|
||||
import org.spongepowered.asm.lib.tree.AbstractInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.FieldInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodInsnNode;
|
||||
import org.spongepowered.asm.mixin.MixinException;
|
||||
import org.spongepowered.asm.mixin.transformer.IReferenceMapperContext;
|
||||
import org.spongepowered.asm.mixin.refmap.IReferenceMapperContext;
|
||||
import org.spongepowered.asm.mixin.refmap.ReferenceMapper;
|
||||
import org.spongepowered.asm.mixin.throwables.MixinException;
|
||||
import org.spongepowered.asm.obfuscation.SrgMethod;
|
||||
import org.spongepowered.asm.util.SignaturePrinter;
|
||||
|
||||
|
||||
+1
-1
@@ -38,9 +38,9 @@ import org.spongepowered.asm.lib.tree.InsnList;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionPoint;
|
||||
import org.spongepowered.asm.mixin.injection.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.injection.code.Injector;
|
||||
import org.spongepowered.asm.mixin.injection.invoke.ModifyConstantInjector;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.injection;
|
||||
package org.spongepowered.asm.mixin.injection.throwables;
|
||||
|
||||
/**
|
||||
* Error to throw for critical injection problems
|
||||
+3
-1
@@ -22,7 +22,9 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.injection;
|
||||
package org.spongepowered.asm.mixin.injection.throwables;
|
||||
|
||||
import org.spongepowered.asm.mixin.injection.InjectorGroupInfo;
|
||||
|
||||
/**
|
||||
* Thrown when an injector group fails an injection check
|
||||
+10
-10
@@ -22,11 +22,11 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.injection;
|
||||
package org.spongepowered.asm.mixin.injection.throwables;
|
||||
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.InvalidMixinException;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
import org.spongepowered.asm.mixin.refmap.IReferenceMapperContext;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
|
||||
/**
|
||||
* Thrown when an injector fails a state check, for example if an injector
|
||||
@@ -34,12 +34,12 @@ import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
*/
|
||||
public class InvalidInjectionException extends InvalidMixinException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
private final InjectionInfo info;
|
||||
|
||||
public InvalidInjectionException(MixinTargetContext mixin, String message) {
|
||||
super(mixin, message);
|
||||
public InvalidInjectionException(IReferenceMapperContext context, String message) {
|
||||
super(context, message);
|
||||
this.info = null;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ public class InvalidInjectionException extends InvalidMixinException {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public InvalidInjectionException(MixinTargetContext mixin, Throwable cause) {
|
||||
super(mixin, cause);
|
||||
public InvalidInjectionException(IReferenceMapperContext context, Throwable cause) {
|
||||
super(context, cause);
|
||||
this.info = null;
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ public class InvalidInjectionException extends InvalidMixinException {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public InvalidInjectionException(MixinTargetContext mixin, String message, Throwable cause) {
|
||||
super(mixin, message, cause);
|
||||
public InvalidInjectionException(IReferenceMapperContext context, String message, Throwable cause) {
|
||||
super(context, message, cause);
|
||||
this.info = null;
|
||||
}
|
||||
|
||||
+7
-7
@@ -22,28 +22,28 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.injection;
|
||||
package org.spongepowered.asm.mixin.injection.throwables;
|
||||
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
import org.spongepowered.asm.mixin.refmap.IReferenceMapperContext;
|
||||
|
||||
/**
|
||||
* Thrown when an injection point cannot be parsed due to invalid data
|
||||
*/
|
||||
public class InvalidInjectionPointException extends InvalidInjectionException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
public InvalidInjectionPointException(MixinTargetContext mixin, String format, Object... args) {
|
||||
super(mixin, String.format(format, args));
|
||||
public InvalidInjectionPointException(IReferenceMapperContext context, String format, Object... args) {
|
||||
super(context, String.format(format, args));
|
||||
}
|
||||
|
||||
public InvalidInjectionPointException(InjectionInfo info, String format, Object... args) {
|
||||
super(info, String.format(format, args));
|
||||
}
|
||||
|
||||
public InvalidInjectionPointException(MixinTargetContext mixin, Throwable cause, String format, Object... args) {
|
||||
super(mixin, String.format(format, args), cause);
|
||||
public InvalidInjectionPointException(IReferenceMapperContext context, Throwable cause, String format, Object... args) {
|
||||
super(context, String.format(format, args), cause);
|
||||
}
|
||||
|
||||
public InvalidInjectionPointException(InjectionInfo info, Throwable cause, String format, Object... args) {
|
||||
+7
-2
@@ -22,14 +22,19 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.transformer;
|
||||
package org.spongepowered.asm.mixin.refmap;
|
||||
|
||||
import org.spongepowered.asm.mixin.injection.struct.ReferenceMapper;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
|
||||
/**
|
||||
* Context for performing reference mapping
|
||||
*/
|
||||
public interface IReferenceMapperContext {
|
||||
|
||||
/**
|
||||
* Get the mixin info
|
||||
*/
|
||||
public abstract IMixinInfo getMixin();
|
||||
|
||||
/**
|
||||
* Get the internal mixin class name
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.injection.struct;
|
||||
package org.spongepowered.asm.mixin.refmap;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
+1
-4
@@ -25,10 +25,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.audit;
|
||||
|
||||
import org.spongepowered.asm.mixin.MixinException;
|
||||
|
||||
package org.spongepowered.asm.mixin.throwables;
|
||||
|
||||
/**
|
||||
* Exception raised when a class was loaded before mixins were able to be
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin;
|
||||
package org.spongepowered.asm.mixin.throwables;
|
||||
|
||||
/**
|
||||
* Error to throw for required mixins when mixing of the mixin fails
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin;
|
||||
package org.spongepowered.asm.mixin.throwables;
|
||||
|
||||
/**
|
||||
* Base class for all mixin processor exceptions
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin;
|
||||
package org.spongepowered.asm.mixin.throwables;
|
||||
|
||||
/**
|
||||
* Error to throw for required configs when initialising of the config fails
|
||||
@@ -47,6 +47,7 @@ import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.Member.Type;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinInfo.MixinClassNode;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* This file is part of Mixin, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) SpongePowered <https://www.spongepowered.org>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.transformer;
|
||||
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfig;
|
||||
|
||||
/**
|
||||
* Handle for marshalling mixin configs outside of the transformer package
|
||||
*/
|
||||
public class Config {
|
||||
|
||||
/**
|
||||
* Config name, used as identity for the purposes of {@link #equals}
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Config
|
||||
*/
|
||||
private final MixinConfig config;
|
||||
|
||||
public Config(MixinConfig config) {
|
||||
this.name = config.getName();
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access inner config
|
||||
*/
|
||||
MixinConfig get() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get API-level config view
|
||||
*/
|
||||
public IMixinConfig getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get environment for the config
|
||||
*/
|
||||
public MixinEnvironment getEnvironment() {
|
||||
return this.config.getEnvironment();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.config.toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof Config && this.name.equals(((Config)obj).name);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method, create a config from the specified config file and fail
|
||||
* over to the specified environment if no selector is present in the config
|
||||
*
|
||||
* @param configFile config resource
|
||||
* @param outer failover environment
|
||||
* @return new config or null if invalid config version
|
||||
*/
|
||||
@Deprecated
|
||||
public static Config create(String configFile, MixinEnvironment outer) {
|
||||
return MixinConfig.create(configFile, outer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method, create a config from the specified config resource
|
||||
*
|
||||
* @param configFile config resource
|
||||
* @return new config or null if invalid config version
|
||||
*/
|
||||
public static Config create(String configFile) {
|
||||
return MixinConfig.create(configFile, MixinEnvironment.getDefaultEnvironment());
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.Method;
|
||||
import org.spongepowered.asm.mixin.transformer.meta.MixinRenamed;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,7 @@ package org.spongepowered.asm.mixin.transformer;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.tree.FieldInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodInsnNode;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
|
||||
/**
|
||||
|
||||
+4
-3
@@ -28,22 +28,23 @@ import java.util.Map.Entry;
|
||||
|
||||
import org.spongepowered.asm.lib.tree.FieldNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.mixin.injection.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.Field;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidInterfaceMixinException;
|
||||
|
||||
/**
|
||||
* Applicator for interface mixins, mainly just disables things which aren't
|
||||
* supported for interface mixins
|
||||
*/
|
||||
public class InterfaceMixinApplicator extends MixinApplicator {
|
||||
public class MixinApplicatorInterface extends MixinApplicatorStandard {
|
||||
|
||||
/**
|
||||
* ctor
|
||||
*
|
||||
* @param context applier context
|
||||
*/
|
||||
InterfaceMixinApplicator(TargetClassContext context) {
|
||||
MixinApplicatorInterface(TargetClassContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
+15
-14
@@ -55,17 +55,18 @@ import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.Field;
|
||||
import org.spongepowered.asm.mixin.transformer.meta.MixinMerged;
|
||||
import org.spongepowered.asm.mixin.transformer.meta.MixinRenamed;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
import org.spongepowered.asm.util.ConstraintParser;
|
||||
import org.spongepowered.asm.util.ConstraintParser.Constraint;
|
||||
import org.spongepowered.asm.util.ConstraintViolationException;
|
||||
import org.spongepowered.asm.util.InvalidConstraintException;
|
||||
import org.spongepowered.asm.util.throwables.ConstraintViolationException;
|
||||
import org.spongepowered.asm.util.throwables.InvalidConstraintException;
|
||||
|
||||
/**
|
||||
* Applies mixins to a target class
|
||||
*/
|
||||
public class MixinApplicator {
|
||||
public class MixinApplicatorStandard {
|
||||
|
||||
/**
|
||||
* Passes the mixin applicator applies to each mixin
|
||||
@@ -193,7 +194,7 @@ public class MixinApplicator {
|
||||
*/
|
||||
protected final ClassNode targetClass;
|
||||
|
||||
MixinApplicator(TargetClassContext context) {
|
||||
MixinApplicatorStandard(TargetClassContext context) {
|
||||
this.context = context;
|
||||
this.targetName = context.getClassName();
|
||||
this.targetClass = context.getClassNode();
|
||||
@@ -323,7 +324,7 @@ public class MixinApplicator {
|
||||
this.mergeAnnotations(shadow, target);
|
||||
|
||||
// Strip the FINAL flag from @Mutable non-private fields
|
||||
if (entry.getValue().isDecoratedMutable() && !MixinApplicator.hasFlag(target, Opcodes.ACC_PRIVATE)) {
|
||||
if (entry.getValue().isDecoratedMutable() && !MixinApplicatorStandard.hasFlag(target, Opcodes.ACC_PRIVATE)) {
|
||||
target.access &= ~Opcodes.ACC_FINAL;
|
||||
}
|
||||
}
|
||||
@@ -364,9 +365,9 @@ public class MixinApplicator {
|
||||
this.checkConstraints(mixin, overwrite);
|
||||
}
|
||||
|
||||
if (MixinApplicator.hasFlag(mixinMethod, Opcodes.ACC_STATIC)
|
||||
&& !MixinApplicator.hasFlag(mixinMethod, Opcodes.ACC_PRIVATE)
|
||||
&& !MixinApplicator.hasFlag(mixinMethod, Opcodes.ACC_SYNTHETIC)
|
||||
if (MixinApplicatorStandard.hasFlag(mixinMethod, Opcodes.ACC_STATIC)
|
||||
&& !MixinApplicatorStandard.hasFlag(mixinMethod, Opcodes.ACC_PRIVATE)
|
||||
&& !MixinApplicatorStandard.hasFlag(mixinMethod, Opcodes.ACC_SYNTHETIC)
|
||||
&& !isOverwrite) {
|
||||
throw new InvalidMixinException(mixin,
|
||||
String.format("Mixin %s contains non-private static method %s%s", mixin, mixinMethod.name, mixinMethod.desc));
|
||||
@@ -440,8 +441,8 @@ public class MixinApplicator {
|
||||
throw new ClassFormatError("Invalid @MixinMerged annotation found in" + mixin + " at " + method.name + " in " + this.targetClass.name);
|
||||
}
|
||||
|
||||
if (MixinApplicator.hasFlag(target, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE)
|
||||
&& MixinApplicator.hasFlag(method, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE)) {
|
||||
if (MixinApplicatorStandard.hasFlag(target, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE)
|
||||
&& MixinApplicatorStandard.hasFlag(method, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE)) {
|
||||
if (mixin.getEnvironment().getOption(Option.DEBUG_VERBOSE)) {
|
||||
this.logger.warn("Synthetic bridge method clash for {} in {}", method.name, mixin);
|
||||
}
|
||||
@@ -486,7 +487,7 @@ public class MixinApplicator {
|
||||
}
|
||||
|
||||
String methodName = method.name + method.desc;
|
||||
if (MixinApplicator.hasFlag(method, Opcodes.ACC_STATIC)) {
|
||||
if (MixinApplicatorStandard.hasFlag(method, Opcodes.ACC_STATIC)) {
|
||||
throw new InvalidMixinException(mixin, "@Intrinsic method cannot be static, found " + methodName + " in " + mixin);
|
||||
}
|
||||
|
||||
@@ -544,7 +545,7 @@ public class MixinApplicator {
|
||||
MethodNode target = this.findTargetMethod(method);
|
||||
|
||||
if (target != null) {
|
||||
AbstractInsnNode returnNode = MixinApplicator.findInsn(target, Opcodes.RETURN);
|
||||
AbstractInsnNode returnNode = MixinApplicatorStandard.findInsn(target, Opcodes.RETURN);
|
||||
|
||||
if (returnNode != null) {
|
||||
Iterator<AbstractInsnNode> injectIter = method.instructions.iterator();
|
||||
@@ -603,7 +604,7 @@ public class MixinApplicator {
|
||||
MethodNode ctor = null;
|
||||
|
||||
for (MethodNode mixinMethod : mixin.getMethods()) {
|
||||
if (Constants.CTOR.equals(mixinMethod.name) && MixinApplicator.hasLineNumbers(mixinMethod)) {
|
||||
if (Constants.CTOR.equals(mixinMethod.name) && MixinApplicatorStandard.hasLineNumbers(mixinMethod)) {
|
||||
if (ctor == null) {
|
||||
ctor = mixinMethod;
|
||||
} else {
|
||||
@@ -710,7 +711,7 @@ public class MixinApplicator {
|
||||
trimAtOpcode = -1;
|
||||
continue;
|
||||
}
|
||||
for (int ivalidOp : MixinApplicator.INITIALISER_OPCODE_BLACKLIST) {
|
||||
for (int ivalidOp : MixinApplicatorStandard.INITIALISER_OPCODE_BLACKLIST) {
|
||||
if (opcode == ivalidOp) {
|
||||
// At the moment I don't handle any transient locals because I haven't seen any in the wild, but let's avoid writing
|
||||
// code which will likely break things and fix it if a real test case ever appears
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* This file is part of Mixin, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) SpongePowered <https://www.spongepowered.org>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.transformer;
|
||||
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
|
||||
/**
|
||||
* ClassNode for a MixinInfo
|
||||
*/
|
||||
public class MixinClassNode extends ClassNode {
|
||||
|
||||
private final MixinInfo mixin;
|
||||
|
||||
public MixinClassNode(MixinInfo mixin) {
|
||||
this(Opcodes.ASM5, mixin);
|
||||
}
|
||||
|
||||
public MixinClassNode(int api, MixinInfo mixin) {
|
||||
super(api);
|
||||
this.mixin = mixin;
|
||||
}
|
||||
|
||||
public MixinInfo getMixin() {
|
||||
return this.mixin;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,8 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -41,12 +43,15 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.launch.MixinInitialisationError;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.CompatibilityLevel;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Phase;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfig;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.struct.ReferenceMapper;
|
||||
import org.spongepowered.asm.mixin.refmap.ReferenceMapper;
|
||||
import org.spongepowered.asm.mixin.transformer.debug.IHotSwap;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
import org.spongepowered.asm.util.VersionNumber;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -82,7 +87,7 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
* Global list of mixin classes, so we can skip any duplicates
|
||||
*/
|
||||
private static final Set<String> globalMixinList = new HashSet<String>();
|
||||
|
||||
|
||||
/**
|
||||
* Log even more things
|
||||
*/
|
||||
@@ -107,13 +112,30 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
* Synthetic inner classes for mixins in this set
|
||||
*/
|
||||
private final transient Set<String> syntheticInnerClasses = new HashSet<String>();
|
||||
|
||||
/**
|
||||
* Marshal
|
||||
*/
|
||||
private transient Config handle;
|
||||
|
||||
/**
|
||||
* Target selector, eg. @env(DEFAULT)
|
||||
*/
|
||||
@SerializedName("target")
|
||||
private String selector;
|
||||
|
||||
/**
|
||||
* Minimum version of the mixin subsystem required to correctly apply mixins
|
||||
* in this configuration.
|
||||
*/
|
||||
@SerializedName("minVersion")
|
||||
private String version;
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* Minimum compatibility level required for mixins in this set
|
||||
*/
|
||||
@SerializedName("compatibilityLevel")
|
||||
private String compatibility;
|
||||
|
||||
/**
|
||||
* Determines whether failures in this mixin config are considered terminal
|
||||
@@ -187,6 +209,11 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
* Intrinsic order (for sorting configurations with identical priority)
|
||||
*/
|
||||
private final transient int order = MixinConfig.configOrder++;
|
||||
|
||||
// /**
|
||||
// * Phase selector
|
||||
// */
|
||||
// private transient List<Selector> selectors;
|
||||
|
||||
/**
|
||||
* Parent environment
|
||||
@@ -223,7 +250,7 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
/**
|
||||
* Keep track of initialisation state
|
||||
*/
|
||||
private transient boolean initialised = false;
|
||||
private transient boolean prepared = false;
|
||||
|
||||
/**
|
||||
* Spawn via GSON, no public ctor for you
|
||||
@@ -233,18 +260,74 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
/**
|
||||
* Called immediately after deserialisation
|
||||
*
|
||||
* @param env Parent environment
|
||||
* @param name Mixin config name
|
||||
* @param fallbackEnvironment Fallback environment if not specified in
|
||||
* config
|
||||
* @return true if the config was successfully initialised and should be
|
||||
* returned, or false if initialisation failed and the config should
|
||||
* be discarded
|
||||
*/
|
||||
private boolean onLoad(MixinEnvironment env, String name) {
|
||||
this.env = env;
|
||||
private boolean onLoad(String name, MixinEnvironment fallbackEnvironment) {
|
||||
this.name = name;
|
||||
this.env = this.parseSelector(this.selector, fallbackEnvironment);
|
||||
this.initCompatibilityLevel();
|
||||
return this.checkVersion();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void initCompatibilityLevel() {
|
||||
if (this.compatibility == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CompatibilityLevel level = CompatibilityLevel.valueOf(this.compatibility.trim().toUpperCase());
|
||||
CompatibilityLevel current = MixinEnvironment.getCompatibilityLevel();
|
||||
|
||||
if (level == current) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Current level is higher than required but too new to support it
|
||||
if (current.isAtLeast(level)) {
|
||||
if (!current.canSupport(level)) {
|
||||
throw new MixinInitialisationError("Mixin config " + this.name + " requires compatibility level " + level + " which is too old");
|
||||
}
|
||||
}
|
||||
|
||||
// Current level is lower than required but current level prohibits elevation
|
||||
if (!current.canElevateTo(level)) {
|
||||
throw new MixinInitialisationError("Mixin config " + this.name + " requires compatibility level " + level + " which is prohibited by "
|
||||
+ current);
|
||||
}
|
||||
|
||||
MixinEnvironment.setCompatibilityLevel(level);
|
||||
}
|
||||
|
||||
// AMS - temp
|
||||
private MixinEnvironment parseSelector(String target, MixinEnvironment fallbackEnvironment) {
|
||||
if (target != null) {
|
||||
String[] selectors = target.split("[&\\| ]");
|
||||
for (String selector : selectors) {
|
||||
selector = selector.trim();
|
||||
Pattern environmentSelector = Pattern.compile("^@env(?:ironment)?\\(([A-Z]+)\\)$");
|
||||
Matcher environmentSelectorMatcher = environmentSelector.matcher(selector);
|
||||
if (environmentSelectorMatcher.matches()) {
|
||||
// only parse first env selector
|
||||
return MixinEnvironment.getEnvironment(Phase.forName(environmentSelectorMatcher.group(1)));
|
||||
}
|
||||
}
|
||||
|
||||
Phase phase = Phase.forName(target);
|
||||
if (phase != null) {
|
||||
return MixinEnvironment.getEnvironment(phase);
|
||||
}
|
||||
}
|
||||
return fallbackEnvironment;
|
||||
}
|
||||
|
||||
private boolean checkVersion() throws MixinInitialisationError {
|
||||
VersionNumber minVersion = VersionNumber.parse(this.version);
|
||||
VersionNumber curVersion = VersionNumber.parse(env.getVersion());
|
||||
VersionNumber curVersion = VersionNumber.parse(this.env.getVersion());
|
||||
if (minVersion.compareTo(curVersion) > 0) {
|
||||
this.logger.warn("Mixin config {} requires mixin subsystem version {} but {} was found. The mixin config will not be applied.",
|
||||
this.name, minVersion, curVersion);
|
||||
@@ -256,6 +339,13 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the config once it's selected
|
||||
*/
|
||||
void onSelect() {
|
||||
if (this.pluginClassName != null) {
|
||||
try {
|
||||
Class<?> pluginClass = Class.forName(this.pluginClassName, true, Launch.classLoader);
|
||||
@@ -285,9 +375,7 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
}
|
||||
|
||||
this.refMapper = ReferenceMapper.read(this.refMapperConfig);
|
||||
this.verboseLogging |= env.getOption(Option.DEBUG_VERBOSE);
|
||||
|
||||
return true;
|
||||
this.verboseLogging |= this.env.getOption(Option.DEBUG_VERBOSE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,20 +391,20 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
* either the <em>hasMixinsFor()</em> or <em>getMixinsFor()</em> methods.
|
||||
* </p>
|
||||
*/
|
||||
void initialise(IHotSwap hotSwapper) {
|
||||
if (this.initialised) {
|
||||
void prepare(IHotSwap hotSwapper) {
|
||||
if (this.prepared) {
|
||||
return;
|
||||
}
|
||||
this.initialised = true;
|
||||
this.prepared = true;
|
||||
|
||||
this.initialiseMixins(this.mixinClasses, false, hotSwapper);
|
||||
this.prepareMixins(this.mixinClasses, false, hotSwapper);
|
||||
|
||||
switch (this.env.getSide()) {
|
||||
case CLIENT:
|
||||
this.initialiseMixins(this.mixinClassesClient, false, hotSwapper);
|
||||
this.prepareMixins(this.mixinClassesClient, false, hotSwapper);
|
||||
break;
|
||||
case SERVER:
|
||||
this.initialiseMixins(this.mixinClassesServer, false, hotSwapper);
|
||||
this.prepareMixins(this.mixinClassesServer, false, hotSwapper);
|
||||
break;
|
||||
case UNKNOWN:
|
||||
//$FALL-THROUGH$
|
||||
@@ -329,7 +417,7 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
void postInitialise(IHotSwap hotSwapper) {
|
||||
if (this.plugin != null) {
|
||||
List<String> pluginMixins = this.plugin.getMixins();
|
||||
this.initialiseMixins(pluginMixins, true, hotSwapper);
|
||||
this.prepareMixins(pluginMixins, true, hotSwapper);
|
||||
}
|
||||
|
||||
for (Iterator<MixinInfo> iter = this.mixins.iterator(); iter.hasNext();) {
|
||||
@@ -361,7 +449,7 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
}
|
||||
}
|
||||
|
||||
private void initialiseMixins(List<String> mixinClasses, boolean suppressPlugin, IHotSwap hotSwapper) {
|
||||
private void prepareMixins(List<String> mixinClasses, boolean suppressPlugin, IHotSwap hotSwapper) {
|
||||
if (mixinClasses == null) {
|
||||
return;
|
||||
}
|
||||
@@ -407,6 +495,16 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
this.unhandledTargets.remove(transformedName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get marshalling handle
|
||||
*/
|
||||
public Config getHandle() {
|
||||
if (this.handle == null) {
|
||||
this.handle = new Config(this);
|
||||
}
|
||||
return this.handle;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.spongepowered.asm.mixin.transformer.IMixinConfig#isRequired()
|
||||
*/
|
||||
@@ -475,6 +573,11 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
String defaultGroup = this.injectorOptions.defaultGroup;
|
||||
return defaultGroup != null && !defaultGroup.isEmpty() ? defaultGroup : "default";
|
||||
}
|
||||
|
||||
// AMS - temp
|
||||
public boolean select(MixinEnvironment environment) {
|
||||
return this.env == environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of mixins in this config, for debug logging
|
||||
@@ -652,19 +755,19 @@ class MixinConfig implements Comparable<MixinConfig>, IMixinConfig {
|
||||
* specified configFile, which must be accessible on the classpath
|
||||
*
|
||||
* @param configFile
|
||||
* @param env parent environment
|
||||
* @param outer fallback environment
|
||||
* @return
|
||||
*/
|
||||
static MixinConfig create(String configFile, MixinEnvironment env) {
|
||||
static Config create(String configFile, MixinEnvironment outer) {
|
||||
try {
|
||||
MixinConfig config = new Gson().fromJson(new InputStreamReader(Launch.classLoader.getResourceAsStream(configFile)), MixinConfig.class);
|
||||
if (config.onLoad(env, configFile)) {
|
||||
return config;
|
||||
if (config.onLoad(configFile, outer)) {
|
||||
return config.getHandle();
|
||||
}
|
||||
return null;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
throw new IllegalArgumentException(String.format("The specified configuration file '%s' was invalid or could not be read", configFile));
|
||||
throw new IllegalArgumentException(String.format("The specified resource '%s' was invalid or could not be read", configFile), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ package org.spongepowered.asm.mixin.transformer;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -37,7 +38,6 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.lib.ClassReader;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.Type;
|
||||
import org.spongepowered.asm.lib.tree.AnnotationNode;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.lib.tree.FieldNode;
|
||||
@@ -48,12 +48,13 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.CompatibilityLevel;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Phase;
|
||||
import org.spongepowered.asm.mixin.MixinException;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfig;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.MixinReloadException;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
@@ -67,60 +68,105 @@ import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
* Runtime information bundle about a mixin
|
||||
*/
|
||||
class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
|
||||
/**
|
||||
* ClassNode for a MixinInfo
|
||||
*/
|
||||
public class MixinClassNode extends ClassNode {
|
||||
|
||||
public MixinClassNode(MixinInfo mixin) {
|
||||
this(Opcodes.ASM5);
|
||||
}
|
||||
|
||||
public MixinClassNode(int api) {
|
||||
super(api);
|
||||
}
|
||||
|
||||
public MixinInfo getMixin() {
|
||||
return MixinInfo.this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* State that can be reloaded.
|
||||
* Mixin preparation/parse/validation state
|
||||
*/
|
||||
private class ValidationState {
|
||||
class State {
|
||||
|
||||
/**
|
||||
* Mixin bytes (read once, generate tree on demand)
|
||||
*/
|
||||
byte[] mixinBytes;
|
||||
|
||||
/**
|
||||
* All interfaces implemented by this mixin, including soft
|
||||
* implementations
|
||||
*/
|
||||
final Set<String> interfaces = new HashSet<String>();
|
||||
|
||||
/**
|
||||
* Interfaces soft-implemented using {@link Implements}
|
||||
*/
|
||||
final List<InterfaceInfo> softImplements = new ArrayList<InterfaceInfo>();
|
||||
|
||||
/**
|
||||
* Synthetic inner classes
|
||||
*/
|
||||
final Set<String> syntheticInnerClasses = new HashSet<String>();
|
||||
private byte[] mixinBytes;
|
||||
|
||||
/**
|
||||
* Mixin ClassInfo
|
||||
*/
|
||||
final ClassInfo classInfo;
|
||||
private final ClassInfo classInfo;
|
||||
|
||||
/**
|
||||
* True if the superclass of the mixin is <b>not</b> the direct
|
||||
* superclass of one or more targets
|
||||
*/
|
||||
boolean detachedSuper;
|
||||
private boolean detachedSuper;
|
||||
|
||||
/**
|
||||
* All interfaces implemented by this mixin, including soft
|
||||
* implementations
|
||||
*/
|
||||
protected final Set<String> interfaces = new HashSet<String>();
|
||||
|
||||
/**
|
||||
* Interfaces soft-implemented using {@link Implements}
|
||||
*/
|
||||
protected final List<InterfaceInfo> softImplements = new ArrayList<InterfaceInfo>();
|
||||
|
||||
/**
|
||||
* Synthetic inner classes
|
||||
*/
|
||||
protected final Set<String> syntheticInnerClasses = new HashSet<String>();
|
||||
|
||||
/**
|
||||
* Initial ClassNode created for mixin validation, not used for actual
|
||||
* application
|
||||
*/
|
||||
ClassNode classNode;
|
||||
protected ClassNode classNode;
|
||||
|
||||
ValidationState(byte[] mixinBytes, ClassInfo classInfo) {
|
||||
this.mixinBytes = mixinBytes;
|
||||
this.classNode = this.getClassNode(0);
|
||||
this.classInfo = classInfo;
|
||||
State(byte[] mixinBytes) {
|
||||
this(mixinBytes, null);
|
||||
}
|
||||
|
||||
ValidationState(byte[] mixinBytes) {
|
||||
State(byte[] mixinBytes, ClassInfo classInfo) {
|
||||
this.mixinBytes = mixinBytes;
|
||||
this.classNode = this.getClassNode(0);
|
||||
this.classInfo = ClassInfo.fromClassNode(this.classNode);
|
||||
this.classNode = this.createClassNode(0);
|
||||
this.classInfo = classInfo != null ? classInfo : ClassInfo.fromClassNode(this.classNode);
|
||||
}
|
||||
|
||||
ClassInfo getClassInfo() {
|
||||
return this.classInfo;
|
||||
}
|
||||
|
||||
byte[] getClassBytes() {
|
||||
return this.mixinBytes;
|
||||
}
|
||||
|
||||
ClassNode getClassNode() {
|
||||
return this.classNode;
|
||||
}
|
||||
|
||||
boolean isDetachedSuper() {
|
||||
return this.detachedSuper;
|
||||
}
|
||||
|
||||
List<? extends InterfaceInfo> getSoftImplements() {
|
||||
return this.softImplements;
|
||||
}
|
||||
|
||||
Set<String> getSyntheticInnerClasses() {
|
||||
return this.syntheticInnerClasses;
|
||||
}
|
||||
|
||||
Set<String> getInterfaces() {
|
||||
return this.interfaces;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,23 +175,147 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
* @param flags Flags passed into classReader
|
||||
* @return Tree representing the bytecode
|
||||
*/
|
||||
ClassNode getClassNode(int flags) {
|
||||
ClassNode createClassNode(int flags) {
|
||||
MixinClassNode classNode = new MixinClassNode(MixinInfo.this);
|
||||
ClassReader classReader = new ClassReader(this.mixinBytes);
|
||||
classReader.accept(classNode, flags);
|
||||
return classNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs pre-flight checks on the mixin
|
||||
*
|
||||
* @param type Mixin Type
|
||||
* @param targetClasses Mixin's target classes
|
||||
*/
|
||||
void validate(SubType type, List<ClassInfo> targetClasses) {
|
||||
type.validate(this, targetClasses);
|
||||
|
||||
this.detachedSuper = type.isDetachedSuper();
|
||||
|
||||
// Pre-flight checks
|
||||
this.validateInner();
|
||||
this.validateClassVersion();
|
||||
this.validateRemappables(targetClasses);
|
||||
|
||||
// Read information from the mixin
|
||||
this.readImplementations();
|
||||
this.readInnerClasses();
|
||||
|
||||
// Takeoff validation
|
||||
this.validateChanges(type, targetClasses);
|
||||
|
||||
// Null out the validation classnode
|
||||
this.classNode = null;
|
||||
}
|
||||
|
||||
private void validateInner() {
|
||||
// isInner (shouldn't) return true for static inner classes
|
||||
if (!this.classInfo.isProbablyStatic()) {
|
||||
throw new InvalidMixinException(MixinInfo.this, "Inner class mixin must be declared static");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateClassVersion() {
|
||||
if (this.classNode.version > MixinEnvironment.getCompatibilityLevel().classVersion()) {
|
||||
String helpText = ".";
|
||||
for (CompatibilityLevel level : CompatibilityLevel.values()) {
|
||||
if (level.classVersion() >= this.classNode.version) {
|
||||
helpText = String.format(". Mixin requires compatibility level %s or above.", level.name());
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidMixinException(MixinInfo.this, "Unsupported mixin class version " + this.classNode.version + helpText);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateRemappables(List<ClassInfo> targetClasses) {
|
||||
// Can't have remappable fields or methods on a multi-target mixin, because after obfuscation the fields will remap to conflicting names
|
||||
if (targetClasses.size() > 1) {
|
||||
for (FieldNode field : this.classNode.fields) {
|
||||
this.validateRemappable(Shadow.class, field.name, ASMHelper.getVisibleAnnotation(field, Shadow.class));
|
||||
}
|
||||
|
||||
for (MethodNode method : this.classNode.methods) {
|
||||
this.validateRemappable(Shadow.class, method.name, ASMHelper.getVisibleAnnotation(method, Shadow.class));
|
||||
AnnotationNode overwrite = ASMHelper.getVisibleAnnotation(method, Overwrite.class);
|
||||
if (overwrite != null && ((method.access & Opcodes.ACC_STATIC) == 0 || (method.access & Opcodes.ACC_PUBLIC) == 0)) {
|
||||
throw new InvalidMixinException(MixinInfo.this, "Found @Overwrite annotation on " + method.name + " in " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validateRemappable(Class<Shadow> annotationClass, String name, AnnotationNode annotation) {
|
||||
if (annotation != null && ASMHelper.getAnnotationValue(annotation, "remap", Boolean.TRUE)) {
|
||||
throw new InvalidMixinException(MixinInfo.this, "Found a remappable @" + annotationClass.getSimpleName() + " annotation on " + name
|
||||
+ " in " + this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read and process any {@link Implements} annotations on the mixin
|
||||
*/
|
||||
void readImplementations() {
|
||||
this.interfaces.addAll(this.classNode.interfaces);
|
||||
|
||||
AnnotationNode implementsAnnotation = ASMHelper.getInvisibleAnnotation(this.classNode, Implements.class);
|
||||
if (implementsAnnotation == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<AnnotationNode> interfaces = ASMHelper.getAnnotationValue(implementsAnnotation);
|
||||
if (interfaces == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (AnnotationNode interfaceNode : interfaces) {
|
||||
InterfaceInfo interfaceInfo = InterfaceInfo.fromAnnotation(MixinInfo.this, interfaceNode);
|
||||
this.softImplements.add(interfaceInfo);
|
||||
this.interfaces.add(interfaceInfo.getInternalName());
|
||||
// only add interface if its initial initialisation
|
||||
if (!(this instanceof Reloaded)) {
|
||||
this.classInfo.addInterface(interfaceInfo.getInternalName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read inner class definitions for the class and locate any synthetic
|
||||
* inner classes so that we can add them to the passthrough set in our
|
||||
* parent config.
|
||||
*/
|
||||
void readInnerClasses() {
|
||||
for (InnerClassNode inner : this.classNode.innerClasses) {
|
||||
ClassInfo innerClass = ClassInfo.forName(inner.name);
|
||||
if (innerClass.isSynthetic() && innerClass.isProbablyStatic()) {
|
||||
if ((inner.outerName != null && inner.outerName.equals(this.classInfo.getName()))
|
||||
|| inner.name.startsWith(this.classNode.name + "$")) {
|
||||
this.syntheticInnerClasses.add(inner.name);
|
||||
} else {
|
||||
throw new InvalidMixinException(MixinInfo.this, "Unhandled synthetic inner class found: " + inner.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void validateChanges(SubType type, List<ClassInfo> targetClasses) {
|
||||
type.createPreProcessor(this.classNode).prepare();
|
||||
}
|
||||
}
|
||||
|
||||
private class ReloadedState extends ValidationState {
|
||||
/**
|
||||
* State use when hotswap reloading a mixin
|
||||
*/
|
||||
class Reloaded extends State {
|
||||
|
||||
/**
|
||||
* The previous validation state to compare the changes to
|
||||
*/
|
||||
private final ValidationState previous;
|
||||
private final State previous;
|
||||
|
||||
ReloadedState(ValidationState previous, byte[] mixinBytes) {
|
||||
super(mixinBytes, previous.classInfo);
|
||||
Reloaded(State previous, byte[] mixinBytes) {
|
||||
super(mixinBytes, previous.getClassInfo());
|
||||
this.previous = previous;
|
||||
}
|
||||
|
||||
@@ -153,7 +323,8 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
* Validates that the changes are allowed to be made, these restrictions
|
||||
* only exits while reloading mixins.
|
||||
*/
|
||||
void validateChanges() {
|
||||
@Override
|
||||
protected void validateChanges(SubType type, List<ClassInfo> targetClasses) {
|
||||
if (!this.syntheticInnerClasses.equals(this.previous.syntheticInnerClasses)) {
|
||||
throw new MixinReloadException(MixinInfo.this, "Cannot change inner classes");
|
||||
}
|
||||
@@ -164,7 +335,7 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
throw new MixinReloadException(MixinInfo.this, "Cannot change soft interfaces");
|
||||
}
|
||||
List<ClassInfo> targets = MixinInfo.this.readTargetClasses(this.classNode, true);
|
||||
if (!new HashSet<ClassInfo>(targets).equals(new HashSet<ClassInfo>(MixinInfo.this.getTargets0()))) {
|
||||
if (!new HashSet<ClassInfo>(targets).equals(new HashSet<ClassInfo>(targetClasses))) {
|
||||
throw new MixinReloadException(MixinInfo.this, "Cannot change target classes");
|
||||
}
|
||||
int priority = MixinInfo.this.readPriority(this.classNode);
|
||||
@@ -173,7 +344,142 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mixin sub-type, eg. standard mixin, interface mixin, accessor
|
||||
*/
|
||||
abstract static class SubType {
|
||||
|
||||
/**
|
||||
* Outer
|
||||
*/
|
||||
protected final MixinInfo mixin;
|
||||
|
||||
/**
|
||||
* String representation of annotation type, for use in messages
|
||||
*/
|
||||
protected final String annotationType;
|
||||
|
||||
/**
|
||||
* Target of this mixin subtype must be an interface, false for a class
|
||||
*/
|
||||
protected final boolean targetMustBeInterface;
|
||||
|
||||
/**
|
||||
* Detached super, parsed out during validation
|
||||
*/
|
||||
protected boolean detached;
|
||||
|
||||
SubType(MixinInfo info, String annotationType, boolean targetMustBeInterface) {
|
||||
this.mixin = info;
|
||||
this.annotationType = annotationType;
|
||||
this.targetMustBeInterface = targetMustBeInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether this mixin is detached super, must call {@link #validate}
|
||||
* first
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isDetachedSuper() {
|
||||
return this.detached;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a single target before adding
|
||||
*
|
||||
* @param targetName
|
||||
* @param targetInfo
|
||||
*/
|
||||
void validateTarget(String targetName, ClassInfo targetInfo) {
|
||||
boolean targetIsInterface = targetInfo.isInterface();
|
||||
if (targetIsInterface != this.targetMustBeInterface) {
|
||||
String not = targetIsInterface ? "" : "not ";
|
||||
throw new InvalidMixinException(this.mixin, this.annotationType + " target type mismatch: " + targetName
|
||||
+ " is " + not + "an interface in " + this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract void validate(State state, List<ClassInfo> targetClasses);
|
||||
|
||||
abstract MixinPreProcessorStandard createPreProcessor(ClassNode classNode);
|
||||
|
||||
/**
|
||||
* A standard mixin
|
||||
*/
|
||||
static class Standard extends SubType {
|
||||
|
||||
Standard(MixinInfo info) {
|
||||
super(info, "@Mixin", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
void validate(State state, List<ClassInfo> targetClasses) {
|
||||
ClassNode classNode = state.getClassNode();
|
||||
|
||||
for (ClassInfo targetClass : targetClasses) {
|
||||
if (classNode.superName.equals(targetClass.getSuperName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!targetClass.hasSuperClass(classNode.superName, ClassInfo.Traversal.SUPER)) {
|
||||
ClassInfo superClass = ClassInfo.forName(classNode.superName);
|
||||
if (superClass.isMixin()) {
|
||||
// If superclass is a mixin, check for hierarchy derp
|
||||
for (ClassInfo superTarget : superClass.getTargets()) {
|
||||
if (targetClasses.contains(superTarget)) {
|
||||
throw new InvalidMixinException(this.mixin, "Illegal hierarchy detected. Derived mixin " + this
|
||||
+ " targets the same class " + superTarget.getClassName() + " as its superclass "
|
||||
+ superClass.getClassName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidMixinException(this.mixin, "Super class '" + classNode.superName.replace('/', '.') + "' of "
|
||||
+ this.mixin.getName() + " was not found in the hierarchy of target class '" + targetClass + "'");
|
||||
}
|
||||
|
||||
this.detached = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
MixinPreProcessorStandard createPreProcessor(ClassNode classNode) {
|
||||
return new MixinPreProcessorStandard(this.mixin, classNode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface mixin
|
||||
*/
|
||||
static class Interface extends SubType {
|
||||
|
||||
Interface(MixinInfo info) {
|
||||
super(info, "@Mixin", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
void validate(State state, List<ClassInfo> targetClasses) {
|
||||
if (!MixinEnvironment.getCompatibilityLevel().supportsMethodsInInterfaces()) {
|
||||
throw new InvalidMixinException(this.mixin, "Interface mixin not supported in current enviromnment");
|
||||
}
|
||||
|
||||
ClassNode classNode = state.getClassNode();
|
||||
|
||||
if (!"java/lang/Object".equals(classNode.superName)) {
|
||||
throw new InvalidMixinException(this.mixin, "Super class of " + this + " is invalid, found "
|
||||
+ classNode.superName.replace('/', '.'));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
MixinPreProcessorStandard createPreProcessor(ClassNode classNode) {
|
||||
return new MixinPreProcessorInterface(this.mixin, classNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Global order of mixin infos, used to determine ordering between mixins
|
||||
* with equivalent priority
|
||||
@@ -238,19 +544,19 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
private final transient ClassInfo info;
|
||||
|
||||
/**
|
||||
* True if this is an interface mixin rather than a regular mixin
|
||||
* Mixin type
|
||||
*/
|
||||
private final transient boolean isInterfaceMixin;
|
||||
private final transient SubType type;
|
||||
|
||||
/**
|
||||
* Holds state that currently is not fully initialised or validated
|
||||
*/
|
||||
private transient ValidationState uninitialisedState;
|
||||
private transient State pendingState;
|
||||
|
||||
/**
|
||||
* Holds the current validated state
|
||||
*/
|
||||
private transient ValidationState validationState;
|
||||
private transient State state;
|
||||
|
||||
/**
|
||||
* Internal ctor, called by {@link MixinConfig}
|
||||
@@ -269,41 +575,50 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
this.plugin = plugin;
|
||||
this.phase = MixinEnvironment.getCurrentEnvironment().getPhase();
|
||||
|
||||
ClassNode classNode = null;
|
||||
|
||||
// Read the class bytes and transform
|
||||
try {
|
||||
byte[] mixinBytes = this.loadMixinClass(this.className, runTransformers);
|
||||
this.uninitialisedState = new ValidationState(mixinBytes);
|
||||
this.info = this.uninitialisedState.classInfo;
|
||||
classNode = this.uninitialisedState.getClassNode(0);
|
||||
this.isInterfaceMixin = this.info.isInterface();
|
||||
this.pendingState = new State(this.loadMixinClass(this.className, runTransformers));
|
||||
this.info = this.pendingState.getClassInfo();
|
||||
this.type = this.initType();
|
||||
} catch (Exception ex) {
|
||||
throw new InvalidMixinException(this, ex);
|
||||
}
|
||||
|
||||
// Read the class bytes and transform
|
||||
try {
|
||||
this.priority = this.readPriority(this.pendingState.getClassNode());
|
||||
this.targetClasses = this.readTargetClasses(this.pendingState.getClassNode(), suppressPlugin);
|
||||
this.targetClassNames = Collections.unmodifiableList(Lists.transform(this.targetClasses, Functions.toStringFunction()));
|
||||
} catch (Exception ex) {
|
||||
throw new InvalidMixinException(this, ex);
|
||||
}
|
||||
|
||||
this.priority = this.readPriority(classNode);
|
||||
this.targetClasses = this.readTargetClasses(classNode, suppressPlugin);
|
||||
this.targetClassNames = Collections.unmodifiableList(Lists.transform(this.targetClasses, Functions.toStringFunction()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the mixin subtype handler
|
||||
*
|
||||
* @return subtype
|
||||
*/
|
||||
private SubType initType() {
|
||||
if (this.info.isInterface()) {
|
||||
return new SubType.Interface(this);
|
||||
}
|
||||
return new SubType.Standard(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run validation pass
|
||||
*/
|
||||
void validate() {
|
||||
if (this.pendingState == null) {
|
||||
throw new IllegalStateException("No pending validation state for " + this);
|
||||
}
|
||||
|
||||
try {
|
||||
ClassNode classNode = this.uninitialisedState.classNode;
|
||||
this.uninitialisedState.detachedSuper = this.validateTargetClasses(classNode);
|
||||
this.validateMixin(this.uninitialisedState);
|
||||
this.readImplementations(this.uninitialisedState);
|
||||
this.readInnerClasses(this.uninitialisedState);
|
||||
if (this.uninitialisedState instanceof ReloadedState) {
|
||||
((ReloadedState) this.uninitialisedState).validateChanges();
|
||||
} else {
|
||||
this.createPreProcessor(classNode).prepare();
|
||||
}
|
||||
this.uninitialisedState.classNode = null;
|
||||
// the state is now fully initialised and validated
|
||||
this.validationState = this.uninitialisedState;
|
||||
this.pendingState.validate(this.type, this.targetClasses);
|
||||
this.state = this.pendingState;
|
||||
} finally {
|
||||
this.uninitialisedState = null;
|
||||
this.pendingState = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,13 +640,13 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
}
|
||||
|
||||
List<ClassInfo> targets = new ArrayList<ClassInfo>();
|
||||
List<Type> publicTargets = ASMHelper.getAnnotationValue(mixin, "value");
|
||||
List<org.spongepowered.asm.lib.Type> publicTargets = ASMHelper.getAnnotationValue(mixin, "value");
|
||||
List<String> privateTargets = ASMHelper.getAnnotationValue(mixin, "targets");
|
||||
|
||||
if (publicTargets != null) {
|
||||
this.readTargets(targets, Lists.transform(publicTargets, new Function<Type, String>() {
|
||||
this.readTargets(targets, Lists.transform(publicTargets, new Function<org.spongepowered.asm.lib.Type, String>() {
|
||||
@Override
|
||||
public String apply(Type input) {
|
||||
public String apply(org.spongepowered.asm.lib.Type input) {
|
||||
return input.getClassName();
|
||||
}
|
||||
}), suppressPlugin, false);
|
||||
@@ -352,12 +667,11 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
/**
|
||||
* Reads a target list into the outTargets list
|
||||
*/
|
||||
private void readTargets(List<ClassInfo> outTargets, List<String> inTargets, boolean suppressPlugin, boolean checkPublic) {
|
||||
for (String targetClassName : inTargets) {
|
||||
targetClassName = targetClassName.replace('/', '.');
|
||||
if (this.plugin == null || suppressPlugin || this.plugin.shouldApplyMixin(targetClassName, this.className)) {
|
||||
ClassInfo targetInfo = ClassInfo.forName(targetClassName);
|
||||
this.checkTarget(targetClassName, targetInfo, checkPublic);
|
||||
private void readTargets(Collection<ClassInfo> outTargets, Collection<String> inTargets, boolean suppressPlugin, boolean checkPublic) {
|
||||
for (String targetName : inTargets) {
|
||||
targetName = targetName.replace('/', '.');
|
||||
if (this.plugin == null || suppressPlugin || this.plugin.shouldApplyMixin(targetName, this.className)) {
|
||||
ClassInfo targetInfo = this.getTarget(targetName, checkPublic);
|
||||
if (!outTargets.contains(targetInfo)) {
|
||||
outTargets.add(targetInfo);
|
||||
targetInfo.addMixin(this);
|
||||
@@ -366,19 +680,17 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkTarget(String targetClassName, ClassInfo targetInfo, boolean checkPublic) throws InvalidMixinException {
|
||||
private ClassInfo getTarget(String targetName, boolean checkPublic) throws InvalidMixinException {
|
||||
ClassInfo targetInfo = ClassInfo.forName(targetName);
|
||||
if (targetInfo == null) {
|
||||
throw new MixinException("@Mixin target " + targetClassName + " was not found " + this);
|
||||
}
|
||||
boolean targetIsInterface = targetInfo.isInterface();
|
||||
if (targetIsInterface != this.isInterfaceMixin) {
|
||||
String not = targetIsInterface ? "" : "not ";
|
||||
throw new InvalidMixinException(this, "@Mixin target type mismatch: " + targetClassName + " is " + not + "an interface in " + this);
|
||||
throw new InvalidMixinException(this, "@Mixin target " + targetName + " was not found " + this);
|
||||
}
|
||||
this.type.validateTarget(targetName, targetInfo);
|
||||
if (checkPublic && targetInfo.isPublic()) {
|
||||
throw new InvalidMixinException(this, "@Mixin target " + targetClassName + " is public in " + this
|
||||
throw new InvalidMixinException(this, "@Mixin target " + targetName + " is public in " + this
|
||||
+ " and must be specified in value");
|
||||
}
|
||||
return targetInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,170 +713,17 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
return priority == null ? this.parent.getDefaultMixinPriority() : priority.intValue();
|
||||
}
|
||||
|
||||
private boolean validateTargetClasses(ClassNode classNode) {
|
||||
if (this.isInterfaceMixin) {
|
||||
return this.validateInterfaceMixinTargets(classNode);
|
||||
}
|
||||
return this.validateClassMixinTargets(classNode);
|
||||
}
|
||||
|
||||
private boolean validateInterfaceMixinTargets(ClassNode classNode) {
|
||||
if (!"java/lang/Object".equals(classNode.superName)) {
|
||||
throw new InvalidMixinException(this, "Super class of " + this + " is invalid, found " + classNode.superName.replace('/', '.'));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean validateClassMixinTargets(ClassNode classNode) {
|
||||
boolean detached = false;
|
||||
|
||||
for (ClassInfo targetClass : this.targetClasses) {
|
||||
if (classNode.superName.equals(targetClass.getSuperName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!targetClass.hasSuperClass(classNode.superName, ClassInfo.Traversal.SUPER)) {
|
||||
ClassInfo superClass = ClassInfo.forName(classNode.superName);
|
||||
if (superClass.isMixin()) {
|
||||
// If superclass is a mixin, check for hierarchy derp
|
||||
for (ClassInfo superTarget : superClass.getTargets()) {
|
||||
if (this.targetClasses.contains(superTarget)) {
|
||||
throw new InvalidMixinException(this, "Illegal hierarchy detected. Derived mixin " + this + " targets the same class "
|
||||
+ superTarget.getClassName() + " as its superclass " + superClass.getClassName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidMixinException(this, "Super class '" + classNode.superName.replace('/', '.') + "' of " + this.name
|
||||
+ " was not found in the hierarchy of target class '" + targetClass + "'");
|
||||
}
|
||||
|
||||
detached = true;
|
||||
}
|
||||
|
||||
return detached;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs pre-flight checks on the mixin
|
||||
*
|
||||
* @param state State to validate
|
||||
*/
|
||||
private void validateMixin(ValidationState state) {
|
||||
this.validateType();
|
||||
this.validateInner(state);
|
||||
this.validateClassVersion(state);
|
||||
this.validateRemappables(state);
|
||||
}
|
||||
|
||||
private void validateType() {
|
||||
if (this.isInterfaceMixin && !MixinEnvironment.getCompatibilityLevel().supportsMethodsInInterfaces()) {
|
||||
throw new InvalidMixinException(this, "Interface mixin not supported in current enviromnment");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateInner(ValidationState state) {
|
||||
// isInner (shouldn't) return true for static inner classes
|
||||
if (!state.classInfo.isProbablyStatic()) {
|
||||
throw new InvalidMixinException(this, "Inner class mixin must be declared static");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateClassVersion(ValidationState state) {
|
||||
if (state.classNode.version > MixinEnvironment.getCompatibilityLevel().classVersion()) {
|
||||
String helpText = ".";
|
||||
for (CompatibilityLevel level : CompatibilityLevel.values()) {
|
||||
if (level.classVersion() >= state.classNode.version) {
|
||||
helpText = String.format(". Mixin requires compatibility level %s or above.", level.name());
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidMixinException(this, "Unsupported mixin class version " + state.classNode.version + helpText);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateRemappables(ValidationState state) {
|
||||
// Can't have remappable fields or methods on a multi-target mixin, because after obfuscation the fields will remap to conflicting names
|
||||
if (this.targetClasses.size() > 1) {
|
||||
for (FieldNode field : state.classNode.fields) {
|
||||
this.checkRemappable(Shadow.class, field.name, ASMHelper.getVisibleAnnotation(field, Shadow.class));
|
||||
}
|
||||
|
||||
for (MethodNode method : state.classNode.methods) {
|
||||
this.checkRemappable(Shadow.class, method.name, ASMHelper.getVisibleAnnotation(method, Shadow.class));
|
||||
AnnotationNode overwrite = ASMHelper.getVisibleAnnotation(method, Overwrite.class);
|
||||
if (overwrite != null && ((method.access & Opcodes.ACC_STATIC) == 0 || (method.access & Opcodes.ACC_PUBLIC) == 0)) {
|
||||
throw new InvalidMixinException(this, "Found @Overwrite annotation on " + method.name + " in " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkRemappable(Class<Shadow> annotationClass, String name, AnnotationNode annotation) {
|
||||
if (annotation != null && ASMHelper.getAnnotationValue(annotation, "remap", Boolean.TRUE)) {
|
||||
throw new InvalidMixinException(this, "Found a remappable @" + annotationClass.getSimpleName() + " annotation on " + name
|
||||
+ " in " + this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read and process any {@link Implements} annotations on the mixin
|
||||
*/
|
||||
private void readImplementations(ValidationState state) {
|
||||
state.interfaces.addAll(state.classNode.interfaces);
|
||||
|
||||
AnnotationNode implementsAnnotation = ASMHelper.getInvisibleAnnotation(state.classNode, Implements.class);
|
||||
if (implementsAnnotation == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<AnnotationNode> interfaces = ASMHelper.getAnnotationValue(implementsAnnotation);
|
||||
if (interfaces == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (AnnotationNode interfaceNode : interfaces) {
|
||||
InterfaceInfo interfaceInfo = InterfaceInfo.fromAnnotation(this, interfaceNode);
|
||||
state.softImplements.add(interfaceInfo);
|
||||
state.interfaces.add(interfaceInfo.getInternalName());
|
||||
// only add interface if its initial initialisation
|
||||
if (!(state instanceof ReloadedState)) {
|
||||
state.classInfo.addInterface(interfaceInfo.getInternalName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read inner class definitions for the class and locate any synthetic inner
|
||||
* classes so that we can add them to the passthrough set in our parent
|
||||
* config.
|
||||
*/
|
||||
private void readInnerClasses(ValidationState state) {
|
||||
for (InnerClassNode inner : state.classNode.innerClasses) {
|
||||
ClassInfo innerClass = ClassInfo.forName(inner.name);
|
||||
if (innerClass.isSynthetic() && innerClass.isProbablyStatic()) {
|
||||
if ((inner.outerName != null && inner.outerName.equals(state.classInfo.getName()))
|
||||
|| inner.name.startsWith(state.classNode.name + "$")) {
|
||||
state.syntheticInnerClasses.add(inner.name);
|
||||
} else {
|
||||
throw new InvalidMixinException(this, "Unhandled synthetic inner class found: " + inner.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Current state, either the validated state or the uninitialised state if
|
||||
* the mixin is initialising for the first time. Should never return null.
|
||||
*/
|
||||
private ValidationState getCurrentState() {
|
||||
if (this.validationState == null) {
|
||||
return this.uninitialisedState;
|
||||
}
|
||||
return this.validationState;
|
||||
private State getState() {
|
||||
return this.state != null ? this.state : this.pendingState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ClassInfo for the mixin class
|
||||
*/
|
||||
ClassInfo getClassInfo() {
|
||||
return this.info;
|
||||
}
|
||||
@@ -580,10 +739,18 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
/**
|
||||
* Get the parent config which declares this mixin
|
||||
*/
|
||||
public MixinConfig getParent() {
|
||||
MixinConfig getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mixin priority
|
||||
*/
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the simple name of the mixin
|
||||
*/
|
||||
@@ -613,7 +780,7 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
*/
|
||||
@Override
|
||||
public byte[] getClassBytes() {
|
||||
return this.getCurrentState().mixinBytes;
|
||||
return this.getState().getClassBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -622,7 +789,7 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
*/
|
||||
@Override
|
||||
public boolean isDetachedSuper() {
|
||||
return this.getCurrentState().detachedSuper;
|
||||
return this.getState().isDetachedSuper();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -639,21 +806,13 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
public Phase getPhase() {
|
||||
return this.phase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether this is an interface mixin or not
|
||||
*/
|
||||
@Override
|
||||
public boolean isInterfaceMixin() {
|
||||
return this.isInterfaceMixin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a new tree for the class bytecode
|
||||
*/
|
||||
@Override
|
||||
public ClassNode getClassNode(int flags) {
|
||||
return this.getCurrentState().getClassNode(flags);
|
||||
return this.getState().createClassNode(flags);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -668,36 +827,21 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
* Get the soft implementations for this mixin
|
||||
*/
|
||||
List<InterfaceInfo> getSoftImplements() {
|
||||
return Collections.unmodifiableList(this.getCurrentState().softImplements);
|
||||
return Collections.unmodifiableList(this.getState().getSoftImplements());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the synthetic inner classes for this mixin
|
||||
*/
|
||||
public Set<String> getSyntheticInnerClasses() {
|
||||
return Collections.unmodifiableSet(this.getCurrentState().syntheticInnerClasses);
|
||||
Set<String> getSyntheticInnerClasses() {
|
||||
return Collections.unmodifiableSet(this.getState().getSyntheticInnerClasses());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the target class list for this mixin
|
||||
*/
|
||||
public List<ClassInfo> getTargets() {
|
||||
return Collections.unmodifiableList(this.getTargets0());
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to avoid synthetic bridge generation
|
||||
*/
|
||||
protected List<ClassInfo> getTargets0() {
|
||||
return this.targetClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mixin priority
|
||||
*/
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return this.priority;
|
||||
List<ClassInfo> getTargets() {
|
||||
return Collections.unmodifiableList(this.targetClasses);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -705,8 +849,8 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
*
|
||||
* @return mixin interfaces
|
||||
*/
|
||||
public Set<String> getInterfaces() {
|
||||
return this.getCurrentState().interfaces;
|
||||
Set<String> getInterfaces() {
|
||||
return this.getState().getInterfaces();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -715,21 +859,9 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
* @param target
|
||||
* @return new context
|
||||
*/
|
||||
public MixinTargetContext createContextFor(TargetClassContext target) {
|
||||
MixinTargetContext createContextFor(TargetClassContext target) {
|
||||
ClassNode classNode = this.getClassNode(ClassReader.EXPAND_FRAMES);
|
||||
return this.createPreProcessor(classNode).prepare().createContextFor(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a preprocessor based on this mixin's type
|
||||
*
|
||||
* @return new preprocessor
|
||||
*/
|
||||
private MixinPreProcessor createPreProcessor(ClassNode classNode) {
|
||||
if (this.isInterfaceMixin) {
|
||||
return new InterfaceMixinPreProcessor(this, classNode);
|
||||
}
|
||||
return new MixinPreProcessor(this, classNode);
|
||||
return this.type.createPreProcessor(classNode).prepare().createContextFor(target);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -766,10 +898,10 @@ class MixinInfo extends TreeInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
* @param mixinBytes New bytecode
|
||||
*/
|
||||
void reloadMixin(byte[] mixinBytes) {
|
||||
if (this.uninitialisedState != null) {
|
||||
if (this.pendingState != null) {
|
||||
throw new IllegalStateException("Cannot reload mixin while it is initialising");
|
||||
}
|
||||
this.uninitialisedState = new ReloadedState(this.validationState, mixinBytes);
|
||||
this.pendingState = new Reloaded(this.state, mixinBytes);
|
||||
this.validate();
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -30,12 +30,13 @@ import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.lib.tree.FieldNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.Method;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidInterfaceMixinException;
|
||||
|
||||
/**
|
||||
* Bytecode preprocessor for interface mixins, simply performs some additional
|
||||
* verification for things which are unsupported in interfaces
|
||||
*/
|
||||
class InterfaceMixinPreProcessor extends MixinPreProcessor {
|
||||
class MixinPreProcessorInterface extends MixinPreProcessorStandard {
|
||||
|
||||
/**
|
||||
* Ctor
|
||||
@@ -43,7 +44,7 @@ class InterfaceMixinPreProcessor extends MixinPreProcessor {
|
||||
* @param mixin Mixin info
|
||||
* @param classNode Mixin classnode
|
||||
*/
|
||||
InterfaceMixinPreProcessor(MixinInfo mixin, ClassNode classNode) {
|
||||
MixinPreProcessorInterface(MixinInfo mixin, ClassNode classNode) {
|
||||
super(mixin, classNode);
|
||||
}
|
||||
|
||||
@@ -55,7 +56,7 @@ class InterfaceMixinPreProcessor extends MixinPreProcessor {
|
||||
@Override
|
||||
protected void prepareMethod(MethodNode mixinMethod, Method method) {
|
||||
// I have no idea how the hell you'd compile this, but we make sure anyway!
|
||||
if (!MixinApplicator.hasFlag(mixinMethod, Opcodes.ACC_PUBLIC)) {
|
||||
if (!MixinApplicatorStandard.hasFlag(mixinMethod, Opcodes.ACC_PUBLIC)) {
|
||||
throw new InvalidInterfaceMixinException(this.mixin, "Interface mixin contains a non-public method! Found " + method + " in "
|
||||
+ this.mixin);
|
||||
}
|
||||
@@ -72,7 +73,7 @@ class InterfaceMixinPreProcessor extends MixinPreProcessor {
|
||||
*/
|
||||
@Override
|
||||
protected boolean validateField(MixinTargetContext context, FieldNode field, AnnotationNode shadow) {
|
||||
if (!MixinApplicator.hasFlag(field, Opcodes.ACC_STATIC)) {
|
||||
if (!MixinApplicatorStandard.hasFlag(field, Opcodes.ACC_STATIC)) {
|
||||
throw new InvalidInterfaceMixinException(this.mixin, "Interface mixin contains an instance field! Found " + field.name + " in "
|
||||
+ this.mixin);
|
||||
}
|
||||
+20
-19
@@ -45,13 +45,14 @@ import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.RemapperChain;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.Surrogate;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.Field;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.Method;
|
||||
import org.spongepowered.asm.mixin.transformer.meta.MixinRenamed;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
import org.spongepowered.asm.obfuscation.RemapperChain;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
|
||||
@@ -74,7 +75,7 @@ import org.spongepowered.asm.util.Constants;
|
||||
* target-context-sensitive pass on the other hand can only operate on private
|
||||
* class members for obvious reasons.</p>
|
||||
*/
|
||||
class MixinPreProcessor {
|
||||
class MixinPreProcessorStandard {
|
||||
|
||||
/**
|
||||
* Logger
|
||||
@@ -95,7 +96,7 @@ class MixinPreProcessor {
|
||||
|
||||
private boolean prepared, attached;
|
||||
|
||||
MixinPreProcessor(MixinInfo mixin, ClassNode classNode) {
|
||||
MixinPreProcessorStandard(MixinInfo mixin, ClassNode classNode) {
|
||||
this.mixin = mixin;
|
||||
this.classNode = classNode;
|
||||
this.verboseLogging = mixin.getParent().getEnvironment().getOption(Option.DEBUG_VERBOSE);
|
||||
@@ -106,7 +107,7 @@ class MixinPreProcessor {
|
||||
*
|
||||
* @return Prepared classnode
|
||||
*/
|
||||
MixinPreProcessor prepare() {
|
||||
MixinPreProcessorStandard prepare() {
|
||||
if (!this.prepared) {
|
||||
this.prepared = true;
|
||||
|
||||
@@ -234,13 +235,13 @@ class MixinPreProcessor {
|
||||
}
|
||||
|
||||
Method method = this.mixin.getClassInfo().findMethod(mixinMethod, ClassInfo.INCLUDE_ALL);
|
||||
MethodNode target = MixinPreProcessor.findMethod(context.getTargetClass(), mixinMethod, annotation);
|
||||
MethodNode target = MixinPreProcessorStandard.findMethod(context.getTargetClass(), mixinMethod, annotation);
|
||||
|
||||
if (target == null) {
|
||||
if (!mustExist) {
|
||||
return false;
|
||||
}
|
||||
target = MixinPreProcessor.findRemappedMethod(context.getTargetClass(), mixinMethod);
|
||||
target = MixinPreProcessorStandard.findRemappedMethod(context.getTargetClass(), mixinMethod);
|
||||
if (target == null) {
|
||||
throw new InvalidMixinException(this.mixin, annotationType.getSimpleName() + " method " + mixinMethod.name
|
||||
+ " was not located in the target class");
|
||||
@@ -292,12 +293,12 @@ class MixinPreProcessor {
|
||||
context.transformDescriptor(mixinField);
|
||||
|
||||
Field field = this.mixin.getClassInfo().findField(mixinField);
|
||||
FieldNode target = MixinPreProcessor.findField(context.getTargetClass(), mixinField, shadow);
|
||||
FieldNode target = MixinPreProcessorStandard.findField(context.getTargetClass(), mixinField, shadow);
|
||||
if (target == null) {
|
||||
if (shadow == null) {
|
||||
continue;
|
||||
}
|
||||
target = MixinPreProcessor.findRemappedField(context.getTargetClass(), mixinField);
|
||||
target = MixinPreProcessorStandard.findRemappedField(context.getTargetClass(), mixinField);
|
||||
if (target == null) {
|
||||
// If this field is a shadow field but is NOT found in the target class, that's bad, mmkay
|
||||
throw new InvalidMixinException(this.mixin, "Shadow field " + mixinField.name + " was not located in the target class");
|
||||
@@ -329,11 +330,11 @@ class MixinPreProcessor {
|
||||
}
|
||||
field.setDecoratedFinal(isFinal, isMutable);
|
||||
|
||||
if (this.verboseLogging && MixinApplicator.hasFlag(target, Opcodes.ACC_FINAL) != isFinal) {
|
||||
if (this.verboseLogging && MixinApplicatorStandard.hasFlag(target, Opcodes.ACC_FINAL) != isFinal) {
|
||||
String message = isFinal
|
||||
? "@Shadow field {}::{} is decorated with @Final but target is not final"
|
||||
: "@Shadow target {}::{} is final but shadow is not decorated with @Final";
|
||||
MixinPreProcessor.logger.warn(message, this.mixin, mixinField.name);
|
||||
MixinPreProcessorStandard.logger.warn(message, this.mixin, mixinField.name);
|
||||
}
|
||||
|
||||
context.addShadowField(mixinField, field);
|
||||
@@ -343,9 +344,9 @@ class MixinPreProcessor {
|
||||
|
||||
protected boolean validateField(MixinTargetContext context, FieldNode field, AnnotationNode shadow) {
|
||||
// Public static fields will fall foul of early static binding in java, including them in a mixin is an error condition
|
||||
if (MixinApplicator.hasFlag(field, Opcodes.ACC_STATIC)
|
||||
&& !MixinApplicator.hasFlag(field, Opcodes.ACC_PRIVATE)
|
||||
&& !MixinApplicator.hasFlag(field, Opcodes.ACC_SYNTHETIC)
|
||||
if (MixinApplicatorStandard.hasFlag(field, Opcodes.ACC_STATIC)
|
||||
&& !MixinApplicatorStandard.hasFlag(field, Opcodes.ACC_PRIVATE)
|
||||
&& !MixinApplicatorStandard.hasFlag(field, Opcodes.ACC_SYNTHETIC)
|
||||
&& shadow == null) {
|
||||
throw new InvalidMixinException(context, String.format("Mixin %s contains non-private static field %s:%s",
|
||||
context, field.name, field.desc));
|
||||
@@ -409,7 +410,7 @@ class MixinPreProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
return MixinPreProcessor.findMethodRecursive(classNode, aliases, method.desc);
|
||||
return MixinPreProcessorStandard.findMethodRecursive(classNode, aliases, method.desc);
|
||||
}
|
||||
|
||||
protected static MethodNode findRemappedMethod(ClassNode classNode, MethodNode method) {
|
||||
@@ -422,7 +423,7 @@ class MixinPreProcessor {
|
||||
Deque<String> aliases = new LinkedList<String>();
|
||||
aliases.add(remappedName);
|
||||
|
||||
return MixinPreProcessor.findMethodRecursive(classNode, aliases, method.desc);
|
||||
return MixinPreProcessorStandard.findMethodRecursive(classNode, aliases, method.desc);
|
||||
}
|
||||
|
||||
private static MethodNode findMethodRecursive(ClassNode classNode, Deque<String> aliases, String desc) {
|
||||
@@ -437,7 +438,7 @@ class MixinPreProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
return MixinPreProcessor.findMethodRecursive(classNode, aliases, desc);
|
||||
return MixinPreProcessorStandard.findMethodRecursive(classNode, aliases, desc);
|
||||
}
|
||||
|
||||
protected static FieldNode findField(ClassNode classNode, FieldNode field, AnnotationNode shadow) {
|
||||
@@ -450,7 +451,7 @@ class MixinPreProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
return MixinPreProcessor.findFieldRecursive(classNode, aliases, field.desc);
|
||||
return MixinPreProcessorStandard.findFieldRecursive(classNode, aliases, field.desc);
|
||||
}
|
||||
|
||||
protected static FieldNode findRemappedField(ClassNode classNode, FieldNode field) {
|
||||
@@ -462,7 +463,7 @@ class MixinPreProcessor {
|
||||
|
||||
Deque<String> aliases = new LinkedList<String>();
|
||||
aliases.add(remappedName);
|
||||
return MixinPreProcessor.findFieldRecursive(classNode, aliases, field.desc);
|
||||
return MixinPreProcessorStandard.findFieldRecursive(classNode, aliases, field.desc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -484,6 +485,6 @@ class MixinPreProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
return MixinPreProcessor.findFieldRecursive(classNode, aliases, desc);
|
||||
return MixinPreProcessorStandard.findFieldRecursive(classNode, aliases, desc);
|
||||
}
|
||||
}
|
||||
@@ -44,16 +44,20 @@ import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.CompatibilityLevel;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.SoftOverride;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionError;
|
||||
import org.spongepowered.asm.mixin.injection.InjectionValidationException;
|
||||
import org.spongepowered.asm.mixin.injection.InjectorGroupInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.injection.struct.ReferenceMapper;
|
||||
import org.spongepowered.asm.mixin.injection.struct.Target;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InjectionError;
|
||||
import org.spongepowered.asm.mixin.injection.throwables.InjectionValidationException;
|
||||
import org.spongepowered.asm.mixin.refmap.IReferenceMapperContext;
|
||||
import org.spongepowered.asm.mixin.refmap.ReferenceMapper;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.Field;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.Traversal;
|
||||
import org.spongepowered.asm.mixin.transformer.meta.MixinMerged;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError;
|
||||
import org.spongepowered.asm.util.ASMHelper;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
|
||||
@@ -767,6 +771,15 @@ public class MixinTargetContext implements IReferenceMapperContext {
|
||||
throw new InvalidMixinException(this, "Unsupported mixin class version " + version);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.spongepowered.asm.mixin.refmap.IReferenceMapperContext
|
||||
* #getMixin()
|
||||
*/
|
||||
@Override
|
||||
public IMixinInfo getMixin() {
|
||||
return this.mixin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mixin info for this mixin
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
@@ -46,20 +47,25 @@ import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.lib.tree.FieldNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.mixin.MixinApplyError;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Option;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Phase;
|
||||
import org.spongepowered.asm.mixin.MixinException;
|
||||
import org.spongepowered.asm.mixin.MixinPrepareError;
|
||||
import org.spongepowered.asm.mixin.audit.ClassAlreadyLoadedException;
|
||||
import org.spongepowered.asm.mixin.Mixins;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfig;
|
||||
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.throwables.ClassAlreadyLoadedException;
|
||||
import org.spongepowered.asm.mixin.throwables.MixinApplyError;
|
||||
import org.spongepowered.asm.mixin.throwables.MixinException;
|
||||
import org.spongepowered.asm.mixin.throwables.MixinPrepareError;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
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.mixin.transformer.throwables.InvalidMixinException;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError;
|
||||
import org.spongepowered.asm.transformers.TreeTransformer;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
import org.spongepowered.asm.util.PrettyPrinter;
|
||||
@@ -82,9 +88,9 @@ public class MixinTransformer extends TreeTransformer {
|
||||
*/
|
||||
PREPARE {
|
||||
@Override
|
||||
ErrorAction onError(IMixinErrorHandler handler, String context, InvalidMixinException ex, MixinInfo mixin, ErrorAction action) {
|
||||
ErrorAction onError(IMixinErrorHandler handler, String context, InvalidMixinException ex, IMixinInfo mixin, ErrorAction action) {
|
||||
try {
|
||||
return handler.onPrepareError(mixin.getParent(), ex, mixin, action);
|
||||
return handler.onPrepareError(mixin.getConfig(), ex, mixin, action);
|
||||
} catch (AbstractMethodError ame) {
|
||||
// Catch if error handler is pre-0.5.4
|
||||
return action;
|
||||
@@ -92,7 +98,7 @@ public class MixinTransformer extends TreeTransformer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getContext(MixinInfo mixin, String context) {
|
||||
protected String getContext(IMixinInfo mixin, String context) {
|
||||
return String.format("preparing %s in %s", mixin.getName(), context);
|
||||
}
|
||||
},
|
||||
@@ -101,7 +107,7 @@ public class MixinTransformer extends TreeTransformer {
|
||||
*/
|
||||
APPLY {
|
||||
@Override
|
||||
ErrorAction onError(IMixinErrorHandler handler, String context, InvalidMixinException ex, MixinInfo mixin, ErrorAction action) {
|
||||
ErrorAction onError(IMixinErrorHandler handler, String context, InvalidMixinException ex, IMixinInfo mixin, ErrorAction action) {
|
||||
try {
|
||||
return handler.onApplyError(context, ex, mixin, action);
|
||||
} catch (AbstractMethodError ame) {
|
||||
@@ -111,7 +117,7 @@ public class MixinTransformer extends TreeTransformer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getContext(MixinInfo mixin, String context) {
|
||||
protected String getContext(IMixinInfo mixin, String context) {
|
||||
return String.format("%s -> %s", mixin, context);
|
||||
}
|
||||
};
|
||||
@@ -125,15 +131,15 @@ public class MixinTransformer extends TreeTransformer {
|
||||
this.text = this.name().toLowerCase();
|
||||
}
|
||||
|
||||
abstract ErrorAction onError(IMixinErrorHandler handler, String context, InvalidMixinException ex, MixinInfo mixin, ErrorAction action);
|
||||
abstract ErrorAction onError(IMixinErrorHandler handler, String context, InvalidMixinException ex, IMixinInfo mixin, ErrorAction action);
|
||||
|
||||
protected abstract String getContext(MixinInfo mixin, String context);
|
||||
protected abstract String getContext(IMixinInfo mixin, String context);
|
||||
|
||||
public String getLogMessage(String context, InvalidMixinException ex, MixinInfo mixin) {
|
||||
public String getLogMessage(String context, InvalidMixinException ex, IMixinInfo mixin) {
|
||||
return String.format("Mixin %s failed %s: %s %s", this.text, this.getContext(mixin, context), ex.getClass().getName(), ex.getMessage());
|
||||
}
|
||||
|
||||
public String getErrorMessage(MixinInfo mixin, MixinConfig config, Phase phase) {
|
||||
public String getErrorMessage(IMixinInfo mixin, IMixinConfig config, Phase phase) {
|
||||
return String.format("Mixin [%s] from phase [%s] in config [%s] FAILED during %s", mixin, phase, config, this.name());
|
||||
}
|
||||
|
||||
@@ -469,7 +475,7 @@ public class MixinTransformer extends TreeTransformer {
|
||||
|
||||
if (this.currentEnvironment != environment && !locked) {
|
||||
try {
|
||||
this.init(environment);
|
||||
this.select(environment);
|
||||
} catch (Exception ex) {
|
||||
this.lock.pop();
|
||||
throw new MixinException(ex);
|
||||
@@ -553,14 +559,14 @@ public class MixinTransformer extends TreeTransformer {
|
||||
return targets;
|
||||
}
|
||||
|
||||
private void init(MixinEnvironment environment) {
|
||||
private void select(MixinEnvironment environment) {
|
||||
this.verboseLoggingLevel = (environment.getOption(Option.DEBUG_VERBOSE)) ? Level.INFO : Level.DEBUG;
|
||||
this.logger.log(this.verboseLoggingLevel, "Preparing mixins for {}", environment);
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
this.addConfigs(environment);
|
||||
this.addModules(environment);
|
||||
int totalMixins = this.initConfigs(environment);
|
||||
this.selectConfigs(environment);
|
||||
this.selectModules(environment);
|
||||
int totalMixins = this.prepareConfigs(environment);
|
||||
this.currentEnvironment = environment;
|
||||
|
||||
double elapsedTime = (System.currentTimeMillis() - startTime) * 0.001D;
|
||||
@@ -576,20 +582,19 @@ public class MixinTransformer extends TreeTransformer {
|
||||
*
|
||||
* @param environment Environment to query
|
||||
*/
|
||||
private void addConfigs(MixinEnvironment environment) {
|
||||
List<String> configs = environment.getMixinConfigs();
|
||||
|
||||
if (configs != null) {
|
||||
for (String configFile : configs) {
|
||||
try {
|
||||
MixinConfig config = MixinConfig.create(configFile, environment);
|
||||
if (config != null) {
|
||||
this.logger.log(this.verboseLoggingLevel, "Adding config {}", config);
|
||||
this.pendingConfigs.add(config);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
this.logger.warn(String.format("Failed to load mixin config: %s", configFile), ex);
|
||||
private void selectConfigs(MixinEnvironment environment) {
|
||||
for (Iterator<Config> iter = Mixins.getConfigs().iterator(); iter.hasNext();) {
|
||||
Config handle = iter.next();
|
||||
try {
|
||||
MixinConfig config = handle.get();
|
||||
if (config.select(environment)) {
|
||||
iter.remove();
|
||||
this.logger.log(this.verboseLoggingLevel, "Selecting config {}", config);
|
||||
config.onSelect();
|
||||
this.pendingConfigs.add(config);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
this.logger.warn(String.format("Failed to select mixin config: %s", handle), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,7 +606,7 @@ public class MixinTransformer extends TreeTransformer {
|
||||
*
|
||||
* @param environment Environment to query
|
||||
*/
|
||||
private void addModules(MixinEnvironment environment) {
|
||||
private void selectModules(MixinEnvironment environment) {
|
||||
this.modules.clear();
|
||||
|
||||
// Run CheckClassAdapter on the mixin bytecode if debug option is enabled
|
||||
@@ -616,18 +621,18 @@ public class MixinTransformer extends TreeTransformer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise mixin configs
|
||||
* Prepare mixin configs
|
||||
*
|
||||
* @param environment Environment
|
||||
* @return total number of mixins initialised
|
||||
*/
|
||||
private int initConfigs(MixinEnvironment environment) {
|
||||
private int prepareConfigs(MixinEnvironment environment) {
|
||||
int totalMixins = 0;
|
||||
|
||||
for (MixinConfig config : this.pendingConfigs) {
|
||||
try {
|
||||
this.logger.log(this.verboseLoggingLevel, "Preparing {} ({})", config, config.getDeclaredMixinCount());
|
||||
config.initialise(this.hotSwapper);
|
||||
config.prepare(this.hotSwapper);
|
||||
totalMixins += config.getMixinCount();
|
||||
} catch (InvalidMixinException ex) {
|
||||
this.handleMixinPrepareError(config, ex, environment);
|
||||
@@ -766,14 +771,14 @@ public class MixinTransformer extends TreeTransformer {
|
||||
private void handleMixinError(String context, InvalidMixinException ex, MixinEnvironment environment, ErrorPhase errorPhase) throws Error {
|
||||
this.errorState = true;
|
||||
|
||||
MixinInfo mixin = ex.getMixin();
|
||||
IMixinInfo mixin = ex.getMixin();
|
||||
|
||||
if (mixin == null) {
|
||||
this.logger.error("InvalidMixinException has no mixin!", ex);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
MixinConfig config = mixin.getParent();
|
||||
IMixinConfig config = mixin.getConfig();
|
||||
Phase phase = mixin.getPhase();
|
||||
ErrorAction action = config.isRequired() ? ErrorAction.ERROR : ErrorAction.WARN;
|
||||
|
||||
@@ -814,7 +819,7 @@ public class MixinTransformer extends TreeTransformer {
|
||||
private List<IMixinErrorHandler> getErrorHandlers(Phase phase) {
|
||||
List<IMixinErrorHandler> handlers = new ArrayList<IMixinErrorHandler>();
|
||||
|
||||
for (String handlerClassName : MixinEnvironment.getEnvironment(phase).getErrorHandlerClasses()) {
|
||||
for (String handlerClassName : Mixins.getErrorHandlerClasses()) {
|
||||
try {
|
||||
this.logger.info("Instancing error handler class {}", handlerClassName);
|
||||
Class<?> handlerClass = Class.forName(handlerClassName, true, Launch.classLoader);
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ package org.spongepowered.asm.mixin.transformer;
|
||||
|
||||
import org.spongepowered.asm.lib.ClassWriter;
|
||||
import org.spongepowered.asm.lib.util.CheckClassAdapter;
|
||||
import org.spongepowered.asm.mixin.MixinException;
|
||||
import org.spongepowered.asm.mixin.throwables.MixinException;
|
||||
|
||||
/**
|
||||
* Mixin transformer module which runs CheckClassAdapter on the post-mixin
|
||||
|
||||
@@ -213,15 +213,15 @@ class TargetClassContext {
|
||||
throw new IllegalStateException("Mixins already applied to target class " + this.className);
|
||||
}
|
||||
this.applied = true;
|
||||
MixinApplicator applicator = this.createApplicator();
|
||||
MixinApplicatorStandard applicator = this.createApplicator();
|
||||
applicator.apply(this.mixins);
|
||||
}
|
||||
|
||||
private MixinApplicator createApplicator() {
|
||||
private MixinApplicatorStandard createApplicator() {
|
||||
if (this.classInfo.isInterface()) {
|
||||
return new InterfaceMixinApplicator(this);
|
||||
return new MixinApplicatorInterface(this);
|
||||
}
|
||||
return new MixinApplicator(this);
|
||||
return new MixinApplicatorStandard(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,14 +29,14 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.spongepowered.asm.mixin.transformer.MixinApplicator;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard;
|
||||
|
||||
/**
|
||||
* <p><b>For internal use only!</b> Contains small parts. Keep out of reach of
|
||||
* children.</p>
|
||||
*
|
||||
* <p>Decoration annotation used by the {@link MixinApplicator} to mark methods
|
||||
* in a class which have been added or overwritten by a mixin.</p>
|
||||
* <p>Decoration annotation used by the {@link MixinApplicatorStandard} to mark
|
||||
* methods in a class which have been added or overwritten by a mixin.</p>
|
||||
*/
|
||||
@Target({ ElementType.METHOD })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
+15
-12
@@ -22,37 +22,40 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.transformer;
|
||||
package org.spongepowered.asm.mixin.transformer.throwables;
|
||||
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
import org.spongepowered.asm.mixin.refmap.IReferenceMapperContext;
|
||||
|
||||
/**
|
||||
* Exception thrown for bad states when parsing/loading interface mixins
|
||||
*/
|
||||
public class InvalidInterfaceMixinException extends InvalidMixinException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
public InvalidInterfaceMixinException(MixinInfo mixin, String message) {
|
||||
public InvalidInterfaceMixinException(IMixinInfo mixin, String message) {
|
||||
super(mixin, message);
|
||||
}
|
||||
|
||||
public InvalidInterfaceMixinException(MixinTargetContext mixin, String message) {
|
||||
super(mixin, message);
|
||||
public InvalidInterfaceMixinException(IReferenceMapperContext context, String message) {
|
||||
super(context, message);
|
||||
}
|
||||
|
||||
public InvalidInterfaceMixinException(MixinInfo mixin, Throwable message) {
|
||||
super(mixin, message);
|
||||
public InvalidInterfaceMixinException(IMixinInfo mixin, Throwable cause) {
|
||||
super(mixin, cause);
|
||||
}
|
||||
|
||||
public InvalidInterfaceMixinException(MixinTargetContext mixin, Throwable message) {
|
||||
super(mixin, message);
|
||||
public InvalidInterfaceMixinException(IReferenceMapperContext context, Throwable cause) {
|
||||
super(context, cause);
|
||||
}
|
||||
|
||||
public InvalidInterfaceMixinException(MixinInfo mixin, String message, Throwable cause) {
|
||||
public InvalidInterfaceMixinException(IMixinInfo mixin, String message, Throwable cause) {
|
||||
super(mixin, message, cause);
|
||||
}
|
||||
|
||||
public InvalidInterfaceMixinException(MixinTargetContext mixin, String message, Throwable cause) {
|
||||
super(mixin, message, cause);
|
||||
public InvalidInterfaceMixinException(IReferenceMapperContext context, String message, Throwable cause) {
|
||||
super(context, message, cause);
|
||||
}
|
||||
|
||||
}
|
||||
+17
-17
@@ -22,50 +22,50 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.transformer;
|
||||
package org.spongepowered.asm.mixin.transformer.throwables;
|
||||
|
||||
import org.spongepowered.asm.mixin.MixinException;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
import org.spongepowered.asm.mixin.refmap.IReferenceMapperContext;
|
||||
import org.spongepowered.asm.mixin.throwables.MixinException;
|
||||
|
||||
/**
|
||||
* Thrown by the mixin validator when a mixin fails a pre-flight check
|
||||
*/
|
||||
public class InvalidMixinException extends MixinException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
private final MixinInfo mixin;
|
||||
private final IMixinInfo mixin;
|
||||
|
||||
public InvalidMixinException(MixinInfo mixin, String message) {
|
||||
public InvalidMixinException(IMixinInfo mixin, String message) {
|
||||
super(message);
|
||||
this.mixin = mixin;
|
||||
}
|
||||
|
||||
public InvalidMixinException(MixinTargetContext mixin, String message) {
|
||||
super(message);
|
||||
this.mixin = mixin.getInfo();
|
||||
public InvalidMixinException(IReferenceMapperContext context, String message) {
|
||||
this(context.getMixin(), message);
|
||||
}
|
||||
|
||||
public InvalidMixinException(MixinInfo mixin, Throwable message) {
|
||||
super(message);
|
||||
public InvalidMixinException(IMixinInfo mixin, Throwable cause) {
|
||||
super(cause);
|
||||
this.mixin = mixin;
|
||||
}
|
||||
|
||||
public InvalidMixinException(MixinTargetContext mixin, Throwable message) {
|
||||
super(message);
|
||||
this.mixin = mixin.getInfo();
|
||||
public InvalidMixinException(IReferenceMapperContext context, Throwable cause) {
|
||||
this(context.getMixin(), cause);
|
||||
}
|
||||
|
||||
public InvalidMixinException(MixinInfo mixin, String message, Throwable cause) {
|
||||
public InvalidMixinException(IMixinInfo mixin, String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.mixin = mixin;
|
||||
}
|
||||
|
||||
public InvalidMixinException(MixinTargetContext mixin, String message, Throwable cause) {
|
||||
public InvalidMixinException(IReferenceMapperContext context, String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.mixin = mixin.getInfo();
|
||||
this.mixin = context.getMixin();
|
||||
}
|
||||
|
||||
public MixinInfo getMixin() {
|
||||
public IMixinInfo getMixin() {
|
||||
return this.mixin;
|
||||
}
|
||||
}
|
||||
+9
-6
@@ -22,25 +22,28 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.transformer;
|
||||
package org.spongepowered.asm.mixin.transformer.throwables;
|
||||
|
||||
import org.spongepowered.asm.mixin.MixinException;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
import org.spongepowered.asm.mixin.throwables.MixinException;
|
||||
|
||||
/**
|
||||
* An exception that occurs when a mixin reloads and does something it is
|
||||
* normally allowed to do but isn't due to reloading restrictions.
|
||||
*/
|
||||
public class MixinReloadException extends MixinException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
private final MixinInfo mixinInfo;
|
||||
private final IMixinInfo mixinInfo;
|
||||
|
||||
public MixinReloadException(MixinInfo mixinInfo, String message) {
|
||||
public MixinReloadException(IMixinInfo mixinInfo, String message) {
|
||||
super(message);
|
||||
this.mixinInfo = mixinInfo;
|
||||
}
|
||||
|
||||
public MixinInfo getMixinInfo() {
|
||||
public IMixinInfo getMixinInfo() {
|
||||
return this.mixinInfo;
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.transformer;
|
||||
package org.spongepowered.asm.mixin.transformer.throwables;
|
||||
|
||||
/**
|
||||
* Error to throw for things which really shouldn't happen
|
||||
+2
-1
@@ -22,12 +22,13 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin.transformer;
|
||||
package org.spongepowered.asm.mixin.transformer.verify;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.spongepowered.asm.lib.Type;
|
||||
import org.spongepowered.asm.lib.tree.analysis.SimpleVerifier;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo;
|
||||
|
||||
/**
|
||||
* Verifier which handles class info lookups via {@link ClassInfo}
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.mixin;
|
||||
package org.spongepowered.asm.obfuscation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -28,7 +28,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.spongepowered.asm.mixin.MixinException;
|
||||
import org.spongepowered.asm.mixin.throwables.MixinException;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
@@ -28,6 +28,8 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.spongepowered.asm.lib.tree.AnnotationNode;
|
||||
import org.spongepowered.asm.util.throwables.ConstraintViolationException;
|
||||
import org.spongepowered.asm.util.throwables.InvalidConstraintException;
|
||||
|
||||
/**
|
||||
* Parser for constraints
|
||||
|
||||
@@ -48,7 +48,8 @@ import org.spongepowered.asm.lib.tree.analysis.Frame;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.FrameData;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.Method;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinVerifier;
|
||||
import org.spongepowered.asm.mixin.transformer.verify.MixinVerifier;
|
||||
import org.spongepowered.asm.util.throwables.LVTGeneratorException;
|
||||
|
||||
/**
|
||||
* Utility methods for working with local variables using ASM
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.util;
|
||||
package org.spongepowered.asm.util.throwables;
|
||||
|
||||
import org.spongepowered.asm.util.ConstraintParser.Constraint;
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.util;
|
||||
package org.spongepowered.asm.util.throwables;
|
||||
|
||||
/**
|
||||
* Exception thrown when a constraint declaration is invalid
|
||||
+2
-2
@@ -22,9 +22,9 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.util;
|
||||
package org.spongepowered.asm.util.throwables;
|
||||
|
||||
import org.spongepowered.asm.mixin.MixinException;
|
||||
import org.spongepowered.asm.mixin.throwables.MixinException;
|
||||
|
||||
/**
|
||||
* Exception thrown when something goes horribly wrong whilst <s>summoning the
|
||||
Reference in new issue
Block a user