Package com.jogamp.common.util
Class ReflectionUtil
- java.lang.Object
-
- com.jogamp.common.util.ReflectionUtil
-
public final class ReflectionUtil extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReflectionUtil.AWTNamesstatic classReflectionUtil.MethodAccessorConvenient Method access class
-
Field Summary
Fields Modifier and Type Field Description static booleanDEBUGstatic booleanDEBUG_STATS_FORNAME
-
Constructor Summary
Constructors Constructor Description ReflectionUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectcallMethod(Object instance, Method method, Object... args)static ObjectcallStaticMethod(String clazzName, String methodName, Class<?>[] argTypes, Object[] args, ClassLoader cl)static ObjectcreateInstance(Class<?> clazz, Class<?>[] cstrArgTypes, Object... cstrArgs)static ObjectcreateInstance(Class<?> clazz, Object... cstrArgs)static ObjectcreateInstance(Constructor<?> cstr, Object... cstrArgs)static ObjectcreateInstance(String clazzName, Class<?>[] cstrArgTypes, Object[] cstrArgs, ClassLoader cl)static ObjectcreateInstance(String clazzName, ClassLoader cl)static ObjectcreateInstance(String clazzName, Object[] cstrArgs, ClassLoader cl)static Class<?>getClass(String clazzName, boolean initializeClazz, 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, boolean initializeClazz, ClassLoader cl)static Constructor<?>getConstructor(String clazzName, ClassLoader cl)static StringBuildergetForNameStats(StringBuilder sb)static MethodgetMethod(Class<?> clazz, String methodName, Class<?>... argTypes)static MethodgetMethod(String clazzName, String methodName, Class<?>[] argTypes, ClassLoader cl)static booleanimplementationOf(Class<?> clazz, String faceName)static booleanimplementationOf(Object obj, String faceName)static booleaninstanceOf(Class<?> clazz, String clazzName)static booleaninstanceOf(Object obj, String clazzName)static booleanisAWTComponent(Class<?> clazz)static booleanisAWTComponent(Object target)static booleanisClassAvailable(String clazzName, ClassLoader cl)Returns true only if the class could be loaded.static voidresetForNameCount()
-
-
-
Method Detail
-
resetForNameCount
public static void resetForNameCount()
-
getForNameStats
public static StringBuilder getForNameStats(StringBuilder sb)
-
isClassAvailable
public static final boolean isClassAvailable(String clazzName, ClassLoader cl)
Returns true only if the class could be loaded.
-
getClass
public static final Class<?> getClass(String clazzName, boolean initializeClazz, ClassLoader cl) throws JogampRuntimeException
Loads and returns the class or null.
-
getConstructor
public static final Constructor<?> getConstructor(String clazzName, Class<?>[] cstrArgTypes, boolean initializeClazz, ClassLoader cl) throws JogampRuntimeException
- Parameters:
initializeClazz- TODO- Throws:
JogampRuntimeException- if the constructor can not be delivered.
-
getConstructor
public static final Constructor<?> getConstructor(Class<?> clazz, Class<?>... cstrArgTypes) throws JogampRuntimeException
Returns a compatible constructor if available, otherwise throws an exception.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 givencstrArgs.- Throws:
JogampRuntimeException- if the constructor can not be delivered.
-
getConstructor
public static final Constructor<?> getConstructor(String clazzName, ClassLoader cl) throws JogampRuntimeException
- Throws:
JogampRuntimeException
-
createInstance
public static final Object createInstance(Constructor<?> cstr, Object... cstrArgs) throws JogampRuntimeException, RuntimeException
- Throws:
JogampRuntimeException- if the instance can not be created.RuntimeException
-
createInstance
public static final Object createInstance(Class<?> clazz, Class<?>[] cstrArgTypes, Object... cstrArgs) throws JogampRuntimeException, RuntimeException
- Throws:
JogampRuntimeException- if the instance can not be created.RuntimeException
-
createInstance
public static final Object createInstance(Class<?> clazz, Object... cstrArgs) throws JogampRuntimeException, RuntimeException
-
createInstance
public static final Object createInstance(String clazzName, Class<?>[] cstrArgTypes, Object[] cstrArgs, ClassLoader cl) throws JogampRuntimeException, RuntimeException
-
createInstance
public static final Object createInstance(String clazzName, Object[] cstrArgs, ClassLoader cl) throws JogampRuntimeException, RuntimeException
-
createInstance
public static final Object createInstance(String clazzName, ClassLoader cl) throws JogampRuntimeException, RuntimeException
-
isAWTComponent
public static boolean isAWTComponent(Object target)
-
isAWTComponent
public static boolean isAWTComponent(Class<?> clazz)
-
getMethod
public static final Method getMethod(Class<?> clazz, String methodName, Class<?>... argTypes) throws JogampRuntimeException, RuntimeException
- Throws:
JogampRuntimeException- if the Method can not be found.RuntimeException
-
getMethod
public static final Method getMethod(String clazzName, String methodName, Class<?>[] argTypes, ClassLoader cl) throws JogampRuntimeException, RuntimeException
- Throws:
JogampRuntimeException- if the Method can not be found.RuntimeException
-
callMethod
public static final Object callMethod(Object instance, Method method, Object... args) throws JogampRuntimeException, RuntimeException
- Parameters:
instance- may be null in case of a static methodmethod- the method to be calledargs- the method arguments- Returns:
- the methods result, maybe null if void
- Throws:
JogampRuntimeException- if call failsRuntimeException- if call fails
-
callStaticMethod
public static final Object callStaticMethod(String clazzName, String methodName, Class<?>[] argTypes, Object[] args, ClassLoader cl) throws JogampRuntimeException, RuntimeException
- Throws:
JogampRuntimeException- if the instance can not be created.RuntimeException
-
-