类 ClassHelper
- java.lang.Object
-
- com.alibaba.dubbo.common.utils.ClassHelper
-
public class ClassHelper extends Object
-
-
字段概要
字段 修饰符和类型 字段 说明 static String
ARRAY_SUFFIX
Suffix for array class names: "[]"
-
构造器概要
构造器 构造器 说明 ClassHelper()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static Class<?>
forName(String name)
Same asClass.forName()
, except that it works for primitive types.static Class<?>
forName(String name, ClassLoader classLoader)
Replacement forClass.forName()
that also returns Class instances for primitives (like "int") and array class names (like "String[]").static Class<?>
forNameWithCallerClassLoader(String name, Class<?> caller)
static Class<?>
forNameWithThreadContextClassLoader(String name)
static ClassLoader
getCallerClassLoader(Class<?> caller)
static ClassLoader
getClassLoader()
Return the default ClassLoader to use: typically the thread context ClassLoader, if available; the ClassLoader that loaded the ClassUtils class will be used as fallback.static ClassLoader
getClassLoader(Class<?> cls)
get class loaderstatic Class<?>
resolvePrimitiveClassName(String name)
Resolve the given class name as primitive class, if appropriate, according to the JVM's naming rules for primitive classes.static String
toShortString(Object obj)
-
-
-
方法详细资料
-
forNameWithThreadContextClassLoader
public static Class<?> forNameWithThreadContextClassLoader(String name) throws ClassNotFoundException
-
forNameWithCallerClassLoader
public static Class<?> forNameWithCallerClassLoader(String name, Class<?> caller) throws ClassNotFoundException
-
getCallerClassLoader
public static ClassLoader getCallerClassLoader(Class<?> caller)
-
getClassLoader
public static ClassLoader getClassLoader(Class<?> cls)
get class loader- 参数:
cls
-- 返回:
- class loader
-
getClassLoader
public static ClassLoader getClassLoader()
Return the default ClassLoader to use: typically the thread context ClassLoader, if available; the ClassLoader that loaded the ClassUtils class will be used as fallback.Call this method if you intend to use the thread context ClassLoader in a scenario where you absolutely need a non-null ClassLoader reference: for example, for class path resource loading (but not necessarily for
Class.forName
, which accepts anull
ClassLoader reference as well).- 返回:
- the default ClassLoader (never
null
) - 另请参阅:
Thread.getContextClassLoader()
-
forName
public static Class<?> forName(String name) throws ClassNotFoundException
Same asClass.forName()
, except that it works for primitive types.
-
forName
public static Class<?> forName(String name, ClassLoader classLoader) throws ClassNotFoundException, LinkageError
Replacement forClass.forName()
that also returns Class instances for primitives (like "int") and array class names (like "String[]").- 参数:
name
- the name of the ClassclassLoader
- the class loader to use (may benull
, which indicates the default class loader)- 返回:
- Class instance for the supplied name
- 抛出:
ClassNotFoundException
- if the class was not foundLinkageError
- if the class file could not be loaded- 另请参阅:
Class.forName(String, boolean, ClassLoader)
-
resolvePrimitiveClassName
public static Class<?> resolvePrimitiveClassName(String name)
Resolve the given class name as primitive class, if appropriate, according to the JVM's naming rules for primitive classes.Also supports the JVM's internal class names for primitive arrays. Does not support the "[]" suffix notation for primitive arrays; this is only supported by
forName(java.lang.String)
.- 参数:
name
- the name of the potentially primitive class- 返回:
- the primitive class, or
null
if the name does not denote a primitive class or primitive array class
-
-