public class JkClassLoader
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
<T> T |
createCrossClassloaderProxy(java.lang.Class<T> interfaze,
java.lang.String className,
java.lang.String staticMethodFactory,
java.lang.Object... args)
Creates an instance of the specified class in this classloader and
callable from the current thread classloader.
|
java.lang.ClassLoader |
getDelegate()
Return the
URLClassLoader wrapped by this object. |
<T> T |
instantiate(java.lang.String className)
Creates an instance of the class having the specified name in this class
loader.
|
<T> T |
invokeInstanceMethod(java.lang.ClassLoader from,
java.lang.Object object,
java.lang.reflect.Method method,
java.lang.Object... args)
Invoke instance method on specified object using this classloader as the curent context class loader.
|
<T> T |
invokeStaticMethod(boolean serializeResult,
java.lang.String className,
java.lang.String methodName,
java.lang.Object... args)
Invokes a static method on the specified class using the provided
arguments.
|
boolean |
isDefined(java.lang.String className)
Returns if the specified class is defined in this
classloader . |
boolean |
isDescendantOf(java.lang.ClassLoader classLoader)
Returns
true if this classloader is descendant or same as the specified classloader. |
<T> java.lang.Class<T> |
load(java.lang.String className)
Delegates the call to
ClassLoader.loadClass(String) of this
wrapped class loader .The specified class is supposed to be defined in this class loader, otherwise an IllegalArgumentException is thrown. |
<T> java.lang.Class<T> |
loadGivenClassSourcePath(java.lang.String classSourcePath)
Loads a class given its source relative path.
|
<T> java.lang.Class<T> |
loadGivenClassSourcePathIfExist(java.lang.String classSourcePath)
Loads a class given its source relative path if exists.
|
<T> java.lang.Class<T> |
loadIfExist(java.lang.String className)
Loads the class having the specified name or return
null if
no such class is defined in this classloader . |
static JkClassLoader |
of(java.lang.ClassLoader classLoader) |
static JkClassLoader |
ofCurrent()
Returns a
JkClassLoader wrapping the current thread context classloader. |
static JkClassLoader |
ofLoaderOf(java.lang.Class<?> clazz)
Returns a
JkClassLoader wrapping the class loader having loaded
the specified class. |
java.lang.String |
toString() |
public static JkClassLoader of(java.lang.ClassLoader classLoader)
public static JkClassLoader ofCurrent()
JkClassLoader
wrapping the current thread context classloader.public static JkClassLoader ofLoaderOf(java.lang.Class<?> clazz)
JkClassLoader
wrapping the class loader having loaded
the specified class.public java.lang.ClassLoader getDelegate()
URLClassLoader
wrapped by this object.public <T> java.lang.Class<T> load(java.lang.String className)
ClassLoader.loadClass(String)
of this
wrapped class loader
.IllegalArgumentException
is thrown.public boolean isDefined(java.lang.String className)
classloader
.public <T> java.lang.Class<T> loadIfExist(java.lang.String className)
null
if
no such class is defined in this classloader
.public <T> java.lang.Class<T> loadGivenClassSourcePath(java.lang.String classSourcePath)
loadGivenSourcePath("mypack1/subpack/MyClass.java")
will load the class mypack1.subpack.MyClass
.
public boolean isDescendantOf(java.lang.ClassLoader classLoader)
true
if this classloader is descendant or same as the specified classloader.public <T> T invokeStaticMethod(boolean serializeResult, java.lang.String className, java.lang.String methodName, java.lang.Object... args)
public <T> T instantiate(java.lang.String className)
public java.lang.String toString()
toString
in class java.lang.Object
public <T> T createCrossClassloaderProxy(java.lang.Class<T> interfaze, java.lang.String className, java.lang.String staticMethodFactory, java.lang.Object... args)
public <T> T invokeInstanceMethod(java.lang.ClassLoader from, java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... args)
from
- If not null
the result is transformed to be used in a specified classloader.public <T> java.lang.Class<T> loadGivenClassSourcePathIfExist(java.lang.String classSourcePath)
loadGivenSourcePath("mypack1/subpack/MyClass.java")
will load the class mypack1.subpack.MyClass
. Returns
null
if no such class exists.