public class ClassLoaderUtil extends Object
org.apache.commons.lang.ClassUtils
from
the Apache Commons Lang Component. Some adjustments made to remove dependency on
org.apache.commons.lang.StringUtils
. Also modified to fall back on the
current class loader when an attempt to load a class with the context class loader
results in a java.lang.ClassNotFoundException
.org.apache.commons.lang.ClassUtils
Constructor and Description |
---|
ClassLoaderUtil() |
Modifier and Type | Method and Description |
---|---|
static Class |
getClass(ClassLoader classLoader,
String className)
Returns the (initialized) class represented by
className
using the classLoader . |
static Class |
getClass(ClassLoader classLoader,
String className,
boolean initialize)
Returns the class represented by
className using the
classLoader . |
static Class |
getClass(String className)
Returns the (initialized) class represented by
className
using the current thread's context class loader. |
static Class |
getClass(String className,
boolean initialize)
Returns the class represented by
className using the
current thread's context class loader. |
public ClassLoaderUtil()
public static Class getClass(ClassLoader classLoader, String className, boolean initialize) throws ClassNotFoundException
className
using the
classLoader
. This implementation supports names like
"java.lang.String[]
" as well as "[Ljava.lang.String;
".classLoader
- the class loader to use to load the classclassName
- the class nameinitialize
- whether the class must be initializedclassName
using the classLoader
ClassNotFoundException
- if the class is not foundpublic static Class getClass(ClassLoader classLoader, String className) throws ClassNotFoundException
className
using the classLoader
. This implementation supports names
like "java.lang.String[]
" as well as
"[Ljava.lang.String;
".classLoader
- the class loader to use to load the classclassName
- the class nameclassName
using the classLoader
ClassNotFoundException
- if the class is not foundpublic static Class getClass(String className) throws ClassNotFoundException
className
using the current thread's context class loader. This implementation
supports names like "java.lang.String[]
" as well as
"[Ljava.lang.String;
".className
- the class nameclassName
using the current thread's context class loaderClassNotFoundException
- if the class is not foundpublic static Class getClass(String className, boolean initialize) throws ClassNotFoundException
className
using the
current thread's context class loader. This implementation supports
names like "java.lang.String[]
" as well as
"[Ljava.lang.String;
".className
- the class nameinitialize
- whether the class must be initializedclassName
using the current thread's context class loaderClassNotFoundException
- if the class is not foundCopyright © 2001–2015 The Apache Software Foundation. All rights reserved.