com.jogamp.common.util
Class ReflectionUtil

java.lang.Object
  extended by com.jogamp.common.util.ReflectionUtil

public final class ReflectionUtil
extends Object


Field Summary
static boolean DEBUG
           
 
Constructor Summary
ReflectionUtil()
           
 
Method Summary
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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
Constructor Detail

ReflectionUtil

public ReflectionUtil()
Method Detail

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 initialize,
                                      ClassLoader cl)
                               throws JogampRuntimeException
Loads and returns the class or null.

Throws:
JogampRuntimeException
See Also:
Class.forName(java.lang.String, boolean, java.lang.ClassLoader)

getConstructor

public static final Constructor<?> getConstructor(String clazzName,
                                                  Class<?>[] cstrArgTypes,
                                                  ClassLoader cl)
                                           throws JogampRuntimeException
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 given cstrArgs.

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
Throws:
JogampRuntimeException
RuntimeException

createInstance

public static final Object createInstance(String clazzName,
                                          Class<?>[] cstrArgTypes,
                                          Object[] cstrArgs,
                                          ClassLoader cl)
                                   throws JogampRuntimeException,
                                          RuntimeException
Throws:
JogampRuntimeException
RuntimeException

createInstance

public static final Object createInstance(String clazzName,
                                          Object[] cstrArgs,
                                          ClassLoader cl)
                                   throws JogampRuntimeException,
                                          RuntimeException
Throws:
JogampRuntimeException
RuntimeException

createInstance

public static final Object createInstance(String clazzName,
                                          ClassLoader cl)
                                   throws JogampRuntimeException,
                                          RuntimeException
Throws:
JogampRuntimeException
RuntimeException

instanceOf

public static final boolean instanceOf(Object obj,
                                       String clazzName)

instanceOf

public static final boolean instanceOf(Class<?> clazz,
                                       String clazzName)

implementationOf

public static final boolean implementationOf(Object obj,
                                             String faceName)

implementationOf

public static final boolean implementationOf(Class<?> clazz,
                                             String faceName)

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 method
method - the method to be called
args - the method arguments
Returns:
the methods result, maybe null if void
Throws:
JogampRuntimeException - if call fails
RuntimeException - 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