public class ClassLoaders
extends java.lang.Object
| Constructor and Description |
|---|
ClassLoaders() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addToSystemClassPath(java.net.URL url)
Add a URL to the system classpath.
|
static java.lang.Class<?> |
defineAnonymousClass(java.lang.Class<?> parent,
byte[] bytecode,
java.lang.String... flags)
Define an anonymous class.
|
static java.lang.Class<?> |
defineClass(java.lang.ClassLoader classLoader,
java.lang.String name,
byte[] bytecode)
Define a class using the given class loader.
|
static java.lang.Class<?> |
defineClass(java.lang.ClassLoader classLoader,
java.lang.String name,
byte[] bytecode,
int offset,
int length,
java.security.ProtectionDomain protectionDomain)
Define a class using the given class loader.
|
static java.lang.Class<?> |
defineClass(java.lang.ClassLoader classLoader,
java.lang.String name,
byte[] bytecode,
java.security.ProtectionDomain protectionDomain)
Define a class using the given class loader.
|
static java.net.URL[] |
getSystemClassPath()
Get all URLs of the system classpath.
|
static void |
loadToFront(java.net.URL url)
Load a URL into the context class loader and move it to the front of the classpath.
|
public static void addToSystemClassPath(java.net.URL url)
url - The URL to addpublic static java.net.URL[] getSystemClassPath()
public static void loadToFront(java.net.URL url)
url - The URL to loadpublic static java.lang.Class<?> defineClass(java.lang.ClassLoader classLoader,
java.lang.String name,
byte[] bytecode)
classLoader - The class loader to usename - The name of the classbytecode - The bytecode of the classpublic static java.lang.Class<?> defineClass(java.lang.ClassLoader classLoader,
java.lang.String name,
byte[] bytecode,
java.security.ProtectionDomain protectionDomain)
classLoader - The class loader to usename - The name of the classbytecode - The bytecode of the classprotectionDomain - The protection domain of the classpublic static java.lang.Class<?> defineClass(java.lang.ClassLoader classLoader,
java.lang.String name,
byte[] bytecode,
int offset,
int length,
java.security.ProtectionDomain protectionDomain)
classLoader - The class loader to usename - The name of the classbytecode - The bytecode of the classoffset - The offset of the class in the bytecodelength - The length of the class in the bytecodeprotectionDomain - The protection domain of the classpublic static java.lang.Class<?> defineAnonymousClass(java.lang.Class<?> parent,
byte[] bytecode,
java.lang.String... flags)
MethodHandles.Lookup#defineHiddenClass method is used. On older versions the Unsafe#defineAnonymousClass method is used.parent - The parent classbytecode - The bytecode of the classflags - The flags to use