Class StriderClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
dev.nozyx.strider.loader.api.StriderClassLoader
- All Implemented Interfaces:
Closeable, AutoCloseable
A class loader used by StriderLoader to load and transform game classes.
Classes outside the Minecraft and Mojang packages use the standard
parent-first class-loading strategy. Classes belonging to
net.minecraft or com.mojang are loaded using a child-first
strategy so they can be transformed before being defined by the JVM.
Classes loaded by this class loader can be processed by registered
class transformers before they are defined by
the JVM. Transformers are applied in the order in which they were
registered.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newStriderClassLoaderusing the current JVM classpath as its initial classpath.StriderClassLoader(URL[] urls, ClassLoader parent) Creates a newStriderClassLoaderwith the specified classpath and parent class loader. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTransformer(ClassTransformer transformer) Registers a class transformer.voidAdds a JAR file or directory to this class loader's classpath.protected Class<?> Class<?> Loads a class using the configured class-loading strategy.Class<?> Loads and optionally resolves a class.Methods inherited from class URLClassLoader
addURL, close, definePackage, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstanceMethods inherited from class SecureClassLoader
defineClass, defineClassMethods inherited from class ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
StriderClassLoader
@Internal public StriderClassLoader()Creates a newStriderClassLoaderusing the current JVM classpath as its initial classpath. -
StriderClassLoader
Creates a newStriderClassLoaderwith the specified classpath and parent class loader.- Parameters:
urls- the URLs from which classes and resources can be loadedparent- the parent class loader used for class loading
-
-
Method Details
-
loadClass
Loads a class using the configured class-loading strategy.- Overrides:
loadClassin classClassLoader- Parameters:
name- the fully qualified binary name of the class- Returns:
- the resulting
Classobject - Throws:
ClassNotFoundException- if the class cannot be found
-
loadClass
Loads and optionally resolves a class.Classes in
net.minecraftandcom.mojangare loaded child-first. All other classes are loaded parent-first.- Overrides:
loadClassin classClassLoader- Parameters:
name- the fully qualified binary name of the classresolve- whether the class should be resolved after loading- Returns:
- the resulting
Classobject - Throws:
ClassNotFoundException- if the class cannot be found
-
findClass
- Overrides:
findClassin classURLClassLoader- Throws:
ClassNotFoundException
-
addUrl
Adds a JAR file or directory to this class loader's classpath.- Parameters:
path- the JAR file or directory to add- Throws:
MalformedURLException- if the path cannot be converted to a URL
-
addTransformer
Registers a class transformer.- Parameters:
transformer- the transformer to register
-