Merge remote-tracking branch 'remotes/upstream/0.8' into fabric-0.8

# Conflicts:
#	build.gradle
#	src/main/java/org/spongepowered/asm/mixin/transformer/MixinInfo.java
This commit is contained in:
modmuss50 committed 2019-10-11 20:58:42 +01:00
commit ed1a103051
50 files changed
+747 -868

No files matched your search

+2 -1
View File
@@ -13,7 +13,8 @@ The main documentation for **Mixin** can be found in the [Wiki](../../wiki).
Additional documentation for individual features and annotations can be found in
the extensive [Javadoc](http://jenkins.liteloader.com/job/Mixin/javadoc/). For
additional help use the channel `#spongedev` on the Espernet IRC network.
additional help use the channel `#mixin` on the
[Sponge Discord Server](https://discord.gg/sponge).
### Building Mixin
**Mixin** uses the [Gradle](http://gradle.org/) build automation system. To
+7 -7
View File
@@ -112,6 +112,9 @@ dependencies {
compile guava
compile log4j2
compile 'com.google.code.gson:gson:2.2.4'
if (Float.parseFloat(asmVersion) < 6) {
compile "org.ow2.asm:asm-debug-all:$asmVersion"
}
compile "org.ow2.asm:asm-tree:$asmVersion"
compile "org.ow2.asm:asm-commons:$asmVersion"
compile "org.ow2.asm:asm-util:$asmVersion"
@@ -143,7 +146,10 @@ dependencies {
modlauncherCompile configurations.compile
modlauncherCompile 'net.sf.jopt-simple:jopt-simple:5.0.4'
modlauncherCompile ('cpw.mods:modlauncher:3.2.0') {
modlauncherCompile "org.ow2.asm:asm-tree:$modlauncherAsmVersion"
modlauncherCompile "org.ow2.asm:asm-commons:$modlauncherAsmVersion"
modlauncherCompile "org.ow2.asm:asm-util:$modlauncherAsmVersion"
modlauncherCompile ('cpw.mods:modlauncher:4.0.0') {
exclude module: 'log4j-core'
}
@@ -258,12 +264,6 @@ shadowJar {
from sourceSets.ap.output
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
dependencies {
include(dependency('com.google.guava:guava'))
include(dependency('com.google.code.gson:gson'))
include(dependency('org.apache.logging.log4j:log4j-core'))
include(dependency('org.apache.logging.log4j:log4j-api'))
}
classifier = 'processor'
}
build.dependsOn(shadowJar)
+1
View File
@@ -8,3 +8,4 @@ buildVersion=0.8-preview
buildType=SNAPSHOT
asmVersion=7.1
legacyForgeAsmVersion=5.0.3
modlauncherAsmVersion=6.2
@@ -41,7 +41,7 @@ import org.spongepowered.asm.mixin.transformer.ext.IHotSwap;
import org.spongepowered.asm.mixin.transformer.throwables.MixinReloadException;
import org.spongepowered.asm.service.IMixinService;
import org.spongepowered.asm.service.MixinService;
import org.spongepowered.asm.util.Bytecode;
import org.spongepowered.asm.util.asm.ASM;
/**
* An agent that re-transforms a mixin's target classes if the mixin has been
@@ -64,7 +64,7 @@ public class MixinAgent implements IHotSwap {
byte[] mixinBytecode = MixinAgent.classLoader.getFakeMixinBytecode(classBeingRedefined);
if (mixinBytecode != null) {
ClassNode classNode = new ClassNode(Bytecode.ASM_API_VERSION);
ClassNode classNode = new ClassNode(ASM.API_VERSION);
ClassReader cr = new ClassReader(classfileBuffer);
cr.accept(classNode, ClassReader.EXPAND_FRAMES);
@@ -498,10 +498,6 @@ abstract class AnnotatedMixinElementHandler {
}
}
private void printMessage(Kind kind, String msg, Element e, AnnotationHandle annotation) {
this.printMessage(kind, msg, e, annotation, null);
}
private void printMessage(Kind kind, String msg, Element e, AnnotationHandle annotation, String suppressedBy) {
if (annotation == null) {
this.ap.printMessage(kind, msg, e, suppressedBy);
@@ -246,6 +246,12 @@ final class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider
return this.getProperties().getProperty(option);
}
@Override
public String getOption(String option, String defaultValue) {
String value = this.getOption(option);
return value != null ? value : defaultValue;
}
@Override
public boolean getOption(String option, boolean defaultValue) {
String value = this.getOption(option);
@@ -32,7 +32,6 @@ import java.util.Map;
import org.spongepowered.tools.obfuscation.interfaces.IMixinAnnotationProcessor;
import org.spongepowered.tools.obfuscation.interfaces.IOptionProvider;
import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP;
import org.spongepowered.tools.obfuscation.service.ObfuscationTypeDescriptor;
import com.google.common.collect.ImmutableList;
@@ -43,6 +42,8 @@ import com.google.common.collect.ImmutableList.Builder;
*/
public final class ObfuscationType {
public static final String DEFAULT_TYPE = "searge";
/**
* Available obfuscation types indexed by key
*/
@@ -111,9 +112,8 @@ public final class ObfuscationType {
* Get whether this is ithe default obfuscation environment
*/
public boolean isDefault() {
String defaultEnv = this.options.getOption(SupportedOptions.DEFAULT_OBFUSCATION_ENV);
return (defaultEnv == null && this.key.equals(ObfuscationServiceMCP.SEARGE))
|| (defaultEnv != null && this.key.equals(defaultEnv.toLowerCase(Locale.ROOT)));
String defaultEnv = this.options.getOption(SupportedOptions.DEFAULT_OBFUSCATION_ENV, ObfuscationType.DEFAULT_TYPE).toLowerCase(Locale.ROOT);
return (this.key.equals(defaultEnv));
}
/**
@@ -45,7 +45,6 @@ public class ObfuscationServiceFG3 implements IObfuscationService {
public static final String REOBF_TSRG_FILE = "reobfTsrgFile";
public static final String OUT_TSRG_SRG_FILE = "outTsrgFile";
public static final String OUT_REFMAP_FILE = "outRefMapFile";
public static final String TSRG_OUTPUT_BEHAVIOUR = "mergeBehaviour";
@Override
@@ -53,7 +52,6 @@ public class ObfuscationServiceFG3 implements IObfuscationService {
return ImmutableSet.<String>of(
ObfuscationServiceFG3.REOBF_TSRG_FILE,
ObfuscationServiceFG3.OUT_TSRG_SRG_FILE,
ObfuscationServiceFG3.OUT_REFMAP_FILE,
ObfuscationServiceFG3.TSRG_OUTPUT_BEHAVIOUR
);
}
@@ -39,6 +39,16 @@ public interface IOptionProvider {
*/
public abstract String getOption(String option);
/**
* Fetch the value of the specified option, if available. If the option is
* not available, return the specified default value
*
* @param option Name of the option to fetch
* @param defaultValue Default value to return if the option is not present
* @return Option value or default if absent
*/
public abstract String getOption(String option, String defaultValue);
/**
* Fetch the value of the specified option, if available. If the option is
* not available, return the specified default value
@@ -50,7 +50,6 @@ public class ObfuscationServiceMCP implements IObfuscationService {
public static final String REOBF_EXTRA_NOTCH_FILES = "reobfNotchSrgFiles";
public static final String OUT_SRG_SRG_FILE = "outSrgFile";
public static final String OUT_NOTCH_SRG_FILE = "outNotchSrgFile";
public static final String OUT_REFMAP_FILE = "outRefMapFile";
@Override
public Set<String> getSupportedOptions() {
@@ -60,8 +59,7 @@ public class ObfuscationServiceMCP implements IObfuscationService {
ObfuscationServiceMCP.REOBF_NOTCH_FILE,
ObfuscationServiceMCP.REOBF_EXTRA_NOTCH_FILES,
ObfuscationServiceMCP.OUT_SRG_SRG_FILE,
ObfuscationServiceMCP.OUT_NOTCH_SRG_FILE,
ObfuscationServiceMCP.OUT_REFMAP_FILE
ObfuscationServiceMCP.OUT_NOTCH_SRG_FILE
);
}
@@ -26,6 +26,7 @@ package org.spongepowered.tools.obfuscation.service;
import java.util.Collection;
import java.util.HashSet;
import java.util.Locale;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.Set;
@@ -33,6 +34,7 @@ import java.util.Set;
import javax.tools.Diagnostic.Kind;
import org.spongepowered.tools.obfuscation.ObfuscationType;
import org.spongepowered.tools.obfuscation.SupportedOptions;
import org.spongepowered.tools.obfuscation.interfaces.IMixinAnnotationProcessor;
/**
@@ -78,6 +80,8 @@ public final class ObfuscationServices {
* @param ap annotation processor
*/
public void initProviders(IMixinAnnotationProcessor ap) {
boolean defaultIsPresent = false;
try {
for (IObfuscationService service : this.serviceLoader) {
if (!this.services.contains(service)) {
@@ -91,6 +95,7 @@ public final class ObfuscationServices {
try {
ObfuscationType type = ObfuscationType.create(obfType, ap);
ap.printMessage(Kind.NOTE, serviceName + " supports type: \"" + type + "\"");
defaultIsPresent |= type.isDefault();
} catch (Exception ex) {
ex.printStackTrace();
}
@@ -102,6 +107,17 @@ public final class ObfuscationServices {
ap.printMessage(Kind.ERROR, serviceError.getClass().getSimpleName() + ": " + serviceError.getMessage());
serviceError.printStackTrace();
}
if (!defaultIsPresent) {
String defaultEnv = ap.getOption(SupportedOptions.DEFAULT_OBFUSCATION_ENV);
if (defaultEnv == null) {
ap.printMessage(Kind.WARNING, "No default obfuscation environment was specified and \"" + ObfuscationType.DEFAULT_TYPE
+ "\" is not available. Please ensure defaultObfuscationEnv is specified in your build configuration");
} else {
ap.printMessage(Kind.WARNING, "Specified default obfuscation environment \"" + defaultEnv.toLowerCase(Locale.ROOT)
+ "\" was not defined. This probably means your build configuration is out of date or a required service is missing");
}
}
}
/**
@@ -66,7 +66,7 @@ public class RuntimeDecompiler extends IFernflowerLogger implements IDecompiler,
try {
MoreFiles.deleteRecursively(this.outputPath.toPath(), RecursiveDeleteOption.ALLOW_INSECURE);
} catch (IOException ex) {
this.logger.warn("Error cleaning output directory: {}", ex.getMessage());
this.logger.debug("Error cleaning output directory: {}", ex.getMessage());
}
}
}
@@ -140,7 +140,7 @@ public class MixinPlatformAgentFMLLegacy extends MixinPlatformAgentAbstract impl
@Override
public boolean accept(MixinPlatformManager manager, IContainerHandle handle) {
if (!(handle instanceof ContainerHandleURI)) {
if (!(handle instanceof ContainerHandleURI) || !super.accept(manager, handle)) {
return false;
}
@@ -148,7 +148,7 @@ public class MixinPlatformAgentFMLLegacy extends MixinPlatformAgentAbstract impl
this.fileName = this.file.getName();
this.coreModWrapper = this.initFMLCoreMod();
return super.accept(manager, handle);
return true;
}
/**
@@ -47,6 +47,7 @@ import org.spongepowered.asm.launch.platform.container.ContainerHandleVirtual;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.tree.ClassNode;
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.throwables.MixinException;
import org.spongepowered.asm.service.IClassBytecodeProvider;
@@ -160,6 +161,15 @@ public class MixinServiceLaunchWrapper extends MixinServiceAbstract implements I
return Phase.PREINIT;
}
/* (non-Javadoc)
* @see org.spongepowered.asm.service.IMixinService
* #getMaxCompatibilityLevel()
*/
@Override
public CompatibilityLevel getMaxCompatibilityLevel() {
return CompatibilityLevel.JAVA_8;
}
/* (non-Javadoc)
* @see org.spongepowered.asm.service.IMixinService#init()
*/
@@ -453,9 +463,14 @@ public class MixinServiceLaunchWrapper extends MixinServiceAbstract implements I
if (classBytes != null) {
return classBytes;
}
URLClassLoader appClassLoader = (URLClassLoader)Launch.class.getClassLoader();
URLClassLoader appClassLoader;
if (Launch.class.getClassLoader() instanceof URLClassLoader) {
appClassLoader = (URLClassLoader) Launch.class.getClassLoader();
} else {
appClassLoader = new URLClassLoader(new URL[]{}, Launch.class.getClassLoader());
}
InputStream classStream = null;
try {
final String resourcePath = transformedName.replace('.', '/').concat(".class");
@@ -82,11 +82,6 @@ public abstract class MixinBootstrap {
* Platform manager instance
*/
private static MixinPlatformManager platform;
/**
* Connectors
*/
private static MixinConnectorManager connectors = new MixinConnectorManager();
private MixinBootstrap() {}
@@ -193,7 +188,6 @@ public abstract class MixinBootstrap {
static void inject() {
MixinBootstrap.getPlatform().inject();
MixinBootstrap.connectors.inject();
}
private static boolean isSubsystemRegistered() {
@@ -22,17 +22,18 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.asm.launch;
package org.spongepowered.asm.launch.platform;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.connect.IMixinConnector;
import org.spongepowered.asm.service.IClassProvider;
import org.spongepowered.asm.service.MixinService;
/**
* Manager for Mixin containers bootstrapping via {@link IMixinConnector}
@@ -43,27 +44,50 @@ public class MixinConnectorManager {
* Logging to the max
*/
private static final Logger logger = LogManager.getLogger("mixin");
private final Set<String> connectorClasses = new LinkedHashSet<String>();
private List<IMixinConnector> connectors = new ArrayList<IMixinConnector>();
private final List<IMixinConnector> connectors = new ArrayList<IMixinConnector>();
MixinConnectorManager() {
}
void addConnector(String connectorClass) {
this.connectorClasses.add(connectorClass);
}
void inject() {
this.loadConnectors();
this.initConnectors();
}
@SuppressWarnings("unchecked")
void loadConnectors() {
ServiceLoader<IMixinConnector> serviceLoader = ServiceLoader.load(IMixinConnector.class);
for (Iterator<IMixinConnector> iterator = serviceLoader.iterator(); iterator.hasNext(); ) {
IClassProvider classProvider = MixinService.getService().getClassProvider();
for (String connectorClassName : this.connectorClasses) {
Class<IMixinConnector> connectorClass = null;
try {
IMixinConnector connector = iterator.next();
Class<?> clazz = classProvider.findClass(connectorClassName);
if (!IMixinConnector.class.isAssignableFrom(clazz)) {
MixinConnectorManager.logger.error("Mixin Connector [" + connectorClassName + "] does not implement IMixinConnector");
continue;
}
connectorClass = (Class<IMixinConnector>)clazz;
} catch (ClassNotFoundException ex) {
MixinConnectorManager.logger.catching(ex);
continue;
}
try {
IMixinConnector connector = connectorClass.newInstance();
this.connectors.add(connector);
} catch (ServiceConfigurationError e) {
MixinConnectorManager.logger.catching(e);
MixinConnectorManager.logger.info("Successfully loaded Mixin Connector [" + connectorClassName + "]");
} catch (ReflectiveOperationException ex) {
MixinConnectorManager.logger.warn("Error loading Mixin Connector [" + connectorClassName + "]", ex);
}
}
this.connectorClasses.clear();
}
void initConnectors() {
@@ -53,6 +53,11 @@ public class MixinPlatformAgentDefault extends MixinPlatformAgentAbstract {
this.manager.addTokenProvider(provider.trim());
}
}
String connectorClass = this.handle.getAttribute(ManifestAttributes.MIXINCONNECTOR);
if (connectorClass != null) {
this.manager.addConnector(connectorClass.trim());
}
}
}
@@ -68,6 +68,12 @@ public class MixinPlatformManager {
*/
private final Map<IContainerHandle, MixinContainer> containers = new LinkedHashMap<IContainerHandle, MixinContainer>();
/**
* Connectors
*/
private final MixinConnectorManager connectors = new MixinConnectorManager();
/**
* Container for this tweaker
*/
@@ -187,6 +193,8 @@ public class MixinPlatformManager {
ex.printStackTrace();
}
}
this.connectors.inject();
}
/**
@@ -280,5 +288,16 @@ public class MixinPlatformManager {
MixinEnvironment.getDefaultEnvironment().registerTokenProviderClass(provider);
}
/**
* Add a mixin connector class for a jar manifest source. Supports only bare
* class names.
*
* @param connectorClass Name of the connector class to load
*/
final void addConnector(String connectorClass) {
this.connectors.addConnector(connectorClass);
}
}
@@ -55,6 +55,7 @@ import org.spongepowered.asm.util.IConsumer;
import org.spongepowered.asm.util.ITokenProvider;
import org.spongepowered.asm.util.JavaVersion;
import org.spongepowered.asm.util.PrettyPrinter;
import org.spongepowered.asm.util.asm.ASM;
import org.spongepowered.asm.util.perf.Profiler;
import com.google.common.collect.ImmutableList;
@@ -700,12 +701,17 @@ public final class MixinEnvironment implements ITokenProvider {
public static final int NESTING = 4;
/**
* Native nesting
* Dynamic constants
*/
public static final int DYNAMIC_CONSTANTS = 8;
}
/**
* Default compatibility level to use if not specified by the service
*/
public static CompatibilityLevel DEFAULT = CompatibilityLevel.JAVA_6;
private final int ver;
private final int classVersion;
@@ -720,11 +726,6 @@ public final class MixinEnvironment implements ITokenProvider {
this.languageFeatures = languageFeatures;
}
@SuppressWarnings("unused")
private void setMaxCompatibleLevel(CompatibilityLevel maxCompatibleLevel) {
this.maxCompatibleLevel = maxCompatibleLevel;
}
/**
* Get whether this compatibility level is supported in the current
* environment
@@ -773,6 +774,16 @@ public final class MixinEnvironment implements ITokenProvider {
return level == null || this.ver >= level.ver;
}
/**
* Get whether this level is less than the specified level
*
* @param level level to compare to
* @return true if this level is less than the supplied level
*/
public boolean isLessThan(CompatibilityLevel level) {
return level == null || this.ver < level.ver;
}
/**
* Get whether this level can be elevated to the specified level
*
@@ -882,7 +893,7 @@ public final class MixinEnvironment implements ITokenProvider {
/**
* Current compatibility level
*/
private static CompatibilityLevel compatibility = Option.DEFAULT_COMPATIBILITY_LEVEL.<CompatibilityLevel>getEnumValue(CompatibilityLevel.JAVA_6);
private static CompatibilityLevel compatibility;
/**
* Show debug header info on first environment construction
@@ -991,7 +1002,9 @@ public final class MixinEnvironment implements ITokenProvider {
printer.add("SpongePowered MIXIN%s", verbose ? " (Verbose debugging enabled)" : "").centre().hr();
printer.kv("Code source", codeSource);
printer.kv("Internal Version", version);
printer.kv("Java Versions Supported", CompatibilityLevel.getSupportedVersions()).hr();
printer.kv("Java Versions Supported", CompatibilityLevel.getSupportedVersions());
printer.kv("Current Compatibility Level", MixinEnvironment.getCompatibilityLevel());
printer.kv("Detected ASM API Version", ASM.getApiVersionString()).hr();
printer.kv("Service Name", serviceName);
printer.kv("Mixin Service Class", this.service.getClass().getName());
printer.kv("Global Property Service Class", MixinService.getGlobalPropertyService().getClass().getName()).hr();
@@ -1368,9 +1381,19 @@ public final class MixinEnvironment implements ITokenProvider {
* Get the current compatibility level
*/
public static CompatibilityLevel getCompatibilityLevel() {
if (MixinEnvironment.compatibility == null) {
CompatibilityLevel minLevel = MixinEnvironment.getMinCompatibilityLevel();
CompatibilityLevel optionLevel = Option.DEFAULT_COMPATIBILITY_LEVEL.<CompatibilityLevel>getEnumValue(minLevel);
MixinEnvironment.compatibility = optionLevel.isAtLeast(minLevel) ? optionLevel : minLevel;
}
return MixinEnvironment.compatibility;
}
private static CompatibilityLevel getMinCompatibilityLevel() {
CompatibilityLevel minLevel = MixinService.getService().getMinCompatibilityLevel();
return minLevel == null ? CompatibilityLevel.DEFAULT : minLevel;
}
/**
* Set desired compatibility level for the entire environment
*
@@ -1385,10 +1408,18 @@ public final class MixinEnvironment implements ITokenProvider {
MixinEnvironment.logger.warn("MixinEnvironment::setCompatibilityLevel is deprecated and will be removed. Set level via config instead!");
}
if (level != MixinEnvironment.compatibility && level.isAtLeast(MixinEnvironment.compatibility)) {
CompatibilityLevel currentLevel = MixinEnvironment.getCompatibilityLevel();
if (level != currentLevel && level.isAtLeast(currentLevel)) {
if (!level.isSupported()) {
throw new IllegalArgumentException("The requested compatibility level " + level + " could not be set. Level is not supported");
}
IMixinService service = MixinService.getService();
CompatibilityLevel maxLevel = service.getMaxCompatibilityLevel();
if (maxLevel != null && maxLevel.isLessThan(level)) {
MixinEnvironment.logger.warn("The requested compatibility level {} is higher than the level supported by the active subsystem '{}'"
+ " which supports {}. This is not a supported configuration and instability may occur.", level, service.getName(), maxLevel);
}
MixinEnvironment.compatibility = level;
MixinEnvironment.logger.info("Compatibility level set to {}", level);
@@ -31,7 +31,7 @@ import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.MethodNode;
import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException;
import org.spongepowered.asm.mixin.refmap.IMixinContext;
import org.spongepowered.asm.util.Bytecode;
import org.spongepowered.asm.util.asm.ASM;
/**
* Base class for accessor generators
@@ -70,7 +70,7 @@ public abstract class AccessorGenerator {
*/
protected final MethodNode createMethod(int maxLocals, int maxStack) {
MethodNode method = this.info.getMethod();
MethodNode accessor = new MethodNode(Bytecode.ASM_API_VERSION, (method.access & ~Opcodes.ACC_ABSTRACT) | Opcodes.ACC_SYNTHETIC, method.name,
MethodNode accessor = new MethodNode(ASM.API_VERSION, (method.access & ~Opcodes.ACC_ABSTRACT) | Opcodes.ACC_SYNTHETIC, method.name,
method.desc, null, null);
accessor.visibleAnnotations = new ArrayList<AnnotationNode>();
accessor.visibleAnnotations.add(this.info.getAnnotation());
@@ -29,6 +29,7 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.Map.Entry;
@@ -58,11 +59,13 @@ import org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionExceptio
import org.spongepowered.asm.mixin.refmap.IMixinContext;
import org.spongepowered.asm.mixin.struct.SpecialMethodInfo;
import org.spongepowered.asm.mixin.throwables.MixinError;
import org.spongepowered.asm.mixin.throwables.MixinException;
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.Annotations;
import org.spongepowered.asm.util.Bytecode;
import org.spongepowered.asm.util.asm.ASM;
import org.spongepowered.asm.util.asm.ElementNode;
import com.google.common.base.Strings;
@@ -131,6 +134,13 @@ public abstract class InjectionInfo extends SpecialMethodInfo implements ISliceC
InjectionInfo create(MixinTargetContext mixin, MethodNode method, AnnotationNode annotation) {
try {
return this.ctor.newInstance(mixin, method, annotation);
} catch (InvocationTargetException itex) {
Throwable cause = itex.getCause();
if (cause instanceof MixinException) {
throw (MixinException)cause;
}
Throwable ex = cause != null ? cause : itex;
throw new MixinError("Error initialising injector metaclass [" + this.type + "] for annotation " + annotation.desc, ex);
} catch (ReflectiveOperationException ex) {
throw new MixinError("Failed to instantiate injector metaclass [" + this.type + "] for annotation " + annotation.desc, ex);
}
@@ -457,7 +467,7 @@ public abstract class InjectionInfo extends SpecialMethodInfo implements ISliceC
* @return new method
*/
public MethodNode addMethod(int access, String name, String desc) {
MethodNode method = new MethodNode(Bytecode.ASM_API_VERSION, access | Opcodes.ACC_SYNTHETIC, name, desc, null, null);
MethodNode method = new MethodNode(ASM.API_VERSION, access | Opcodes.ACC_SYNTHETIC, name, desc, null, null);
this.injectedMethods.add(method);
return method;
}
@@ -58,6 +58,7 @@ import org.spongepowered.asm.mixin.transformer.MixinInfo.MixinClassNode;
import org.spongepowered.asm.service.MixinService;
import org.spongepowered.asm.util.Annotations;
import org.spongepowered.asm.util.ClassSignature;
import org.spongepowered.asm.util.Locals;
import org.spongepowered.asm.util.perf.Profiler;
import org.spongepowered.asm.util.perf.Profiler.Section;
@@ -205,17 +206,24 @@ public final class ClassInfo {
* Frame local count
*/
public final int locals;
/**
* Frame local size
*/
public final int size;
FrameData(int index, int type, int locals) {
FrameData(int index, int type, int locals, int size) {
this.index = index;
this.type = type;
this.locals = locals;
this.size = size;
}
FrameData(int index, FrameNode frameNode) {
this.index = index;
this.type = frameNode.type;
this.locals = frameNode.local != null ? frameNode.local.size() : 0;
this.size = Locals.computeFrameSize(frameNode);
}
/* (non-Javadoc)
@@ -42,8 +42,8 @@ import org.spongepowered.asm.mixin.transformer.ext.IClassGenerator;
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
import org.spongepowered.asm.service.ISyntheticClassInfo;
import org.spongepowered.asm.service.MixinService;
import org.spongepowered.asm.util.Bytecode;
import org.spongepowered.asm.util.IConsumer;
import org.spongepowered.asm.util.asm.ASM;
/**
* Class generator which creates unique copies of inner classes within mixins
@@ -200,7 +200,7 @@ final class InnerClassGenerator implements IClassGenerator {
private final InnerClassInfo info;
public InnerClassAdapter(ClassVisitor cv, InnerClassInfo info) {
super(Bytecode.ASM_API_VERSION, cv, info);
super(ASM.API_VERSION, cv, info);
this.info = info;
}
@@ -67,6 +67,7 @@ import org.spongepowered.asm.service.IMixinService;
import org.spongepowered.asm.service.MixinService;
import org.spongepowered.asm.util.Annotations;
import org.spongepowered.asm.util.Bytecode;
import org.spongepowered.asm.util.asm.ASM;
import org.spongepowered.asm.util.CompareUtil;
import org.spongepowered.asm.util.perf.Profiler;
import org.spongepowered.asm.util.perf.Profiler.Section;
@@ -88,7 +89,7 @@ class MixinInfo implements Comparable<MixinInfo>, IMixinInfo {
private final String originalName;
public MixinMethodNode(int access, String name, String desc, String signature, String[] exceptions) {
super(Bytecode.ASM_API_VERSION, access, name, desc, signature, exceptions);
super(ASM.API_VERSION, access, name, desc, signature, exceptions);
this.originalName = name;
}
@@ -135,7 +136,7 @@ class MixinInfo implements Comparable<MixinInfo>, IMixinInfo {
public final List<MixinMethodNode> mixinMethods;
MixinClassNode(MixinInfo mixin) {
this(Bytecode.ASM_API_VERSION);
this(ASM.API_VERSION);
}
@SuppressWarnings("unchecked")
@@ -798,7 +799,7 @@ class MixinInfo implements Comparable<MixinInfo>, IMixinInfo {
} catch (InvalidMixinException ex) {
throw ex;
} catch (Exception ex) {
throw new InvalidMixinException(this, ex);
throw new InvalidMixinException(this, ex.getMessage(), ex);
}
if (!this.type.isLoadable()) {
@@ -29,9 +29,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
@@ -32,8 +32,8 @@ import org.spongepowered.asm.mixin.throwables.MixinException;
import org.spongepowered.asm.mixin.transformer.ext.Extensions;
import org.spongepowered.asm.mixin.transformer.ext.IExtensionRegistry;
import org.spongepowered.asm.transformers.TreeTransformer;
import org.spongepowered.asm.util.Bytecode;
import org.spongepowered.asm.util.Constants;
import org.spongepowered.asm.util.asm.ASM;
/**
* Transformer which manages the mixin configuration and application process
@@ -203,7 +203,7 @@ class MixinTransformer extends TreeTransformer implements IMixinTransformer {
* You need to ask yourself why you're reading this comment
*/
private static ClassNode createEmptyClass(String name) {
ClassNode classNode = new ClassNode(Bytecode.ASM_API_VERSION);
ClassNode classNode = new ClassNode(ASM.API_VERSION);
classNode.name = name.replace('.', '/');
classNode.version = MixinEnvironment.getCompatibilityLevel().classVersion();
classNode.superName = Constants.OBJECT;
@@ -77,7 +77,7 @@ public class ExtensionClassExporter implements IExtension {
try {
MoreFiles.deleteRecursively(this.classExportDir.toPath(), RecursiveDeleteOption.ALLOW_INSECURE);
} catch (IOException ex) {
ExtensionClassExporter.logger.warn("Error cleaning class output directory: {}", ex.getMessage());
ExtensionClassExporter.logger.debug("Error cleaning class output directory: {}", ex.getMessage());
}
}
@@ -28,6 +28,7 @@ import java.io.InputStream;
import java.util.Collection;
import org.spongepowered.asm.launch.platform.container.IContainerHandle;
import org.spongepowered.asm.mixin.MixinEnvironment.CompatibilityLevel;
import org.spongepowered.asm.mixin.MixinEnvironment.Phase;
import org.spongepowered.asm.util.ReEntranceLock;
@@ -176,5 +177,25 @@ public interface IMixinService {
* Get the detected side name for this environment
*/
public abstract String getSideName();
/**
* Get the minimum compatibility level supported by this service. Can return
* <tt>null</tt> if the service has no specific minimum compatibility level,
* however if a value is returned, it will be used as the minimum
* compatibility level and no lower levels will be supported.
*
* @return minimum supported {@link CompatibilityLevel} or null
*/
public abstract CompatibilityLevel getMinCompatibilityLevel();
/**
* Get the maximum compatibility level supported by this service. Can return
* <tt>null</tt> if the service has no specific maximum compatibility level.
* If a value is returned, a warning will be raised if a configuration
* attempts to se a higher compatibility level.
*
* @return minimum supported {@link CompatibilityLevel} or null
*/
public abstract CompatibilityLevel getMaxCompatibilityLevel();
}
@@ -24,8 +24,10 @@
*/
package org.spongepowered.asm.service;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.Set;
@@ -33,6 +35,8 @@ import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.common.base.Joiner;
/**
* Provides access to the service layer which connects the mixin transformer to
* a particular host environment. Host environments are implemented as services
@@ -79,15 +83,17 @@ public final class MixinService {
private void runBootServices() {
this.bootstrapServiceLoader = ServiceLoader.<IMixinServiceBootstrap>load(IMixinServiceBootstrap.class, this.getClass().getClassLoader());
for (IMixinServiceBootstrap bootService : this.bootstrapServiceLoader) {
Iterator<IMixinServiceBootstrap> iter = this.bootstrapServiceLoader.iterator();
while (iter.hasNext()) {
try {
IMixinServiceBootstrap bootService = iter.next();
bootService.bootstrap();
this.bootedServices.add(bootService.getServiceClassName());
} catch (ServiceInitialisationException ex) {
// Expected if service cannot start
MixinService.logger.debug("Mixin bootstrap service {} is not available: {}", bootService.getClass().getName(), ex.getMessage());
MixinService.logger.error("Mixin bootstrap service {} is not available: {}", ex.getStackTrace()[0].getClassName(), ex.getMessage());
} catch (Throwable th) {
MixinService.logger.throwing(th);
MixinService.logger.debug("Catching {}:{} initialising service", th.getClass().getName(), th.getMessage(), th);
}
}
}
@@ -124,6 +130,7 @@ public final class MixinService {
private IMixinService initService() {
this.serviceLoader = ServiceLoader.<IMixinService>load(IMixinService.class, this.getClass().getClassLoader());
Iterator<IMixinService> iter = this.serviceLoader.iterator();
List<String> rejectedServices = new ArrayList<String>();
while (iter.hasNext()) {
try {
IMixinService service = iter.next();
@@ -133,13 +140,14 @@ public final class MixinService {
if (service.isValid()) {
return service;
}
rejectedServices.add(service.getName());
} catch (ServiceConfigurationError serviceError) {
// serviceError.printStackTrace();
} catch (Throwable th) {
// th.printStackTrace();
}
}
throw new ServiceNotAvailableError("No mixin host service is available");
throw new ServiceNotAvailableError("No mixin host service is available. Rejected services: " + Joiner.on(", ").join(rejectedServices));
}
/**
@@ -33,6 +33,7 @@ import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.launch.platform.IMixinPlatformAgent;
import org.spongepowered.asm.launch.platform.IMixinPlatformServiceAgent;
import org.spongepowered.asm.launch.platform.container.IContainerHandle;
import org.spongepowered.asm.mixin.MixinEnvironment.CompatibilityLevel;
import org.spongepowered.asm.mixin.MixinEnvironment.Phase;
import org.spongepowered.asm.util.Constants;
import org.spongepowered.asm.util.IConsumer;
@@ -71,19 +72,50 @@ public abstract class MixinServiceAbstract implements IMixinService {
*/
private String sideName;
/* (non-Javadoc)
* @see org.spongepowered.asm.service.IMixinService#prepare()
*/
@Override
public void prepare() {
}
/* (non-Javadoc)
* @see org.spongepowered.asm.service.IMixinService#getInitialPhase()
*/
@Override
public Phase getInitialPhase() {
return Phase.PREINIT;
}
/* (non-Javadoc)
* @see org.spongepowered.asm.service.IMixinService
* #getMinCompatibilityLevel()
*/
@Override
public CompatibilityLevel getMinCompatibilityLevel() {
return null;
}
/* (non-Javadoc)
* @see org.spongepowered.asm.service.IMixinService
* #getMaxCompatibilityLevel()
*/
@Override
public CompatibilityLevel getMaxCompatibilityLevel() {
return null;
}
/* (non-Javadoc)
* @see org.spongepowered.asm.service.IMixinService#beginPhase()
*/
@Override
public void beginPhase() {
}
/* (non-Javadoc)
* @see org.spongepowered.asm.service.IMixinService
* #checkEnv(java.lang.Object)
*/
@Override
public void checkEnv(Object bootSource) {
}
@@ -43,6 +43,7 @@ import org.objectweb.asm.Type;
import org.objectweb.asm.tree.*;
import org.objectweb.asm.util.CheckClassAdapter;
import org.objectweb.asm.util.TraceClassVisitor;
import org.spongepowered.asm.util.asm.ASM;
import org.spongepowered.asm.util.throwables.SyntheticBridgeException;
import org.spongepowered.asm.util.throwables.SyntheticBridgeException.Problem;
@@ -143,8 +144,6 @@ public final class Bytecode {
return this.isSuper ? "super" : "this";
}
}
public static final int ASM_API_VERSION = Opcodes.ASM6;
/**
* Integer constant opcodes
@@ -390,8 +389,9 @@ public final class Bytecode {
*/
public static void printMethod(MethodNode method) {
System.err.printf("%s%s\n", method.name, method.desc);
int index = 0;
for (Iterator<AbstractInsnNode> iter = method.instructions.iterator(); iter.hasNext();) {
System.err.print(" ");
System.err.printf("%-4d ", index++);
Bytecode.printNode(iter.next());
}
}
@@ -1161,7 +1161,6 @@ public final class Bytecode {
dest.sourceDebug = source.sourceDebug;
dest.sourceFile = source.sourceFile;
dest.module = source.module;
dest.outerClass = source.outerClass;
dest.outerMethod = source.outerMethod;
dest.outerMethodDesc = source.outerMethodDesc;
@@ -1175,7 +1174,10 @@ public final class Bytecode {
Bytecode.<InnerClassNode>clear(dest.innerClasses);
Bytecode.<FieldNode>clear(dest.fields);
Bytecode.<MethodNode>clear(dest.methods);
if (ASM.API_VERSION >= Opcodes.ASM6) {
dest.module = source.module;
}
// TODO Java 10
// dest.nestHostClassExperimental = source.nestHostClassExperimental;
@@ -1216,4 +1218,5 @@ public final class Bytecode {
destination.addAll(source);
return destination;
}
}
@@ -39,6 +39,7 @@ import org.objectweb.asm.signature.SignatureReader;
import org.objectweb.asm.signature.SignatureVisitor;
import org.objectweb.asm.signature.SignatureWriter;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.util.asm.ASM;
/**
* Represents an object-oriented view of a generic class signature. We use ASM's
@@ -660,7 +661,7 @@ public class ClassSignature {
abstract class SignatureElement extends SignatureVisitor {
public SignatureElement() {
super(Bytecode.ASM_API_VERSION);
super(ASM.API_VERSION);
}
}
@@ -897,7 +898,7 @@ public class ClassSignature {
private FormalParamElement param;
SignatureParser() {
super(Bytecode.ASM_API_VERSION);
super(ASM.API_VERSION);
}
@Override
@@ -69,6 +69,7 @@ public abstract class Constants {
public static final String MAINCLASS = "Main-Class";
public static final String MIXINCONFIGS = "MixinConfigs";
public static final String TOKENPROVIDERS = "MixinTokenProviders";
public static final String MIXINCONNECTOR = "MixinConnector";
@Deprecated
public static final String COMPATIBILITY = "MixinCompatibilityLevel";
@@ -48,6 +48,7 @@ import org.objectweb.asm.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.util.asm.ASM;
import org.spongepowered.asm.util.asm.MixinVerifier;
import org.spongepowered.asm.util.throwables.LVTGeneratorError;
@@ -56,6 +57,11 @@ import org.spongepowered.asm.util.throwables.LVTGeneratorError;
*/
public final class Locals {
/**
* Frame type names just for the purposes of debug printing
*/
private static final String[] FRAME_TYPES = { "TOP", "INTEGER", "FLOAT", "DOUBLE", "LONG", "NULL", "UNINITIALIZED_THIS" };
/**
* Cached local variable lists, to avoid having to recalculate them
* (expensive) if multiple injectors are working with the same method
@@ -157,24 +163,56 @@ public final class Locals {
}
int initialFrameSize = local;
int frameIndex = -1, locals = 0;
int frameSize = local;
int frameIndex = -1;
int lastFrameSize = local;
VarInsnNode storeInsn = null;
for (Iterator<AbstractInsnNode> iter = method.instructions.iterator(); iter.hasNext();) {
AbstractInsnNode insn = iter.next();
if (insn instanceof FrameNode) {
if (storeInsn != null) {
frame[storeInsn.var] = Locals.getLocalVariableAt(classNode, method, insn, storeInsn.var);
storeInsn = null;
}
handleFrame: if (insn instanceof FrameNode) {
frameIndex++;
FrameNode frameNode = (FrameNode)insn;
FrameData frameData = frameIndex < frames.size() ? frames.get(frameIndex) : null;
if (frameNode.type == Opcodes.F_SAME || frameNode.type == Opcodes.F_SAME1) {
break handleFrame;
}
locals = frameData != null && frameData.type == Opcodes.F_FULL ? Math.min(locals, frameData.locals) : frameNode.local.size();
FrameData frameData = frameIndex < frames.size() ? frames.get(frameIndex) : null;
if (frameData != null) {
if (frameData.type == Opcodes.F_FULL) {
frameSize = Math.min(frameSize, frameData.locals);
lastFrameSize = frameSize;
} else {
frameSize = Locals.getAdjustedFrameSize(frameSize, frameData);
}
} else {
frameSize = Locals.getAdjustedFrameSize(frameSize, frameNode);
}
if (frameNode.type == Opcodes.F_CHOP) {
for (int framePos = frameSize; framePos < frame.length; framePos++) {
frame[framePos] = null;
}
lastFrameSize = frameSize;
break handleFrame;
}
int framePos = frameNode.type == Opcodes.F_APPEND ? lastFrameSize : 0;
lastFrameSize = frameSize;
// localPos tracks the location in the frame node's locals list, which doesn't leave space for TOP entries
for (int localPos = 0, framePos = 0; framePos < frame.length; framePos++, localPos++) {
for (int localPos = 0; framePos < frame.length; framePos++, localPos++) {
// Get the local at the current position in the FrameNode's locals list
final Object localType = (localPos < frameNode.local.size()) ? frameNode.local.get(localPos) : null;
if (localType instanceof String) { // String refers to a reference type
frame[framePos] = Locals.getLocalVariableAt(classNode, method, node, framePos);
frame[framePos] = Locals.getLocalVariableAt(classNode, method, insn, framePos);
} else if (localType instanceof Integer) { // Integer refers to a primitive type or other marker
boolean isMarkerType = localType == Opcodes.UNINITIALIZED_THIS || localType == Opcodes.NULL;
boolean is32bitValue = localType == Opcodes.INTEGER || localType == Opcodes.FLOAT;
@@ -184,8 +222,8 @@ public final class Locals {
} else if (isMarkerType) {
frame[framePos] = null;
} else if (is32bitValue || is64bitValue) {
frame[framePos] = Locals.getLocalVariableAt(classNode, method, node, framePos);
frame[framePos] = Locals.getLocalVariableAt(classNode, method, insn, framePos);
if (is64bitValue) {
framePos++;
frame[framePos] = null; // TOP
@@ -195,9 +233,11 @@ public final class Locals {
+ " in " + classNode.name + "." + method.name + method.desc);
}
} else if (localType == null) {
if (framePos >= initialFrameSize && framePos >= locals && locals > 0) {
if (framePos >= initialFrameSize && framePos >= frameSize && frameSize > 0) {
frame[framePos] = null;
}
} else if (localType instanceof LabelNode) {
// Uninitialised
} else {
throw new LVTGeneratorError("Invalid value " + localType + " in locals array at position " + localPos
+ " in " + classNode.name + "." + method.name + method.desc);
@@ -205,8 +245,16 @@ public final class Locals {
}
} else if (insn instanceof VarInsnNode) {
VarInsnNode varNode = (VarInsnNode) insn;
frame[varNode.var] = Locals.getLocalVariableAt(classNode, method, node, varNode.var);
}
boolean isLoad = insn.getOpcode() >= Opcodes.ILOAD && insn.getOpcode() <= Opcodes.SALOAD;
if (isLoad) {
frame[varNode.var] = Locals.getLocalVariableAt(classNode, method, insn, varNode.var);
} else {
// Update the LVT for the opcode AFTER this one, since we always want to know
// the frame state BEFORE the *current* instruction to match the contract of
// injection points
storeInsn = varNode;
}
}
if (insn == node) {
break;
@@ -223,7 +271,7 @@ public final class Locals {
return frame;
}
/**
/**
* Attempts to locate the appropriate entry in the local variable table for
* the specified local variable index at the location specified by node.
*
@@ -277,7 +325,7 @@ public final class Locals {
}
private static boolean isOpcodeInRange(InsnList insns, LocalVariableNode local, int pos) {
return insns.indexOf(local.start) < pos && insns.indexOf(local.end) > pos;
return insns.indexOf(local.start) <= pos && insns.indexOf(local.end) > pos;
}
/**
@@ -341,7 +389,7 @@ public final class Locals {
// Use Analyzer to generate the bytecode frames
Analyzer<BasicValue> analyzer = new Analyzer<BasicValue>(
new MixinVerifier(Bytecode.ASM_API_VERSION, Type.getObjectType(classNode.name), objectType, interfaces, false));
new MixinVerifier(ASM.API_VERSION, Type.getObjectType(classNode.name), objectType, interfaces, false));
try {
analyzer.analyze(classNode.name, method);
} catch (AnalyzerException ex) {
@@ -449,5 +497,108 @@ public final class Locals {
}
return insn;
}
/**
* Compute a new frame size based on the supplied frame type and the size of
* locals contained in the frame (this may differ from the number of actual
* frame slots if the frame contains doubles or longs)
*
* @param currentSize current frame size
* @param frameNode frame entry
* @return new frame size
*/
private static int getAdjustedFrameSize(int currentSize, FrameNode frameNode) {
return Locals.getAdjustedFrameSize(currentSize, frameNode.type, Locals.computeFrameSize(frameNode));
}
/**
* Compute a new frame size based on the supplied frame type and the size of
* locals contained in the frame (this may differ from the number of actual
* frame slots if the frame contains doubles or longs)
*
* @param currentSize current frame size
* @param frameData frame entry
* @return new frame size
*/
private static int getAdjustedFrameSize(int currentSize, FrameData frameData) {
return Locals.getAdjustedFrameSize(currentSize, frameData.type, frameData.size);
}
/**
* Compute a new frame size based on the supplied frame type and the size of
* locals contained in the frame (this may differ from the number of actual
* frame slots if the frame contains doubles or longs)
*
* @param currentSize current frame size
* @param type frame entry type
* @param size frame entry size
* @return new frame size
*/
private static int getAdjustedFrameSize(int currentSize, int type, int size) {
switch (type) {
case Opcodes.F_NEW:
case Opcodes.F_FULL:
return size;
case Opcodes.F_APPEND:
return currentSize + size;
case Opcodes.F_CHOP:
return currentSize - size;
case Opcodes.F_SAME:
case Opcodes.F_SAME1:
return currentSize;
default:
return currentSize;
}
}
/**
* Compute the size required to accomodate the entries described by the
* supplied frame node
*
* @param frameNode frame node with locals to compute
* @return size of frame node locals
*/
public static int computeFrameSize(FrameNode frameNode) {
if (frameNode.local == null) {
return 0;
}
int size = 0;
for (Object local : frameNode.local) {
if (local instanceof Integer) {
size += (local == Opcodes.DOUBLE || local == Opcodes.LONG) ? 2 : 1;
} else {
size++;
}
}
return size;
}
/**
* Debug function to return printable name of a frame entry
*
* @param frameEntry Frame entry
* @return string representation of the supplied frame entry
*/
public static String getFrameTypeName(Object frameEntry) {
if (frameEntry == null) {
return "NULL";
}
if (frameEntry instanceof String) {
return Bytecode.getSimpleName(frameEntry.toString());
}
if (frameEntry instanceof Integer) {
int type = ((Integer)frameEntry).intValue();
if (type >= Locals.FRAME_TYPES.length) {
return "INVALID";
}
return Locals.FRAME_TYPES[type];
}
return "?";
}
}
@@ -0,0 +1,89 @@
/*
* 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.util.asm;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
/**
* Utility methods for determining ASM version and other version-specific
* shenanigans
*/
public final class ASM {
@SuppressWarnings("deprecation")
private static final int[] EXPERIMENTAL_VERSIONS = { Opcodes.ASM7_EXPERIMENTAL };
private static final int[] SUPPORTED_VERSIONS = { Opcodes.ASM6, Opcodes.ASM5 };
public static final int API_VERSION = ASM.detectVersion();
private static boolean experimental;
private ASM() {
}
/**
* Get the ASM API version as a string (mostly for debugging and the banner)
*
* @return
*/
public static String getApiVersionString() {
String suffix = "";
if (ASM.experimental) {
int version = ASM.detectVersion(ASM.SUPPORTED_VERSIONS);
suffix = String.format("-EXPERIMENTAL (%d.%d)", ((0xFF0000 & version) >> 16), ((0xFF00 & version) >> 8));
}
return String.format("ASM %d.%d%s", ((0xFF0000 & ASM.API_VERSION) >> 16), ((0xFF00 & ASM.API_VERSION) >> 8), suffix);
}
private static int detectVersion() {
int expVersion = ASM.detectVersion(ASM.EXPERIMENTAL_VERSIONS);
if (expVersion > 0) {
ASM.experimental = true;
return expVersion;
}
ASM.experimental = false;
int version = ASM.detectVersion(ASM.SUPPORTED_VERSIONS);
if (version > 0) {
return version;
}
return Opcodes.ASM5;
}
private static int detectVersion(int[] versions) {
for (int version : versions) {
try {
new ClassNode(version).hashCode();
return version;
} catch (IllegalArgumentException ex) {
// expected, this version is not supported
}
}
return 0;
}
}
@@ -34,7 +34,7 @@ import org.spongepowered.asm.util.Bytecode;
public class MethodVisitorEx extends MethodVisitor {
public MethodVisitorEx(MethodVisitor mv) {
super(Bytecode.ASM_API_VERSION, mv);
super(ASM.API_VERSION, mv);
}
/**
@@ -1,32 +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.launch;
/**
* Class interceptor. Decorator interface only. Blatant h4x.
*/
public interface IClassInterceptor extends IClassProcessor {
}
@@ -45,9 +45,10 @@ public interface IClassProcessor {
* @param classType the class to consider
* @param isEmpty if the class is empty at present (indicates no backing
* file found)
* @param reason the reason for processing
* @return the set of Phases the plugin wishes to be called back with
*/
public abstract EnumSet<Phase> handlesClass(Type classType, boolean isEmpty);
public abstract EnumSet<Phase> handlesClass(Type classType, boolean isEmpty, String reason);
/**
@@ -56,8 +57,9 @@ public interface IClassProcessor {
* @param phase The phase of the supplied class node
* @param classNode the classnode to process
* @param classType the name of the class
* @param reason the reason for processing
* @return true if the class was processed
*/
public abstract boolean processClass(Phase phase, ClassNode classNode, Type classType);
public abstract boolean processClass(Phase phase, ClassNode classNode, Type classType, String reason);
}
@@ -24,40 +24,51 @@
*/
package org.spongepowered.asm.launch;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Map.Entry;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.launch.platform.CommandLineOptions;
import org.spongepowered.asm.service.IClassBytecodeProvider;
import org.spongepowered.asm.service.IMixinService;
import org.spongepowered.asm.service.MixinService;
import org.spongepowered.asm.service.modlauncher.MixinServiceModLauncher;
import com.google.common.io.Resources;
import cpw.mods.modlauncher.api.IEnvironment;
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
/**
* Mixin launch plugin
*/
public class MixinLaunchPlugin implements ILaunchPluginService {
public class MixinLaunchPlugin implements ILaunchPluginService, IClassBytecodeProvider {
/**
* Name used for ModLauncher mixin service components
*/
public static final String NAME = "mixin";
/**
* Interceptor if present
*/
private IClassInterceptor interceptor;
/**
* Class processing components
*/
private List<IClassProcessor> processors = new ArrayList<IClassProcessor>();
/**
* Mixin config names specified on the command line
*/
private List<String> commandLineMixins;
private ITransformerLoader transformerLoader;
private MixinServiceModLauncher service;
/* (non-Javadoc)
* @see cpw.mods.modlauncher.serviceapi.ILaunchPluginService#name()
@@ -67,27 +78,31 @@ public class MixinLaunchPlugin implements ILaunchPluginService {
return MixinLaunchPlugin.NAME;
}
/* (non-Javadoc)
* @see cpw.mods.modlauncher.serviceapi.ILaunchPluginService
* #handlesClass(org.objectweb.asm.Type, boolean)
*/
@Override
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
if (this.interceptor != null) {
// If the interceptor wants to handle this class, it has executive
// power since this entry is almost certainly simulated. If it's
// not a simulated entry then something is probably not right. RIP?
EnumSet<Phase> interceptorVote = this.interceptor.handlesClass(classType, isEmpty);
if (interceptorVote != null) {
return interceptorVote;
}
throw new IllegalStateException("Outdated ModLauncher");
}
@Override
public boolean processClass(Phase phase, ClassNode classNode, Type classType) {
throw new IllegalStateException("Outdated ModLauncher");
}
/* (non-Javadoc)
* @see cpw.mods.modlauncher.serviceapi.ILaunchPluginService#handlesClass(
* org.objectweb.asm.Type, boolean, java.lang.String)
*/
@Override
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty, final String reason) {
if (MixinLaunchPlugin.NAME.equals(reason)) {
return Phases.NONE;
}
// All processors can nominate phases, we aggregate the results
EnumSet<Phase> phases = EnumSet.<Phase>noneOf(Phase.class);
synchronized (this.processors) {
for (IClassProcessor postProcessor : this.processors) {
EnumSet<Phase> processorVote = postProcessor.handlesClass(classType, isEmpty);
EnumSet<Phase> processorVote = postProcessor.handlesClass(classType, isEmpty, reason);
if (processorVote != null) {
phases.addAll(processorVote);
}
@@ -98,40 +113,54 @@ public class MixinLaunchPlugin implements ILaunchPluginService {
}
/* (non-Javadoc)
* @see cpw.mods.modlauncher.serviceapi.ILaunchPluginService
* #processClass(
* @see cpw.mods.modlauncher.serviceapi.ILaunchPluginService#processClass(
* cpw.mods.modlauncher.serviceapi.ILaunchPluginService.Phase,
* org.objectweb.asm.tree.ClassNode, org.objectweb.asm.Type)
* org.objectweb.asm.tree.ClassNode, org.objectweb.asm.Type,
* java.lang.String)
*/
@Override
public boolean processClass(Phase phase, ClassNode classNode, Type classType) {
if (this.interceptor != null) {
if (this.interceptor.processClass(phase, classNode, classType)) {
// If the interceptor handles the class, then this is likely a
// simulated entry. Return immediately and don't delegate to
// other processors
return true;
}
public boolean processClass(Phase phase, ClassNode classNode, Type classType, String reason) {
if (MixinLaunchPlugin.NAME.equals(reason)) {
return false;
}
boolean processed = false;
synchronized (this.processors) {
for (IClassProcessor postProcessor : this.processors) {
processed |= postProcessor.processClass(phase, classNode, classType);
processed |= postProcessor.processClass(phase, classNode, classType, reason);
}
}
return processed;
}
/* (non-Javadoc)
* @see cpw.mods.modlauncher.serviceapi.ILaunchPluginService#addResource(
* java.nio.file.Path, java.lang.String)
/**
* Initialisation routine, called as a lifecycle event from the
* transformation service
*/
void init(IEnvironment environment, List<String> commandLineMixins) {
IMixinService service = MixinService.getService();
if (!(service instanceof MixinServiceModLauncher)) {
throw new IllegalStateException("Unsupported service type for ModLauncher Mixin Service");
}
this.service = (MixinServiceModLauncher)service;
synchronized (this.processors) {
this.processors.addAll(this.service.getProcessors());
}
this.commandLineMixins = commandLineMixins;
this.service.onInit(this);
}
@Override
@Deprecated
public void addResource(Path resource, String name) {
// This is never called, I'm not sure what it's for
this.service.getPrimaryContainer().addResource(name, resource);
}
@Override
public void addResources(List<Entry<String, Path>> resources) {
this.service.getPrimaryContainer().addResources(resources);
}
/* (non-Javadoc)
@@ -142,24 +171,49 @@ public class MixinLaunchPlugin implements ILaunchPluginService {
return null;
}
/**
* Initialisation routine, called as a lifecycle event from the
* transformation service
*/
void init(IEnvironment environment, Runnable startupListener) {
IMixinService service = MixinService.getService();
if (!(service instanceof MixinServiceModLauncher)) {
throw new IllegalStateException("Unsupported service type for ModLauncher Mixin Service");
@Override
public void initializeLaunch(ITransformerLoader transformerLoader, Path[] specialPaths) {
this.transformerLoader = transformerLoader;
MixinBootstrap.doInit(CommandLineOptions.of(this.commandLineMixins));
MixinBootstrap.inject();
this.service.onStartup();
}
@Override
public ClassNode getClassNode(String name) throws ClassNotFoundException, IOException {
return this.getClassNode(name, true);
}
@Override
public ClassNode getClassNode(String name, boolean runTransformers) throws ClassNotFoundException, IOException {
if (!runTransformers) {
throw new IllegalArgumentException("ModLauncher service does not currently support retrieval of untransformed bytecode");
}
IClassBytecodeProvider bytecodeProvider = service.getBytecodeProvider();
if (bytecodeProvider instanceof IClassInterceptor) {
this.interceptor = (IClassInterceptor)bytecodeProvider;
byte[] classBytes;
try {
classBytes = this.transformerLoader.buildTransformedClassNodeFor(name);
} catch (ClassNotFoundException ex) {
URL url = Thread.currentThread().getContextClassLoader().getResource(name.replace('.', '/') + ".class");
if (url == null) {
throw ex;
}
try {
classBytes = Resources.asByteSource(url).read();
} catch (IOException ioex) {
throw ex;
}
}
MixinServiceModLauncher modLauncherService = (MixinServiceModLauncher)service;
synchronized (this.processors) {
this.processors.addAll(modLauncherService.getProcessors());
if (classBytes == null) {
throw new ClassNotFoundException(name.replace('/', '.'));
}
modLauncherService.onInit(startupListener);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(classBytes);
classReader.accept(classNode, ClassReader.EXPAND_FRAMES);
return classNode;
}
}
@@ -24,13 +24,12 @@
*/
package org.spongepowered.asm.launch;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiFunction;
import org.spongepowered.asm.launch.platform.CommandLineOptions;
import com.google.common.collect.ImmutableList;
import cpw.mods.modlauncher.api.IEnvironment;
@@ -47,7 +46,7 @@ import joptsimple.OptionSpecBuilder;
public class MixinTransformationService implements ITransformationService {
private ArgumentAcceptingOptionSpec<String> mixinsArgument;
private List<String> commandLineMixins;
private List<String> commandLineMixins = new ArrayList<String>();
private MixinLaunchPlugin plugin;
@Override
@@ -63,7 +62,7 @@ public class MixinTransformationService implements ITransformationService {
@Override
public void argumentValues(OptionResult option) {
this.commandLineMixins = option.values(this.mixinsArgument);
this.commandLineMixins.addAll(option.values(this.mixinsArgument));
}
@Override
@@ -83,14 +82,9 @@ public class MixinTransformationService implements ITransformationService {
this.plugin = (MixinLaunchPlugin)launchPlugin;
MixinBootstrap.start();
this.plugin.init(environment, this::onStartup);
this.plugin.init(environment, this.commandLineMixins);
}
private void onStartup() {
MixinBootstrap.doInit(CommandLineOptions.of(this.commandLineMixins));
MixinBootstrap.inject();
}
@Override
public void beginScanning(IEnvironment environment) {
}
@@ -24,88 +24,27 @@
*/
package org.spongepowered.asm.launch.platform;
import java.lang.reflect.Method;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import org.spongepowered.asm.launch.platform.container.ContainerHandleURI;
import org.spongepowered.asm.launch.platform.container.ContainerHandleVirtual;
import org.spongepowered.asm.launch.platform.container.IContainerHandle;
import org.spongepowered.asm.util.Constants;
import com.google.common.collect.ImmutableSet;
import cpw.mods.modlauncher.Environment;
import cpw.mods.modlauncher.Launcher;
import cpw.mods.modlauncher.api.IEnvironment;
/**
* Platform agent for minecraft forge under ModLauncher
* Platform agent for minecraft forge under ModLauncher, only detects the side
*/
public class MixinPlatformAgentMinecraftForge extends MixinPlatformAgentAbstract implements IMixinPlatformServiceAgent {
private static final String FML_LOADING_PACKAGE = "net.minecraftforge.fml.loading.";
private static final String FML_DISCOVERY_PACKAGE = MixinPlatformAgentMinecraftForge.FML_LOADING_PACKAGE + "moddiscovery.";
private static final String LAUNCHER_VERSION_CLASS = MixinPlatformAgentMinecraftForge.FML_LOADING_PACKAGE + "LauncherVersion";
private static final String LOADING_MOD_LIST_CLASS = MixinPlatformAgentMinecraftForge.FML_LOADING_PACKAGE + "LoadingModList";
private static final String MOD_FILE_INFO_CLASS = MixinPlatformAgentMinecraftForge.FML_DISCOVERY_PACKAGE + "ModFileInfo";
private static final String MOD_FILE_CLASS = MixinPlatformAgentMinecraftForge.FML_DISCOVERY_PACKAGE + "ModFile";
private static final String GET_MOD_LIST_METHOD = "get";
private static final String GET_MOD_FILES_METHOD = "getModFiles";
private static final String GET_MOD_FILE_METHOD = "getFile";
private static final String GET_FILE_PATH_METHOD = "getFilePath";
private ContainerHandleVirtual rootContainer;
/* (non-Javadoc)
* @see org.spongepowered.asm.launch.platform.IMixinPlatformServiceAgent
* #init()
*/
@Override
public void init() {
try {
Class.forName(MixinPlatformAgentMinecraftForge.LAUNCHER_VERSION_CLASS);
} catch (Exception ex) {
MixinPlatformAgentAbstract.logger.debug("FML Launcher Version class was not found, assuming FML is not present");
return;
}
String activity = "Initialising FML containers";
try {
// Normally I'd cache these reflection objects, but this should only get called once
activity = "Resolving FML LoadingModList class";
Class<?> clModList = Class.forName(MixinPlatformAgentMinecraftForge.LOADING_MOD_LIST_CLASS);
activity = "Resolving FML ModFileInfo class";
Class<?> clModFileInfo = Class.forName(MixinPlatformAgentMinecraftForge.MOD_FILE_INFO_CLASS);
activity = "Resolving FML ModFile class";
Class<?> clModFile = Class.forName(MixinPlatformAgentMinecraftForge.MOD_FILE_CLASS);
activity = "Resolving FML LoadingModList::get method";
Method mdGetModListInstance = clModList.getDeclaredMethod(MixinPlatformAgentMinecraftForge.GET_MOD_LIST_METHOD);
activity = "Resolving FML LoadingModList::getModFiles method";
Method mdGetModFiles = clModList.getDeclaredMethod(MixinPlatformAgentMinecraftForge.GET_MOD_FILES_METHOD);
activity = "Resolving FML ModFileInfo::getFile method";
Method mdGetModFile = clModFileInfo.getDeclaredMethod(MixinPlatformAgentMinecraftForge.GET_MOD_FILE_METHOD);
activity = "Resolving FML ModFile::getFilePath method";
Method mdGetFilePath = clModFile.getDeclaredMethod(MixinPlatformAgentMinecraftForge.GET_FILE_PATH_METHOD);
activity = "Calling FML LoadingModList::get method to obtain LoadingModList singleton";
Object loadingModList = mdGetModListInstance.invoke(null);
activity = "Calling FML LoadingModList::getModFiles method to obtain list of mod candidates";
List<?> modlist = (List<?>)mdGetModFiles.invoke(loadingModList);
for (Object modFileInfo : modlist) {
activity = "Calling ModFileInfo::getFile method to obtain mod file info";
Object modFile = mdGetModFile.invoke(modFileInfo);
activity = "Calling ModFile::getFilePath method to obtain mod file location";
Path path = (Path)mdGetFilePath.invoke(modFile);
activity = "Creating ContainerHandleURI instance to contain FML mod: " + path;
this.rootContainer.add(new ContainerHandleURI(path.toUri()));
}
} catch (Exception ex) {
MixinPlatformAgentAbstract.logger.error("Error reading FML mod list contents during activity: {}", activity);
MixinPlatformAgentAbstract.logger.catching(ex);
}
}
/* (non-Javadoc)
@@ -142,10 +81,7 @@ public class MixinPlatformAgentMinecraftForge extends MixinPlatformAgentAbstract
*/
@Override
public Collection<IContainerHandle> getMixinContainers() {
if (this.rootContainer == null) {
this.rootContainer = new ContainerHandleVirtual("forge");
}
return ImmutableSet.<IContainerHandle>of(this.rootContainer);
return null;
}
}
@@ -24,15 +24,69 @@
*/
package org.spongepowered.asm.launch.platform.container;
import java.nio.file.Path;
import java.util.List;
import java.util.Map.Entry;
/**
* ModLauncher root container
*/
public class ContainerHandleModLauncher extends ContainerHandleVirtual {
/**
* Container handle for resources offered by ModLauncher
*/
public class Resource extends ContainerHandleURI {
private String name;
private Path path;
public Resource(String name, Path path) {
super(path.toUri());
this.name = name;
this.path = path;
}
public String getName() {
return this.name;
}
public Path getPath() {
return this.path;
}
@Override
public String toString() {
return String.format("ContainerHandleModLauncher.Resource(%s:%s)", this.name, this.path);
}
}
public ContainerHandleModLauncher(String name) {
super(name);
}
/**
* Add a resource to to this container
*
* @param name Resource name
* @param path Resource path
*/
public void addResource(String name, Path path) {
this.add(new Resource(name, path));
}
/**
* Add a collection of resources to this container
*
* @param resources Resources to add
*/
public void addResources(List<Entry<String, Path>> resources) {
for (Entry<String, Path> resource : resources) {
this.addResource(resource.getKey(), resource.getValue());
}
}
@Override
public String toString() {
return String.format("ModLauncher Root Container(%x)", this.hashCode());
@@ -60,10 +60,10 @@ public class MixinTransformationHandler implements IClassProcessor {
/* (non-Javadoc)
* @see org.spongepowered.asm.launch.IClassProcessor#handlesClass(
* org.objectweb.asm.Type, boolean)
* org.objectweb.asm.Type, boolean, java.lang.String)
*/
@Override
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty, String reason) {
if (!isEmpty) {
return Phases.AFTER_ONLY;
}
@@ -77,13 +77,13 @@ public class MixinTransformationHandler implements IClassProcessor {
}
/* (non-Javadoc)
* @see org.spongepowered.asm.launch.IClassProcessor
* #processClass(
* @see org.spongepowered.asm.launch.IClassProcessor#processClass(
* cpw.mods.modlauncher.serviceapi.ILaunchPluginService.Phase,
* org.objectweb.asm.tree.ClassNode, org.objectweb.asm.Type)
* org.objectweb.asm.tree.ClassNode, org.objectweb.asm.Type,
* java.lang.String)
*/
@Override
public synchronized boolean processClass(Phase phase, ClassNode classNode, Type classType) {
public synchronized boolean processClass(Phase phase, ClassNode classNode, Type classType, String reason) {
if (phase == Phase.BEFORE) {
return false;
}
@@ -1,305 +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.service.modlauncher;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.jar.Manifest;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.appender.AbstractAppender;
import cpw.mods.modlauncher.ClassTransformer;
import cpw.mods.modlauncher.Launcher;
import cpw.mods.modlauncher.TransformingClassLoader;
/**
* Shim for accessing resources inside modlauncher that Mixin needs to operate.
* Ideally in the long run facilities can be provided directly within
* modlauncher to make this shim unnecessary.
*/
class Internals {
/**
* Temporary
*/
static class MixinAppender extends AbstractAppender {
private final List<Runnable> startupListeners = new ArrayList<Runnable>();
MixinAppender() {
super("MixinLogWatcherAppender", null, null);
this.start();
}
void addListener(Runnable listener) {
synchronized (this.startupListeners) {
this.startupListeners.add(listener);
}
}
@Override
public void append(LogEvent event) {
if (event.getLevel() != Level.INFO || !event.getMessage().getFormat().startsWith("Launching target '")) {
return;
}
// transition to DEFAULT
synchronized (this.startupListeners) {
for (Runnable listener : this.startupListeners) {
listener.run();
}
}
}
}
/**
* Logger
*/
private static final Logger logger = LogManager.getLogger("mixin");
private static MixinAppender appender;
private static org.apache.logging.log4j.core.Logger launcherLogger;
private static Internals instance;
private static final String FD_CLASSLOADER = "classLoader";
private static final String FD_CLASSTRANSFORMER = "classTransformer";
private static final String FD_MANIFESTFINDER = "manifestFinder";
private static final String FD_CLASSBYTESFINDER = "classBytesFinder";
private static final String MD_TRANSFORM = "transform";
// private static final String MD_LOADCLASS = "loadClass";
private TransformingClassLoader transformingClassLoader;
private ClassTransformer classTransformer;
private Function<URLConnection, Manifest> manifestFinder;
private Function<String, URL> classBytesFinder;
// private Method mdLoadClass;
private Method mdTransform;
TransformingClassLoader getTransformingClassLoader() {
if (this.transformingClassLoader == null) {
this.transformingClassLoader = Internals.<Launcher, TransformingClassLoader>getField(Launcher.class, Launcher.INSTANCE,
Internals.FD_CLASSLOADER);
}
return this.transformingClassLoader;
}
ClassTransformer getClassTransformer() {
if (this.classTransformer == null) {
this.classTransformer = Internals.<TransformingClassLoader, ClassTransformer>getField(TransformingClassLoader.class,
this.getTransformingClassLoader(), Internals.FD_CLASSTRANSFORMER);
}
return this.classTransformer;
}
Function<URLConnection, Manifest> getManifestFinder() {
if (this.manifestFinder == null) {
this.manifestFinder = Internals.<TransformingClassLoader, Function<URLConnection, Manifest>>getField(TransformingClassLoader.class,
this.getTransformingClassLoader(), Internals.FD_MANIFESTFINDER);
}
return this.manifestFinder;
}
Function<String, URL> getClassBytesFinder() {
if (this.classBytesFinder == null) {
this.classBytesFinder = Internals.<TransformingClassLoader, Function<String, URL>>getField(TransformingClassLoader.class,
this.getTransformingClassLoader(), Internals.FD_CLASSBYTESFINDER);
}
return this.classBytesFinder;
}
// /**
// * Invokes 'loadClass' on the Transforming classloader
// *
// * @param name class name to load
// * @param resolve If <tt>true</tt> then resolve the class
// * @return loaded class
// * @throws ClassNotFoundException propagated
// */
// public Class<?> findClass(String name, boolean resolve) throws ClassNotFoundException {
// if (this.mdLoadClass == null) {
// this.mdLoadClass = Internals.getMethod(TransformingClassLoader.class, Internals.MD_LOADCLASS);
// }
// if (this.mdLoadClass != null) {
// try {
// return (Class<?>)this.mdLoadClass.invoke(this.getTransformingClassLoader(), name, resolve);
// } catch (ReflectiveOperationException ex) {
// ex.printStackTrace();
// }
// }
// return Class.forName("name");
// }
byte[] simulateClassLoad(String name, boolean runTransformers) throws ClassNotFoundException {
Function<String, URL> classBytesFinder = this.getClassBytesFinder();
final String path = name.replace('.', '/').concat(".class");
final URL classResource = classBytesFinder.apply(path);
byte[] classBytes;
if (classResource != null) {
try (AutoURLConnection urlConnection = new AutoURLConnection(classResource, this.getManifestFinder())) {
final int length = urlConnection.getContentLength();
final InputStream is = urlConnection.getInputStream();
classBytes = new byte[length];
int pos = 0, remain = length, read;
while ((read = is.read(classBytes, pos, remain)) != -1 && remain > 0) {
pos += read;
remain -= read;
}
@SuppressWarnings("unused")
Manifest jarManifest = urlConnection.getJarManifest();
} catch (IOException e) {
throw new ClassNotFoundException("Failed to find class bytes for " + name, e);
}
} else {
classBytes = new byte[0];
}
return this.transform(classBytes, name);
}
/**
* Copied directly from ModLauncher, ideally won't be necessary in the long
* run
*/
static class AutoURLConnection implements AutoCloseable {
private final URLConnection urlConnection;
private final InputStream inputStream;
private final Function<URLConnection, Manifest> manifestFinder;
AutoURLConnection(URL url, Function<URLConnection, Manifest> manifestFinder) throws IOException {
this.urlConnection = url.openConnection();
this.inputStream = this.urlConnection.getInputStream();
this.manifestFinder = manifestFinder;
}
@Override
public void close() throws IOException {
this.inputStream.close();
}
int getContentLength() {
return this.urlConnection.getContentLength();
}
InputStream getInputStream() {
return this.inputStream;
}
Manifest getJarManifest() {
return this.manifestFinder.apply(this.urlConnection);
}
}
private byte[] transform(byte[] inputClass, String className) {
if (this.mdTransform == null) {
this.mdTransform = Internals.getMethod(ClassTransformer.class, Internals.MD_TRANSFORM, byte[].class, String.class);
}
if (this.mdTransform == null) {
return inputClass;
}
try {
return (byte[])this.mdTransform.invoke(this.getClassTransformer(), inputClass, className);
} catch (InvocationTargetException ex) {
Throwable cause = ex.getCause();
if (cause instanceof RuntimeException) {
throw (RuntimeException)cause;
}
throw new RuntimeException(cause);
} catch (ReflectiveOperationException ex) {
Internals.logger.catching(ex);
}
return inputClass;
}
@SuppressWarnings("unchecked")
private static <C, T> T getField(Class<C> clazz, C instance, String fieldName) {
try {
Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
return (T)field.get(instance);
} catch (Exception ex) {
// ex.printStackTrace();
}
return null;
}
private static Method getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
try {
Method method = clazz.getDeclaredMethod(methodName, parameterTypes);
method.setAccessible(true);
return method;
} catch (Exception ex) {
// ex.printStackTrace();
}
return null;
}
void registerStartupListener(Runnable listener) {
if (Internals.appender == null) {
Logger launcherLog = LogManager.getLogger("cpw.mods.modlauncher.LaunchServiceHandler");
if (!(launcherLog instanceof org.apache.logging.log4j.core.Logger)) {
return;
}
Internals.appender = new MixinAppender();
Internals.launcherLogger = (org.apache.logging.log4j.core.Logger)launcherLog;
Internals.launcherLogger.addAppender(Internals.appender);
}
Internals.appender.addListener(listener);
}
void destroyLogWatcher() {
if (Internals.launcherLogger != null) {
Internals.launcherLogger.removeAppender(Internals.appender);
}
}
static synchronized Internals getInstance() {
if (Internals.instance == null) {
Internals.instance = new Internals();
}
return Internals.instance;
}
}
@@ -26,27 +26,21 @@ package org.spongepowered.asm.service.modlauncher;
import java.io.InputStream;
import java.util.Collection;
import java.util.Iterator;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import org.spongepowered.asm.launch.IClassProcessor;
import org.spongepowered.asm.launch.platform.container.ContainerHandleModLauncher;
import org.spongepowered.asm.launch.platform.container.IContainerHandle;
import org.spongepowered.asm.mixin.MixinEnvironment.CompatibilityLevel;
import org.spongepowered.asm.mixin.MixinEnvironment.Phase;
import org.spongepowered.asm.mixin.transformer.MixinTransformationHandler;
import org.spongepowered.asm.service.IClassBytecodeProvider;
import org.spongepowered.asm.service.IClassProvider;
import org.spongepowered.asm.service.ITransformer;
import org.spongepowered.asm.service.MixinServiceAbstract;
import org.spongepowered.asm.service.modlauncher.ext.IModLauncherClassBytecodeProvider;
import org.spongepowered.asm.service.modlauncher.ext.IModLauncherClassProvider;
import org.spongepowered.asm.util.IConsumer;
import com.google.common.collect.ImmutableList;
import cpw.mods.modlauncher.Launcher;
import cpw.mods.modlauncher.TransformingClassLoader;
import cpw.mods.modlauncher.api.ITransformationService;
/**
@@ -57,17 +51,17 @@ public class MixinServiceModLauncher extends MixinServiceAbstract {
/**
* Specification version to check for at startup
*/
private static final String MODLAUNCHER_SPECIFICATION_VERSION = "1.0";
private static final String MODLAUNCHER_SPECIFICATION_VERSION = "4.0";
/**
* Class provider, either uses hacky internals or provided service
*/
private IModLauncherClassProvider classProvider;
private IClassProvider classProvider;
/**
* Bytecode provider, either uses hacky internals or provided service
*/
private IModLauncherClassBytecodeProvider bytecodeProvider;
private IClassBytecodeProvider bytecodeProvider;
/**
* Container for the mixin pipeline which is called by the launch plugin
@@ -88,25 +82,29 @@ public class MixinServiceModLauncher extends MixinServiceAbstract {
* Only allow onInit to be called once
*/
private volatile boolean initialised;
/**
* Root container
*/
private ContainerHandleModLauncher rootContainer = new ContainerHandleModLauncher(this.getName());
/**
* Begin init
*
* @param startupListener Lifecyle listener
* @param bytecodeProvider bytecode provider
*/
public void onInit(Runnable startupListener) {
public void onInit(IClassBytecodeProvider bytecodeProvider) {
if (this.initialised) {
throw new IllegalStateException("Already initialised");
}
this.initialised = true;
Internals.getInstance().registerStartupListener(startupListener);
Internals.getInstance().registerStartupListener(MixinServiceModLauncher.this::onStartup);
this.bytecodeProvider = bytecodeProvider;
}
/**
* Lifecycle event
*/
private void onStartup() {
public void onStartup() {
this.phaseConsumer.accept(Phase.DEFAULT);
}
@@ -125,6 +123,15 @@ public class MixinServiceModLauncher extends MixinServiceAbstract {
public String getName() {
return "ModLauncher";
}
/* (non-Javadoc)
* @see org.spongepowered.asm.service.IMixinService
* #getMinCompatibilityLevel()
*/
@Override
public CompatibilityLevel getMinCompatibilityLevel() {
return CompatibilityLevel.JAVA_8;
}
/* (non-Javadoc)
* @see org.spongepowered.asm.service.IMixinService#isValid()
@@ -149,7 +156,7 @@ public class MixinServiceModLauncher extends MixinServiceAbstract {
@Override
public IClassProvider getClassProvider() {
if (this.classProvider == null) {
this.classProvider = MixinServiceModLauncher.createClassProvider();
this.classProvider = new ModLauncherClassProvider();
}
return this.classProvider;
}
@@ -160,7 +167,7 @@ public class MixinServiceModLauncher extends MixinServiceAbstract {
@Override
public IClassBytecodeProvider getBytecodeProvider() {
if (this.bytecodeProvider == null) {
this.bytecodeProvider = MixinServiceModLauncher.createBytecodeProvider();
throw new IllegalStateException("Service initialisation incomplete");
}
return this.bytecodeProvider;
}
@@ -199,8 +206,8 @@ public class MixinServiceModLauncher extends MixinServiceAbstract {
* @see org.spongepowered.asm.service.IMixinService#getPrimaryContainer()
*/
@Override
public IContainerHandle getPrimaryContainer() {
return new ContainerHandleModLauncher(this.getName());
public ContainerHandleModLauncher getPrimaryContainer() {
return this.rootContainer;
}
/* (non-Javadoc)
@@ -209,12 +216,6 @@ public class MixinServiceModLauncher extends MixinServiceAbstract {
*/
@Override
public InputStream getResourceAsStream(String name) {
TransformingClassLoader tcl = Internals.getInstance().getTransformingClassLoader();
if (tcl != null) {
return tcl.getResourceAsStream(name);
}
// Probably not what we want :/
return Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
}
@@ -282,28 +283,4 @@ public class MixinServiceModLauncher extends MixinServiceAbstract {
);
}
private static IModLauncherClassProvider createClassProvider() {
IModLauncherClassProvider service =
MixinServiceModLauncher.<IModLauncherClassProvider>loadFirstAvailableService(IModLauncherClassProvider.class);
return service != null ? service : new ModLauncherClassProvider();
}
private static IModLauncherClassBytecodeProvider createBytecodeProvider() {
IModLauncherClassBytecodeProvider service =
MixinServiceModLauncher.<IModLauncherClassBytecodeProvider>loadFirstAvailableService(IModLauncherClassBytecodeProvider.class);
return service != null ? service : new ModLauncherBytecodeProvider();
}
private static <TService> TService loadFirstAvailableService(Class<TService> serviceClass) {
Iterator<TService> loader = ServiceLoader.<TService>load(serviceClass).iterator();
if (loader.hasNext()) {
try {
return loader.next();
} catch (ServiceConfigurationError ex) {
ex.printStackTrace();
}
}
return null;
}
}
@@ -1,159 +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.service.modlauncher;
import java.io.IOException;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.launch.IClassInterceptor;
import org.spongepowered.asm.service.modlauncher.ext.IModLauncherClassBytecodeProvider;
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService.Phase;
/**
* Bytecode provider for ModLauncher environment.
*/
class ModLauncherBytecodeProvider implements IModLauncherClassBytecodeProvider, IClassInterceptor {
/**
* Exception thrown by the interceptor to terminate the transformation
* pipeline once we have obtained a ClassNode in the state we want it.
*/
static class CaptureException extends RuntimeException {
private static final long serialVersionUID = 1L;
ClassNode captured;
CaptureException(ClassNode captured) {
this.captured = captured;
}
}
/**
* Filthy hacks
*/
private final Internals internals = Internals.getInstance();
/**
* Class names we want to capture
*/
private final Map<String, Phase> captures = new HashMap<String, Phase>();
/**
* Classes which are initially empty
*/
private final Set<String> emptyClasses = new HashSet<String>();
ModLauncherBytecodeProvider() {
}
/* (non-Javadoc)
* @see org.spongepowered.asm.service.IClassBytecodeProvider#getClassNode(
* java.lang.String)
*/
@Override
public synchronized ClassNode getClassNode(String name) throws ClassNotFoundException, IOException {
return this.getClassNode(name, true, true);
}
@Override
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
synchronized (this.captures) {
String internalName = classType.getInternalName();
Phase capturePhase = this.captures.get(internalName);
if (capturePhase != null) {
if (isEmpty) {
this.emptyClasses.add(internalName);
}
return EnumSet.<Phase>of(capturePhase);
}
}
return null;
}
@Override
public boolean processClass(Phase phase, ClassNode classNode, Type classType) {
synchronized (this.captures) {
Phase capturePhase = this.captures.get(classType.getInternalName());
if (capturePhase != null && phase == capturePhase) {
throw new CaptureException(classNode);
}
}
return false;
}
/* (non-Javadoc)
* @see org.spongepowered.asm.service.IClassBytecodeProvider#getClassNode(
* java.lang.String, boolean)
*/
@Override
public synchronized ClassNode getClassNode(String name, boolean runTransformers) throws ClassNotFoundException, IOException {
return this.getClassNode(name, runTransformers, false);
}
private synchronized ClassNode getClassNode(String name, boolean runTransformers, boolean ignoreEmpty)
throws ClassNotFoundException {
String internalName = name.replace('.', '/');
synchronized (this.captures) {
this.emptyClasses.remove(internalName);
this.captures.put(internalName, runTransformers ? Phase.AFTER : Phase.BEFORE);
}
ClassNode captured = null;
try {
this.internals.simulateClassLoad(name, runTransformers);
} catch (CaptureException ex) {
captured = ex.captured;
synchronized (this.captures) {
if (this.emptyClasses.contains(internalName)) {
if (!ignoreEmpty) {
throw new ClassNotFoundException(name);
}
}
}
} finally {
synchronized (this.captures) {
this.captures.remove(internalName);
}
}
if (captured == null) {
throw new ClassNotFoundException("Unable to obtain ClassNode for: " + name);
}
return captured;
}
}
@@ -26,21 +26,15 @@ package org.spongepowered.asm.service.modlauncher;
import java.net.URL;
import org.spongepowered.asm.service.modlauncher.ext.IModLauncherClassProvider;
import org.spongepowered.asm.service.IClassProvider;
import cpw.mods.gross.Java9ClassLoaderUtil;
import cpw.mods.modlauncher.Launcher;
import cpw.mods.modlauncher.TransformingClassLoader;
/**
* Class provider for use under ModLauncher
*/
class ModLauncherClassProvider implements IModLauncherClassProvider {
/**
* Here be dragons
*/
private final Internals internals = Internals.getInstance();
class ModLauncherClassProvider implements IClassProvider {
ModLauncherClassProvider() {
}
@@ -60,7 +54,7 @@ class ModLauncherClassProvider implements IModLauncherClassProvider {
*/
@Override
public Class<?> findClass(String name) throws ClassNotFoundException {
return Class.forName(name, true, this.getClassLoader());
return Class.forName(name, true, Thread.currentThread().getContextClassLoader());
}
/* (non-Javadoc)
@@ -69,12 +63,7 @@ class ModLauncherClassProvider implements IModLauncherClassProvider {
*/
@Override
public Class<?> findClass(String name, boolean initialize) throws ClassNotFoundException {
return Class.forName(name, initialize, this.getClassLoader());
}
private ClassLoader getClassLoader() {
TransformingClassLoader tcl = this.internals.getTransformingClassLoader();
return tcl != null ? tcl : Launcher.class.getClassLoader();
return Class.forName(name, initialize, Thread.currentThread().getContextClassLoader());
}
/* (non-Javadoc)
@@ -64,10 +64,10 @@ public class ModLauncherClassTracker implements IClassProcessor {
/* (non-Javadoc)
* @see org.spongepowered.asm.launch.IClassProcessor#handlesClass(
* org.objectweb.asm.Type, boolean)
* org.objectweb.asm.Type, boolean, java.lang.String)
*/
@Override
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty, String reason) {
String name = classType.getClassName();
synchronized (this.invalidClasses) {
if (this.invalidClasses.contains(name)) {
@@ -85,10 +85,11 @@ public class ModLauncherClassTracker implements IClassProcessor {
/* (non-Javadoc)
* @see org.spongepowered.asm.launch.IClassProcessor#processClass(
* cpw.mods.modlauncher.serviceapi.ILaunchPluginService.Phase,
* org.objectweb.asm.tree.ClassNode, org.objectweb.asm.Type)
* org.objectweb.asm.tree.ClassNode, org.objectweb.asm.Type,
* java.lang.String)
*/
@Override
public boolean processClass(Phase phase, ClassNode classNode, Type classType) {
public boolean processClass(Phase phase, ClassNode classNode, Type classType, String reason) {
return false;
}
@@ -1,34 +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.service.modlauncher.ext;
import org.spongepowered.asm.service.IClassBytecodeProvider;
/**
* Service-loadable interface for modlauncher class bytecode provider
*/
public interface IModLauncherClassBytecodeProvider extends IClassBytecodeProvider {
}
@@ -1,34 +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.service.modlauncher.ext;
import org.spongepowered.asm.service.IClassProvider;
/**
* Service-loadable interface for modlauncher class provider
*/
public interface IModLauncherClassProvider extends IClassProvider {
}