Top Inners Fields Constructors Methods
com.jogamp.common.util

public final Class ReflectionUtil

extends Object
Class Inheritance
Imports
java.lang.reflect.Constructor, .InvocationTargetException, .Method, java.util.HashMap, .Iterator, .Map, .Map.Entry, .Set, jogamp.common.Debug, com.jogamp.common.ExceptionUtils, .JogampRuntimeException

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
private static class
public static class
ReflectionUtil.MethodAccessor

Convenient Method access class

Field Summary

Modifier and TypeField and Description
public static final boolean
public static final boolean
private static int
private static final Object
private static long
private static final Map<String, ReflectionUtil.ClassNameLookup>
private static final Class<?>[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static final String
asString(final Class<?>[] argTypes)

public static final Object

Returns:

the methods result, maybe null if void
callMethod
(final Object
may be null in case of a static method
instance
,
final Method
the method to be called
method
,
final Object...
the method arguments
args
)

public static final Object
callStaticMethod(final String clazzName, final String methodName, final Class<?>[] argTypes, final Object[] args, final ClassLoader cl)

public static final Object
createInstance(final Constructor<?> cstr, final Object... cstrArgs)

public static final Object
createInstance(final Class<?> clazz, final Class<?>[] cstrArgTypes, final Object... cstrArgs)

public static final Object
createInstance(final Class<?> clazz, final Object... cstrArgs)

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

public static final Object
createInstance(final String clazzName, final Object[] cstrArgs, final ClassLoader cl)

public static final Object
createInstance(final String clazzName, final ClassLoader cl)

public static final Class<?>
getClass(final String clazzName, final boolean initializeClazz, final ClassLoader cl)

Loads and returns the class or null.

private static Class<?>
getClassImpl(final String clazzName, final boolean initializeClazz, final ClassLoader cl)

public static final Constructor<?>
getConstructor(final String clazzName, final Class<?>[] cstrArgTypes, final boolean
TODO
initializeClazz
,
final ClassLoader cl)

public static final Constructor<?>
getConstructor(final Class<?> clazz, Class<?>... cstrArgTypes)

Returns a compatible constructor if available, otherwise throws an exception.

public static final Constructor<?>
getConstructor(final String clazzName, final ClassLoader cl)

public static StringBuilder
public static final Method
getMethod(final Class<?> clazz, final String methodName, final Class<?>... argTypes)

public static final Method
getMethod(final String clazzName, final String methodName, final Class<?>[] argTypes, final ClassLoader cl)

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

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

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

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

public static boolean
isAWTComponent(final Object target)

public static boolean
isAWTComponent(final Class<?> clazz)

public static final boolean
isClassAvailable(final String clazzName, final ClassLoader cl)

Returns true only if the class could be loaded.

public static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEBUGback to summary
public static final boolean DEBUG
DEBUG_STATS_FORNAMEback to summary
public static final boolean DEBUG_STATS_FORNAME
forNameCountback to summary
private static int forNameCount
forNameLockback to summary
private static final Object forNameLock
forNameNanoCostsback to summary
private static long forNameNanoCosts
forNameStatsback to summary
private static final Map<String, ReflectionUtil.ClassNameLookup> forNameStats
zeroTypesback to summary
private static final Class<?>[] zeroTypes

Constructor Detail

ReflectionUtilback to summary
public ReflectionUtil()

Method Detail

asStringback to summary
pack-priv static final String asString(final Class<?>[] argTypes)
callMethodback to summary
public static final Object callMethod(final Object instance, final Method method, final Object... args) throws JogampRuntimeException, RuntimeException
Parameters
instance:Object

may be null in case of a static method

method:Method

the method to be called

args:Object[]

the method arguments

Returns:Object

the methods result, maybe null if void

Exceptions
JogampRuntimeException:
if call fails
RuntimeException:
if call fails
callStaticMethodback to summary
public static final Object callStaticMethod(final String clazzName, final String methodName, final Class<?>[] argTypes, final Object[] args, final ClassLoader cl) throws JogampRuntimeException, RuntimeException
Exceptions
JogampRuntimeException:
if the instance can not be created.
createInstanceback to summary
public static final Object createInstance(final Constructor<?> cstr, final Object... cstrArgs) throws JogampRuntimeException, RuntimeException
Exceptions
JogampRuntimeException:
if the instance can not be created.
createInstanceback to summary
public static final Object createInstance(final Class<?> clazz, final Class<?>[] cstrArgTypes, final Object... cstrArgs) throws JogampRuntimeException, RuntimeException
Exceptions
JogampRuntimeException:
if the instance can not be created.
createInstanceback to summary
public static final Object createInstance(final Class<?> clazz, final Object... cstrArgs) throws JogampRuntimeException, RuntimeException
createInstanceback to summary
public static final Object createInstance(final String clazzName, final Class<?>[] cstrArgTypes, final Object[] cstrArgs, final ClassLoader cl) throws JogampRuntimeException, RuntimeException
createInstanceback to summary
public static final Object createInstance(final String clazzName, final Object[] cstrArgs, final ClassLoader cl) throws JogampRuntimeException, RuntimeException
createInstanceback to summary
public static final Object createInstance(final String clazzName, final ClassLoader cl) throws JogampRuntimeException, RuntimeException
getClassback to summary
public static final Class<?> getClass(final String clazzName, final boolean initializeClazz, final ClassLoader cl) throws JogampRuntimeException

Loads and returns the class or null.

See Also
Class#forName(java.lang.String, boolean, java.lang.ClassLoader)
getClassImplback to summary
private static Class<?> getClassImpl(final String clazzName, final boolean initializeClazz, final ClassLoader cl) throws ClassNotFoundException
getConstructorback to summary
public static final Constructor<?> getConstructor(final String clazzName, final Class<?>[] cstrArgTypes, final boolean initializeClazz, final ClassLoader cl) throws JogampRuntimeException
Parameters
initializeClazz:boolean

TODO

Exceptions
JogampRuntimeException:
if the constructor can not be delivered.
getConstructorback to summary
public static final Constructor<?> getConstructor(final 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.

Exceptions
JogampRuntimeException:
if the constructor can not be delivered.
getConstructorback to summary
public static final Constructor<?> getConstructor(final String clazzName, final ClassLoader cl) throws JogampRuntimeException
getForNameStatsback to summary
public static StringBuilder getForNameStats(StringBuilder sb)
getMethodback to summary
public static final Method getMethod(final Class<?> clazz, final String methodName, final Class<?>... argTypes) throws JogampRuntimeException, RuntimeException
Exceptions
JogampRuntimeException:
if the Method can not be found.
getMethodback to summary
public static final Method getMethod(final String clazzName, final String methodName, final Class<?>[] argTypes, final ClassLoader cl) throws JogampRuntimeException, RuntimeException
Exceptions
JogampRuntimeException:
if the Method can not be found.
implementationOfback to summary
public static final boolean implementationOf(final Object obj, final String faceName)
implementationOfback to summary
public static final boolean implementationOf(Class<?> clazz, final String faceName)
instanceOfback to summary
public static final boolean instanceOf(final Object obj, final String clazzName)
instanceOfback to summary
public static final boolean instanceOf(Class<?> clazz, final String clazzName)
isAWTComponentback to summary
public static boolean isAWTComponent(final Object target)
isAWTComponentback to summary
public static boolean isAWTComponent(final Class<?> clazz)
isClassAvailableback to summary
public static final boolean isClassAvailable(final String clazzName, final ClassLoader cl)

Returns true only if the class could be loaded.

resetForNameCountback to summary
public static void resetForNameCount()
com.jogamp.common.util back to summary

public Class ReflectionUtil.AWTNames

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ComponentClassback to summary
public static final String ComponentClass
GraphicsEnvironmentClassback to summary
public static final String GraphicsEnvironmentClass
isHeadlessMethodback to summary
public static final String isHeadlessMethod

Constructor Detail

AWTNamesback to summary
public AWTNames()
com.jogamp.common.util back to summary

private Class ReflectionUtil.ClassNameLookup

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public int
public final String
public long

Constructor Summary

AccessConstructor and Description
public
ClassNameLookup(final String name)

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

countback to summary
public int count
nameback to summary
public final String name
nanoCostsback to summary
public long nanoCosts

Constructor Detail

ClassNameLookupback to summary
public ClassNameLookup(final String name)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
com.jogamp.common.util back to summary

public Class ReflectionUtil.MethodAccessor

extends Object
Class Inheritance

Convenient Method access class

Field Summary

Modifier and TypeField and Description
pack-priv Method
m

Constructor Summary

AccessConstructor and Description
public
MethodAccessor(final Class<?> clazz, final String methodName, final Class<?>... argTypes)

Check available() before using instance.

Method Summary

Modifier and TypeMethod and Description
public boolean
available()

Returns true if method is available, otherwise false.

public Object
callMethod(final Object instance, final Object... args)

Check available() before calling to avoid throwing a JogampRuntimeException.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mback to summary
pack-priv Method m

Constructor Detail

MethodAccessorback to summary
public MethodAccessor(final Class<?> clazz, final String methodName, final Class<?>... argTypes)

Check available() before using instance.

Method Detail

availableback to summary
public boolean available()

Returns true if method is available, otherwise false.

callMethodback to summary
public Object callMethod(final Object instance, final Object... args)

Check available() before calling to avoid throwing a JogampRuntimeException.

Exceptions
JogampRuntimeException:
if method is not available