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)
Define an anonymous class
This is java version independent but in java 17+ the parent class is unused |
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
|
public static void addToSystemClassPath(java.net.URL url)
url - The URL to addpublic static java.net.URL[] getSystemClassPath()
public 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)
parent - The parent class (unused in java 17+)bytecode - The bytecode of the class