@ParametersAreNonnullByDefault
public class InjectionClassLoader
extends java.net.URLClassLoader
| Constructor and Description |
|---|
InjectionClassLoader(TransformerManager transformerManager,
java.lang.ClassLoader parent,
java.net.URL... urls) |
InjectionClassLoader(TransformerManager transformerManager,
java.net.URL... urls) |
| Modifier and Type | Method and Description |
|---|---|
void |
addProtectedPackage(java.lang.String protectedPackage)
Add a protected package to prevent the classes from being transformed.
|
void |
addProtectionException(java.lang.String protectionException)
Add an exception to the protected packages.
|
void |
addRuntimeResource(java.lang.String path,
byte[] data)
Add a new resource to the classpath during runtime.
|
void |
addURL(java.net.URL url)
Add an url to the classpath.
|
void |
copyClass(IClassProvider classProvider,
java.lang.String className)
Copy a class to the runtime resources.
|
void |
copyResource(java.lang.ClassLoader classLoader,
java.lang.String path)
Copy a resource from a class loader to the runtime resources.
|
void |
executeMain(java.lang.String className,
java.lang.String methodName,
java.lang.String... args)
Execute the main method of the given class.
The only argument of the main method has to be a String[]. |
protected java.lang.Class<?> |
findClass(java.lang.String name) |
java.net.URL |
findResource(java.lang.String name) |
java.util.Enumeration<java.net.URL> |
findResources(java.lang.String name) |
java.net.URL |
getResource(java.lang.String name) |
TransformerManager |
getTransformerManager() |
boolean |
isProtected(java.lang.String className)
Check if the given class is protected and should not be transformed/loaded by this class loader.
|
protected java.lang.Class<?> |
loadClass(java.lang.String name,
boolean resolve) |
void |
setPriority(EnumLoaderPriority priority)
Set the priority of the load class method.
|
close, definePackage, getPermissions, getResourceAsStream, getURLs, newInstance, newInstanceclearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSignerspublic InjectionClassLoader(TransformerManager transformerManager, java.net.URL... urls)
public InjectionClassLoader(TransformerManager transformerManager, java.lang.ClassLoader parent, java.net.URL... urls)
protected java.lang.Class<?> loadClass(java.lang.String name,
boolean resolve)
throws java.lang.ClassNotFoundException
loadClass in class java.lang.ClassLoaderjava.lang.ClassNotFoundExceptionprotected java.lang.Class<?> findClass(java.lang.String name)
throws java.lang.ClassNotFoundException
findClass in class java.net.URLClassLoaderjava.lang.ClassNotFoundException@Nullable public java.net.URL getResource(java.lang.String name)
getResource in class java.lang.ClassLoader@Nullable public java.net.URL findResource(java.lang.String name)
findResource in class java.net.URLClassLoader@Nonnull public java.util.Enumeration<java.net.URL> findResources(java.lang.String name)
findResources in class java.net.URLClassLoaderpublic boolean isProtected(java.lang.String className)
className - The name of the class to checkpublic void addProtectedPackage(java.lang.String protectedPackage)
protectedPackage - The package to protectpublic void addProtectionException(java.lang.String protectionException)
protectionException - The package to addpublic TransformerManager getTransformerManager()
public void addURL(java.net.URL url)
addURL in class java.net.URLClassLoaderurl - The url to addpublic void addRuntimeResource(java.lang.String path,
byte[] data)
path - The path to the resourcedata - The data of the resourcepublic void copyResource(java.lang.ClassLoader classLoader,
java.lang.String path)
classLoader - The class loader to copy the resource frompath - The path to the resourcepublic void copyClass(IClassProvider classProvider, java.lang.String className)
classProvider - The class provider to get the bytecode fromclassName - The name of the class to copypublic void setPriority(EnumLoaderPriority priority)
priority - The priorityjava.lang.IllegalArgumentException - If the priority is set to EnumLoaderPriority.PARENT_FIRST and no parent class loader is setpublic void executeMain(java.lang.String className,
java.lang.String methodName,
java.lang.String... args)
throws java.lang.ClassNotFoundException,
java.lang.NoSuchMethodException,
java.lang.reflect.InvocationTargetException,
java.lang.IllegalAccessException
String[].className - The name of the class containing the main methodmethodName - The name of the main methodargs - The arguments to pass to the main methodjava.lang.ClassNotFoundException - If the class could not be foundjava.lang.NoSuchMethodException - If the main method could not be foundjava.lang.reflect.InvocationTargetException - If the main method throws an exceptionjava.lang.IllegalAccessException - If the main method could not be accessed