public final class ClassUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
classToResourceName(Class<?> klass)
Get the resource path of the given class.
|
static String |
classToResourceName(String klass)
Convert the class name to '/' based resource path.
|
static ClassLoader |
getContextClassLoader()
Returns the context ClassLoader for this Thread.
|
static ClassLoader |
getDefaultClassLoader()
Returns the default ClassLoader.
|
static <T> Class<? super T> |
getRealClass(Class<T> proxyClass)
Get the real class of the given proxy class.
|
static URL |
getResource(String location)
Finds the resource from the class path with the given location using default ClassLoader.
|
static URL |
getURL(String location)
Resolve the given resource location to a
URL. |
static boolean |
isProxy(Object object)
Check whether the given object is a CGLIB or ByteBuddy proxy.
|
static boolean |
isProxyClass(Class<?> clazz)
Check whether the given class is a CGLIB or ByteBuddy proxy class, assuming no custom proxy
class naming is used.
|
static boolean |
isProxyClassName(String className)
Check whether the given class name is a CGLIB or ByteBuddy proxy class name, assuming no custom
class naming is used.
|
static String |
resourceToClassName(String resource)
Convert the '/' based resource path to '.' based class name.
|
static ClassLoader |
setContextClassLoader(ClassLoader classLoader)
Override the context ClassLoader of this Thread.
|
public static ClassLoader getContextClassLoader()
Thread.getContextClassLoader()public static ClassLoader setContextClassLoader(ClassLoader classLoader)
classLoader - the ClassLoader to override.public static ClassLoader getDefaultClassLoader()
Generally, it is current Thread context ClassLoader. If not available, it will be the
ClassLoader that loaded the ClassUtils.
public static String resourceToClassName(String resource)
resource - the resource pathpublic static String classToResourceName(String klass)
klass - the fully qualified class namepublic static String classToResourceName(Class<?> klass)
klass - the classpublic static boolean isProxy(Object object)
object - the object to checkpublic static boolean isProxyClass(Class<?> clazz)
clazz - the class to checkpublic static boolean isProxyClassName(String className)
className - the class name to checkpublic static <T> Class<? super T> getRealClass(Class<T> proxyClass)
proxyClass - the proxy class whose first real super class is required.public static URL getURL(String location) throws FileNotFoundException
URL.location - the resource location to resolve, either a pseudo 'classpath:' url, a 'file:'
url or plain resource location.URL objectFileNotFoundException - if location can't be resolved.public static URL getResource(String location)
location - The resource locationURL for reading the resource or nullgetDefaultClassLoader(),
ClassLoader.getResource(String)