public final class ReflectionUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ReflectionUtil.AWTNames |
static class |
ReflectionUtil.MethodAccessor
Convenient Method access class
|
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
static boolean |
DEBUG_STATS_FORNAME |
Constructor and Description |
---|
ReflectionUtil() |
Modifier and Type | Method and Description |
---|---|
static Object |
callMethod(Object instance,
Method method,
Object... args) |
static Object |
callStaticMethod(String clazzName,
String methodName,
Class<?>[] argTypes,
Object[] args,
ClassLoader cl) |
static Object |
createInstance(Class<?> clazz,
Class<?>[] cstrArgTypes,
Object... cstrArgs) |
static Object |
createInstance(Class<?> clazz,
Object... cstrArgs) |
static Object |
createInstance(Constructor<?> cstr,
Object... cstrArgs) |
static Object |
createInstance(String clazzName,
Class<?>[] cstrArgTypes,
Object[] cstrArgs,
ClassLoader cl) |
static Object |
createInstance(String clazzName,
ClassLoader cl) |
static Object |
createInstance(String clazzName,
Object[] cstrArgs,
ClassLoader cl) |
static Class<?> |
getClass(String clazzName,
boolean initialize,
ClassLoader cl)
Loads and returns the class or null.
|
static Constructor<?> |
getConstructor(Class<?> clazz,
Class<?>... cstrArgTypes)
Returns a compatible constructor
if available, otherwise throws an exception.
|
static Constructor<?> |
getConstructor(String clazzName,
Class<?>[] cstrArgTypes,
ClassLoader cl) |
static Constructor<?> |
getConstructor(String clazzName,
ClassLoader cl) |
static StringBuilder |
getForNameStats(StringBuilder sb) |
static Method |
getMethod(Class<?> clazz,
String methodName,
Class<?>... argTypes) |
static Method |
getMethod(String clazzName,
String methodName,
Class<?>[] argTypes,
ClassLoader cl) |
static boolean |
implementationOf(Class<?> clazz,
String faceName) |
static boolean |
implementationOf(Object obj,
String faceName) |
static boolean |
instanceOf(Class<?> clazz,
String clazzName) |
static boolean |
instanceOf(Object obj,
String clazzName) |
static boolean |
isAWTComponent(Class<?> clazz) |
static boolean |
isAWTComponent(Object target) |
static boolean |
isClassAvailable(String clazzName,
ClassLoader cl)
Returns true only if the class could be loaded.
|
static void |
resetForNameCount() |
public static final boolean DEBUG
public static final boolean DEBUG_STATS_FORNAME
public static void resetForNameCount()
public static StringBuilder getForNameStats(StringBuilder sb)
public static final boolean isClassAvailable(String clazzName, ClassLoader cl)
public static final Class<?> getClass(String clazzName, boolean initialize, ClassLoader cl) throws JogampRuntimeException
public static final Constructor<?> getConstructor(String clazzName, Class<?>[] cstrArgTypes, ClassLoader cl) throws JogampRuntimeException
JogampRuntimeException
- if the constructor can not be delivered.public static final Constructor<?> getConstructor(Class<?> clazz, Class<?>... cstrArgTypes) throws JogampRuntimeException
It first attempts to get the specific Constructor
using the given cstrArgTypes
.
If this fails w/ NoSuchMethodException
, a compatible
Constructor is being looked-up w/ with parameter types assignable
from the given cstrArgs
.
JogampRuntimeException
- if the constructor can not be delivered.public static final Constructor<?> getConstructor(String clazzName, ClassLoader cl) throws JogampRuntimeException
JogampRuntimeException
public static final Object createInstance(Constructor<?> cstr, Object... cstrArgs) throws JogampRuntimeException, RuntimeException
JogampRuntimeException
- if the instance can not be created.RuntimeException
public static final Object createInstance(Class<?> clazz, Class<?>[] cstrArgTypes, Object... cstrArgs) throws JogampRuntimeException, RuntimeException
JogampRuntimeException
- if the instance can not be created.RuntimeException
public static final Object createInstance(Class<?> clazz, Object... cstrArgs) throws JogampRuntimeException, RuntimeException
public static final Object createInstance(String clazzName, Class<?>[] cstrArgTypes, Object[] cstrArgs, ClassLoader cl) throws JogampRuntimeException, RuntimeException
public static final Object createInstance(String clazzName, Object[] cstrArgs, ClassLoader cl) throws JogampRuntimeException, RuntimeException
public static final Object createInstance(String clazzName, ClassLoader cl) throws JogampRuntimeException, RuntimeException
public static boolean isAWTComponent(Object target)
public static boolean isAWTComponent(Class<?> clazz)
public static final Method getMethod(Class<?> clazz, String methodName, Class<?>... argTypes) throws JogampRuntimeException, RuntimeException
JogampRuntimeException
- if the Method can not be found.RuntimeException
public static final Method getMethod(String clazzName, String methodName, Class<?>[] argTypes, ClassLoader cl) throws JogampRuntimeException, RuntimeException
JogampRuntimeException
- if the Method can not be found.RuntimeException
public static final Object callMethod(Object instance, Method method, Object... args) throws JogampRuntimeException, RuntimeException
instance
- may be null in case of a static methodmethod
- the method to be calledargs
- the method argumentsJogampRuntimeException
- if call failsRuntimeException
- if call failspublic static final Object callStaticMethod(String clazzName, String methodName, Class<?>[] argTypes, Object[] args, ClassLoader cl) throws JogampRuntimeException, RuntimeException
JogampRuntimeException
- if the instance can not be created.RuntimeException