public class JkClassLoader
extends java.lang.Object
ClassLoader
providing convenient methods.Modifier and Type | Method and Description |
---|---|
java.util.List<java.lang.String> |
findClassesHavingMainMethod()
Returns all class names having a
main method. |
java.util.List<java.lang.String> |
findClassesMatchingAnnotations(java.util.function.Predicate<java.util.List<java.lang.String>> annotationNamePredicate)
Returns all classes matching the specified annotation predicate.
|
java.lang.ClassLoader |
get()
Return the
URLClassLoader wrapped by this object. |
JkPathSequence |
getClasspath()
Returns the classpath for this classloader excluding elements on the platform/system classloader.
|
<T> T |
instantiate(java.lang.String className)
Creates an instance of the class having the specified name in this class
loader.
|
boolean |
isDefined(java.lang.String className)
Returns if the specified class is defined in this
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> |
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() |
java.lang.String |
toString(int maxEntryCount) |
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 get()
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> T instantiate(java.lang.String className)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(int maxEntryCount)
public java.util.List<java.lang.String> findClassesHavingMainMethod()
main
method.public java.util.List<java.lang.String> findClassesMatchingAnnotations(java.util.function.Predicate<java.util.List<java.lang.String>> annotationNamePredicate)
public JkPathSequence getClasspath()