mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-26 22:03:10 +00:00
Yet more internal service refactoring
This commit is contained in:
1 parent
0d4300980d
commit
039d1f6d0b
9 files changed
+126
-88
No files matched your search
@@ -212,7 +212,7 @@ public class MixinPlatformManager {
|
||||
* mixin tweaker in their manifest) and add agents for them
|
||||
*/
|
||||
private void scanClasspath() {
|
||||
URL[] sources = MixinService.getService().getClassPath();
|
||||
URL[] sources = MixinService.getService().getClassProvider().getClassPath();
|
||||
for (URL url : sources) {
|
||||
try {
|
||||
URI uri = url.toURI();
|
||||
|
||||
@@ -1673,7 +1673,7 @@ public final class ClassInfo {
|
||||
ClassInfo info = ClassInfo.cache.get(className);
|
||||
if (info == null) {
|
||||
try {
|
||||
ClassNode classNode = MixinService.getService().getClassNode(className);
|
||||
ClassNode classNode = MixinService.getService().getBytecodeProvider().getClassNode(className);
|
||||
info = new ClassInfo(classNode);
|
||||
} catch (Exception ex) {
|
||||
ClassInfo.logger.catching(Level.TRACE, ex);
|
||||
|
||||
@@ -120,7 +120,7 @@ final class InnerClassGenerator implements IClassGenerator {
|
||||
}
|
||||
|
||||
byte[] getClassBytes() throws ClassNotFoundException, IOException {
|
||||
return MixinService.getService().getClassBytes(this.originalName, true);
|
||||
return MixinService.getService().getBytecodeProvider().getClassBytes(this.originalName, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1158,7 +1158,7 @@ class MixinInfo implements Comparable<MixinInfo>, IMixinInfo {
|
||||
byte[] mixinBytes = null;
|
||||
|
||||
try {
|
||||
mixinBytes = this.service.getClassBytes(mixinClassName, runTransformers);
|
||||
mixinBytes = this.service.getBytecodeProvider().getClassBytes(mixinClassName, runTransformers);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
throw new ClassNotFoundException(String.format("The specified mixin '%s' was not found", mixinClassName));
|
||||
} catch (IOException ex) {
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
|
||||
/**
|
||||
* Interface for object which can provide class bytecode
|
||||
*/
|
||||
public interface IClassBytecodeProvider {
|
||||
|
||||
/**
|
||||
* Retrieve class bytes using available classloaders, does not transform the
|
||||
* class
|
||||
*
|
||||
* @param name class name
|
||||
* @param transformedName transformed class name
|
||||
* @return class bytes or null if not found
|
||||
* @throws IOException propagated
|
||||
*/
|
||||
public abstract byte[] getClassBytes(String name, String transformedName) throws IOException;
|
||||
|
||||
/**
|
||||
* Retrieve transformed class bytes by using available classloaders and
|
||||
* running transformer delegation chain on the result if the runTransformers
|
||||
* option is enabled
|
||||
*
|
||||
* @param name full class name
|
||||
* @param runTransformers true to run transformers on the loaded bytecode
|
||||
* @return transformed bytes
|
||||
* @throws ClassNotFoundException if class not found
|
||||
* @throws IOException propagated
|
||||
*/
|
||||
public abstract byte[] getClassBytes(String name, boolean runTransformers) throws ClassNotFoundException, IOException;
|
||||
|
||||
/**
|
||||
* Retrieve transformed class as an ASM tree
|
||||
*
|
||||
* @param name full class name
|
||||
* @return tree
|
||||
* @throws ClassNotFoundException if class not found
|
||||
* @throws IOException propagated
|
||||
*/
|
||||
public abstract ClassNode getClassNode(String name) throws ClassNotFoundException, IOException;
|
||||
|
||||
}
|
||||
@@ -24,10 +24,26 @@
|
||||
*/
|
||||
package org.spongepowered.asm.service;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Interface for marshal object which can retrieve classes from the environment
|
||||
*/
|
||||
public interface IClassProvider {
|
||||
|
||||
/**
|
||||
* Get the current classpath from the service classloader
|
||||
*/
|
||||
public abstract URL[] getClassPath();
|
||||
|
||||
/**
|
||||
* Find a class in the service classloader
|
||||
*
|
||||
* @param name class name
|
||||
* @return resultant class
|
||||
* @throws ClassNotFoundException if the class was not found
|
||||
*/
|
||||
public abstract Class<?> findClass(final String name) throws ClassNotFoundException;
|
||||
|
||||
/**
|
||||
* Marshal a call to <tt>Class.forName</tt> for a regular class
|
||||
|
||||
@@ -24,12 +24,9 @@
|
||||
*/
|
||||
package org.spongepowered.asm.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Phase;
|
||||
import org.spongepowered.asm.util.ReEntranceLock;
|
||||
|
||||
@@ -93,6 +90,11 @@ public interface IMixinService {
|
||||
*/
|
||||
public abstract IClassProvider getClassProvider();
|
||||
|
||||
/**
|
||||
* Return the class bytecode provider for this service
|
||||
*/
|
||||
public abstract IClassBytecodeProvider getBytecodeProvider();
|
||||
|
||||
/**
|
||||
* Get additional platform agents for this service
|
||||
*/
|
||||
@@ -108,15 +110,6 @@ public interface IMixinService {
|
||||
*/
|
||||
public abstract InputStream getResourceAsStream(String name);
|
||||
|
||||
/**
|
||||
* Find a class in the service classloader
|
||||
*
|
||||
* @param name class name
|
||||
* @return resultant class
|
||||
* @throws ClassNotFoundException if the class was not found
|
||||
*/
|
||||
public abstract Class<?> findClass(final String name) throws ClassNotFoundException;
|
||||
|
||||
/**
|
||||
* Register an invalid class with the service classloader
|
||||
*
|
||||
@@ -132,60 +125,12 @@ public interface IMixinService {
|
||||
* @return true if the class was already loaded
|
||||
*/
|
||||
public abstract boolean isClassLoaded(String className);
|
||||
|
||||
/**
|
||||
* Check whether the specified class is excluded in the service classloader
|
||||
*
|
||||
* @param name class name to check
|
||||
* @param transformedName transformed name to check
|
||||
* @return true if the class is excluded in the service classloader
|
||||
*/
|
||||
public abstract boolean isClassExcluded(String name, String transformedName);
|
||||
|
||||
/**
|
||||
* Get the current classpath from the service classloader
|
||||
*/
|
||||
public abstract URL[] getClassPath();
|
||||
|
||||
/**
|
||||
* Get currently available transformers in the environment
|
||||
*/
|
||||
public abstract Collection<ITransformer> getTransformers();
|
||||
|
||||
/**
|
||||
* Retrieve class bytes using available classloaders, does not transform the
|
||||
* class
|
||||
*
|
||||
* @param name class name
|
||||
* @param transformedName transformed class name
|
||||
* @return class bytes or null if not found
|
||||
* @throws IOException propagated
|
||||
*/
|
||||
public abstract byte[] getClassBytes(String name, String transformedName) throws IOException;
|
||||
|
||||
/**
|
||||
* Retrieve transformed class bytes by using available classloaders and
|
||||
* running transformer delegation chain on the result if the runTransformers
|
||||
* option is enabled
|
||||
*
|
||||
* @param name full class name
|
||||
* @param runTransformers true to run transformers on the loaded bytecode
|
||||
* @return transformed bytes
|
||||
* @throws ClassNotFoundException if class not found
|
||||
* @throws IOException propagated
|
||||
*/
|
||||
public abstract byte[] getClassBytes(String name, boolean runTransformers) throws ClassNotFoundException, IOException;
|
||||
|
||||
/**
|
||||
* Retrieve transformed class as an ASM tree
|
||||
*
|
||||
* @param name full class name
|
||||
* @return tree
|
||||
* @throws ClassNotFoundException if class not found
|
||||
* @throws IOException propagated
|
||||
*/
|
||||
public abstract ClassNode getClassNode(String name) throws ClassNotFoundException, IOException;
|
||||
|
||||
/**
|
||||
* Get the detected side name for this environment
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user