Class MinestomOverwriteClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
net.minestom.server.extras.selfmodification.MinestomOverwriteClassLoader
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class MinestomOverwriteClassLoader
extends java.net.URLClassLoader
Class Loader that can modify class bytecode when they are loaded
-
Field Summary
Fields Modifier and Type Field Description java.util.Set<java.lang.String>
protectedClasses
Classes that cannot be loaded/modified by this classloader.java.util.Set<java.lang.String>
protectedPackages
-
Method Summary
Modifier and Type Method Description void
addCodeModifier(CodeModifier modifier)
java.lang.Class<?>
findClass(java.lang.String name)
static MinestomOverwriteClassLoader
getInstance()
java.util.List<CodeModifier>
getModifiers()
byte[]
loadBytes(java.lang.String name, boolean transform)
Loads and possibly transforms class bytecode corresponding to the given binary name.java.lang.Class<?>
loadClass(java.lang.String name, boolean resolve)
void
loadModifier(java.io.File[] originFiles, java.lang.String codeModifierClass)
java.net.URLClassLoader
newChild(java.net.URL[] urls)
Methods inherited from class java.net.URLClassLoader
addURL, close, definePackage, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
Methods inherited from class java.lang.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, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Field Details
-
protectedClasses
public final java.util.Set<java.lang.String> protectedClassesClasses that cannot be loaded/modified by this classloader. Will go through parent class loader -
protectedPackages
public final java.util.Set<java.lang.String> protectedPackages
-
-
Method Details
-
getInstance
-
loadClass
public java.lang.Class<?> loadClass(java.lang.String name, boolean resolve) throws java.lang.ClassNotFoundException- Overrides:
loadClass
in classjava.lang.ClassLoader
- Throws:
java.lang.ClassNotFoundException
-
loadBytes
public byte[] loadBytes(java.lang.String name, boolean transform) throws java.io.IOException, java.lang.ClassNotFoundExceptionLoads and possibly transforms class bytecode corresponding to the given binary name.- Parameters:
name
-transform
-- Returns:
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
findClass
public java.lang.Class<?> findClass(java.lang.String name) throws java.lang.ClassNotFoundException- Overrides:
findClass
in classjava.net.URLClassLoader
- Throws:
java.lang.ClassNotFoundException
-
newChild
@NotNull public java.net.URLClassLoader newChild(@NotNull java.net.URL[] urls) -
loadModifier
public void loadModifier(java.io.File[] originFiles, java.lang.String codeModifierClass) -
addCodeModifier
-
getModifiers
-