public final class ReflectionHelper
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ReflectionHelper.DeclaringClassInterfacePair
A tuple consisting of a concrete class and a declaring class that declares a
generic interface type.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.Class<?> |
bundleReferenceClass |
private static TypeVisitor<java.lang.Class> |
eraser
Implements the logic for
erasure(Type) . |
private static java.util.logging.Logger |
LOGGER |
private static java.security.PrivilegedAction<?> |
NoOpPrivilegedACTION |
Modifier | Constructor and Description |
---|---|
private |
ReflectionHelper()
Prevents instantiation.
|
Modifier and Type | Method and Description |
---|---|
private static java.lang.reflect.Method[] |
_getMethods(java.lang.Class<?> clazz) |
private static boolean |
checkTypeBounds(java.lang.Class type,
java.lang.reflect.Type[] bounds) |
static <T> java.security.PrivilegedAction<java.lang.Class<T>> |
classForNamePA(java.lang.String name)
Get privileged action to obtain Class from given class name.
|
static <T> java.security.PrivilegedAction<java.lang.Class<T>> |
classForNamePA(java.lang.String name,
java.lang.ClassLoader cl)
Get privileged action to obtain Class from given class name.
|
static <T> java.security.PrivilegedExceptionAction<java.lang.Class<T>> |
classForNameWithExceptionPEA(java.lang.String name)
Get privileged exception action to obtain Class from given class name.
|
static <T> java.security.PrivilegedExceptionAction<java.lang.Class<T>> |
classForNameWithExceptionPEA(java.lang.String name,
java.lang.ClassLoader cl)
Get privileged exception action to obtain Class from given class name.
|
private static boolean |
compareParameterTypes(java.lang.reflect.Type[] ts,
java.lang.reflect.Type[] _ts)
Compare generic parameter types of two methods.
|
private static boolean |
compareParameterTypes(java.lang.reflect.Type ts,
java.lang.reflect.Type _ts)
Compare respective generic parameter types of two methods.
|
static <T> java.lang.Class<T> |
erasure(java.lang.reflect.Type type)
Get the
Class representation of the given type. |
static java.security.PrivilegedAction<java.lang.reflect.Method> |
findMethodOnClassPA(java.lang.Class<?> c,
java.lang.reflect.Method m)
Get privileged action to find a method on a class given an existing method.
|
static java.lang.reflect.Method |
findOverridingMethodOnClass(java.lang.Class<?> clazz,
java.lang.reflect.Method method)
Find a
method that overrides the given method on the given class . |
private static java.lang.reflect.Type |
fix(java.lang.reflect.Type t)
JDK 5.0 has a bug of creating
GenericArrayType where it shouldn't. |
static javax.ws.rs.core.GenericType |
genericTypeFor(java.lang.Object instance)
Create a
generic type information for a given
Java instance . |
static java.security.PrivilegedAction<java.lang.reflect.Field[]> |
getAllFieldsPA(java.lang.Class<?> clazz)
Get privileged action to obtain fields on given class, recursively through inheritance hierarchy.
|
static java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> |
getAnnotationTypes(java.lang.reflect.AnnotatedElement annotatedElement,
java.lang.Class<? extends java.lang.annotation.Annotation> metaAnnotation)
Returns collection of all annotation types attached to a given annotated element that have the provided meta
annotation attached.
|
static java.lang.reflect.Type |
getArrayComponentType(java.lang.reflect.Type type)
Gets the component type of the array.
|
static java.lang.Class<?> |
getArrayForComponentType(java.lang.Class<?> c)
Get Array class of component type.
|
static ReflectionHelper.DeclaringClassInterfacePair |
getClass(java.lang.Class<?> concrete,
java.lang.Class<?> iface)
Find the declaring class that implements or extends an interface.
|
private static ReflectionHelper.DeclaringClassInterfacePair |
getClass(java.lang.Class<?> concrete,
java.lang.Class<?> iface,
java.lang.Class<?> c) |
static java.security.PrivilegedAction<java.lang.ClassLoader> |
getClassLoaderPA(java.lang.Class<?> clazz)
Get privileged action to obtain class loader for given class.
|
private static java.lang.ClassLoader |
getContextClassLoader()
Get the context class loader.
|
static java.security.PrivilegedAction<java.lang.ClassLoader> |
getContextClassLoaderPA()
Get privileged action to obtain context class loader.
|
static java.security.PrivilegedAction<java.lang.reflect.Constructor<?>> |
getDeclaredConstructorPA(java.lang.Class<?> clazz,
java.lang.Class<?>... params)
Get privileged action to obtain declared constructor of given class with given parameters.
|
static java.security.PrivilegedAction<java.lang.reflect.Constructor<?>[]> |
getDeclaredConstructorsPA(java.lang.Class<?> clazz)
Get privileged action to obtain declared constructors of given class.
|
static java.security.PrivilegedAction<java.lang.reflect.Field[]> |
getDeclaredFieldsPA(java.lang.Class<?> clazz)
Get privileged action to obtain fields declared on given class.
|
static java.security.PrivilegedAction<java.util.Collection<? extends java.lang.reflect.Method>> |
getDeclaredMethodsPA(java.lang.Class<?> clazz)
Get privileged action to obtain methods declared on given class.
|
static java.lang.Class<?> |
getDeclaringClass(java.lang.reflect.AccessibleObject ao)
Get the declaring class of an accessible object.
|
static java.security.PrivilegedAction<java.lang.reflect.Method> |
getFromStringStringMethodPA(java.lang.Class<?> clazz)
Get privileged action to get the static fromString(String ) method.
|
static java.util.List<java.lang.Class<?>> |
getGenericTypeArgumentClasses(java.lang.reflect.Type type)
Get the list of classes that represent the type arguments of a
parameterized input type. |
static java.security.PrivilegedAction<java.lang.reflect.Method[]> |
getMethodsPA(java.lang.Class<?> c)
Get privileged action to return an array containing
Method objects reflecting all
the public member methods of the supplied class or interface
object, including those declared by the class or interface and those
inherited from superclasses and superinterfaces. |
static OsgiRegistry |
getOsgiRegistryInstance()
Returns an
OsgiRegistry instance. |
static java.lang.Class[] |
getParameterizedClassArguments(ReflectionHelper.DeclaringClassInterfacePair p)
Get the parameterized class arguments for a declaring class that
declares a generic interface type.
|
static java.lang.reflect.Type[] |
getParameterizedTypeArguments(ReflectionHelper.DeclaringClassInterfacePair p)
Get the parameterized type arguments for a declaring class that
declares a generic interface type.
|
static java.lang.String |
getPropertyName(java.lang.reflect.Method method)
Determine property (field) name from given getter/setter method.
|
static java.lang.Class<?> |
getRawClass(java.lang.reflect.Type type)
Given the type parameter gets the raw type represented by the type, or null if this has no associated raw class.
|
static java.io.InputStream |
getResourceAsStream(java.lang.ClassLoader loader,
java.lang.Class<?> originClass,
java.lang.String name)
Lookup resource by given name.
|
static java.security.PrivilegedAction<java.lang.reflect.Constructor> |
getStringConstructorPA(java.lang.Class<?> clazz)
Get privileged action to obtain constructor that has a single parameter of String.
|
private static java.security.PrivilegedAction<java.lang.reflect.Method> |
getStringToObjectMethodPA(java.lang.Class<?> clazz,
java.lang.String methodName)
Get privileged action to get the static method of given name.
|
private static ReflectionHelper.DeclaringClassInterfacePair |
getType(java.lang.Class<?> concrete,
java.lang.Class<?> iface,
java.lang.Class<?> c,
java.lang.reflect.Type t) |
private static ReflectionHelper.DeclaringClassInterfacePair |
getType(java.lang.Class<?> concrete,
java.lang.Class<?> iface,
java.lang.Class<?> c,
java.lang.reflect.Type[] ts) |
static java.lang.reflect.Type |
getTypeArgument(java.lang.reflect.Type type,
int index)
Get a type argument at particular index for a parameterized type.
|
static java.util.List<ClassTypePair> |
getTypeArgumentAndClass(java.lang.reflect.Type type)
Get the list of class-type pairs that represent the type arguments of a
parameterized input type. |
static java.lang.reflect.Type[] |
getTypeArguments(java.lang.reflect.Type type)
Get the type arguments for a parameterized type.
|
private static java.lang.String |
getTypeName(java.lang.Class<?> type)
Get the Java type or array name.
|
static java.security.PrivilegedAction<java.lang.reflect.Method> |
getValueOfStringMethodPA(java.lang.Class<?> clazz)
Get privileged action to obtain the static valueOf(String ) method.
|
static boolean |
isArray(java.lang.reflect.Type type)
Checks if the type is an array type.
|
static boolean |
isArrayOfType(java.lang.reflect.Type type,
java.lang.Class<?> componentType)
Checks if the type is an array of a given component type.
|
static boolean |
isGetter(java.lang.reflect.Method method)
Determine whether a given method is
getter . |
static boolean |
isPrimitive(java.lang.reflect.Type type)
Check if the given type is a primitive type.
|
static boolean |
isSetter(java.lang.reflect.Method method)
Determine whether a given method is
setter . |
static boolean |
isSubClassOf(java.lang.reflect.Type subType,
java.lang.reflect.Type superType)
Check if
subType is a sub-type of superType . |
static java.lang.String |
methodInstanceToString(java.lang.Object o,
java.lang.reflect.Method m)
Create a string representation of a method and an instance whose
class implements the method.
|
static java.lang.String |
objectToString(java.lang.Object o)
Create a string representation of an object.
|
static ClassTypePair |
resolveGenericType(java.lang.Class concreteClass,
java.lang.Class declaringClass,
java.lang.Class rawResolvedType,
java.lang.reflect.Type genericResolvedType)
Resolve generic type parameter(s) of a raw class and it's generic type
based on the class that declares the generic type parameter(s) to be resolved
and a concrete implementation of the declaring class.
|
static ClassTypePair |
resolveTypeVariable(java.lang.Class<?> c,
java.lang.Class<?> dc,
java.lang.reflect.TypeVariable tv)
Given a type variable resolve the Java class of that variable.
|
private static ClassTypePair |
resolveTypeVariable(java.lang.Class<?> c,
java.lang.Class<?> dc,
java.lang.reflect.TypeVariable tv,
java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> map) |
private static ClassTypePair |
resolveTypeVariable(java.lang.reflect.ParameterizedType pt,
java.lang.Class<?> c,
java.lang.Class<?> dc,
java.lang.reflect.TypeVariable tv,
java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> map) |
static java.security.PrivilegedAction |
setAccessibleMethodPA(java.lang.reflect.Method m)
Get privileged action to set a method to be accessible.
|
static java.security.PrivilegedAction |
setContextClassLoaderPA(java.lang.ClassLoader classLoader)
Get privileged action to set the actual context class loader.
|
static java.lang.Class<?> |
theMostSpecificTypeOf(java.util.Set<java.lang.reflect.Type> contractTypes)
Determine the most specific type from given set.
|
private static final java.util.logging.Logger LOGGER
private static final java.security.PrivilegedAction<?> NoOpPrivilegedACTION
private static final TypeVisitor<java.lang.Class> eraser
erasure(Type)
.private static final java.lang.Class<?> bundleReferenceClass
public static java.lang.Class<?> getDeclaringClass(java.lang.reflect.AccessibleObject ao)
Supported are Method
, Field
and Constructor
accessible object types.
ao
- an accessible object.java.lang.IllegalArgumentException
- in case the type of the accessible object
is not supported.public static java.lang.String objectToString(java.lang.Object o)
Returns a string consisting of the name of the class of which the
object is an instance, the at-sign character '@'
, and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
o.getClass().getName() + '@' + Integer.toHexString(o.hashCode())
o
- the object.public static java.lang.String methodInstanceToString(java.lang.Object o, java.lang.reflect.Method m)
Returns a string consisting of the name of the class of which the object
is an instance, the at-sign character '@'
,
the unsigned hexadecimal representation of the hash code of the
object, the character '.'
, the name of the method,
the character '('
, the list of method parameters, and
the character ')'
. In other words, those method returns a
string equal to the value of:
o.getClass().getName() + '@' + Integer.toHexString(o.hashCode()) + '.' + m.getName() + '(' + <parameters> + ')'.
o
- the object whose class implements m
.m
- the method.private static java.lang.String getTypeName(java.lang.Class<?> type)
If the class is representing an array, the "[]"
suffix will be added
to the name of the type for each dimension of an array.
type
- Java type (can represent an array).public static <T> java.security.PrivilegedAction<java.lang.Class<T>> classForNamePA(java.lang.String name)
If run using security manager, the returned privileged action must be invoked within a doPrivileged block. The context class loader will be utilized if accessible and non-null. Otherwise the defining class loader of this class will be utilized.
T
- class type.name
- class name.null
if the class cannot be found.AccessController.doPrivileged(java.security.PrivilegedAction)
public static <T> java.security.PrivilegedAction<java.lang.Class<T>> classForNamePA(java.lang.String name, java.lang.ClassLoader cl)
T
- class type.name
- class name.cl
- class loader to use, if null
then the defining class loader
of this class will be utilized.null
if the class cannot be found.AccessController.doPrivileged(java.security.PrivilegedAction)
public static java.security.PrivilegedAction<java.lang.ClassLoader> getClassLoaderPA(java.lang.Class<?> clazz)
clazz
- class for which to get class loader.clazz
class.AccessController.doPrivileged(java.security.PrivilegedAction)
public static java.security.PrivilegedAction<java.lang.reflect.Field[]> getDeclaredFieldsPA(java.lang.Class<?> clazz)
clazz
- class for which to get the declared fields.clazz
class.AccessController.doPrivileged(java.security.PrivilegedAction)
public static java.security.PrivilegedAction<java.lang.reflect.Field[]> getAllFieldsPA(java.lang.Class<?> clazz)
clazz
- class for which to get fields.clazz
class.AccessController.doPrivileged(java.security.PrivilegedAction)
public static java.security.PrivilegedAction<java.util.Collection<? extends java.lang.reflect.Method>> getDeclaredMethodsPA(java.lang.Class<?> clazz)
clazz
- class for which to get the declared methods.clazz
class.AccessController.doPrivileged(java.security.PrivilegedAction)
public static <T> java.security.PrivilegedExceptionAction<java.lang.Class<T>> classForNameWithExceptionPEA(java.lang.String name) throws java.lang.ClassNotFoundException
T
- class type.name
- class name.ClassNotFoundException
or return null
if the class cannot be found.java.lang.ClassNotFoundException
- in case the class cannot be loaded with the context class loader.AccessController.doPrivileged(java.security.PrivilegedExceptionAction)
public static <T> java.security.PrivilegedExceptionAction<java.lang.Class<T>> classForNameWithExceptionPEA(java.lang.String name, java.lang.ClassLoader cl) throws java.lang.ClassNotFoundException
T
- class type.name
- class name.cl
- class loader to use, if null
then the defining class loader
of the calling class will be utilized.null
,
or throws ClassNotFoundException
in case the class loader has been specified.java.lang.ClassNotFoundException
- in case the class cannot be loaded with the specified class loader.AccessController.doPrivileged(java.security.PrivilegedExceptionAction)
public static java.security.PrivilegedAction<java.lang.ClassLoader> getContextClassLoaderPA()
null
if the context class loader has not been set.AccessController.doPrivileged(java.security.PrivilegedAction)
private static java.lang.ClassLoader getContextClassLoader()
null
if not set.public static java.security.PrivilegedAction setContextClassLoaderPA(java.lang.ClassLoader classLoader)
classLoader
- context class loader to be set.AccessController.doPrivileged(java.security.PrivilegedAction)
public static java.security.PrivilegedAction setAccessibleMethodPA(java.lang.reflect.Method m)
m
- method to be set as accessible.AccessController.doPrivileged(java.security.PrivilegedAction)
public static java.util.List<java.lang.Class<?>> getGenericTypeArgumentClasses(java.lang.reflect.Type type) throws java.lang.IllegalArgumentException
parameterized
input type.
For any given argument in the returned list, following rules apply:
type
is not an instance of ParameterizedType an empty
list is returned.type
- parameterized type.null
.java.lang.IllegalArgumentException
- if any of the generic type arguments is
not a class, or a generic array type, or the generic component type
of the generic array type is not class, or not a parameterized type
with a raw type that is not a class.public static java.util.List<ClassTypePair> getTypeArgumentAndClass(java.lang.reflect.Type type) throws java.lang.IllegalArgumentException
parameterized
input type.
For any given class
part of each pair
in the returned list, following rules apply:
type
is not an instance of ParameterizedType an empty
list is returned.type
- parameterized type.null
.java.lang.IllegalArgumentException
- if any of the generic type arguments is
not a class, or a generic array type, or the generic component type
of the generic array type is not class, or not a parameterized type
with a raw type that is not a class.public static boolean isPrimitive(java.lang.reflect.Type type)
type
- type to be checked.true
in case the type represents a primitive type, otherwise returns false
.public static java.lang.reflect.Type[] getTypeArguments(java.lang.reflect.Type type)
parameterized type
,
the method returns null
.type
- parameterized type.null
in case the input type is not a parameterized type.public static java.lang.reflect.Type getTypeArgument(java.lang.reflect.Type type, int index)
parameterized type
,
the method returns null
.type
- parameterized type.index
- type parameter index.null
in case the input type is not
a parameterized type.private static java.lang.reflect.Type fix(java.lang.reflect.Type t)
GenericArrayType
where it shouldn't.
fix that manually to work around the problem.
See bug 6202725.public static <T> java.lang.Class<T> erasure(java.lang.reflect.Type type)
Class
representation of the given type.
This corresponds to the notion of the erasure in JSR-14.type
- type to provide the erasure for.public static boolean isSubClassOf(java.lang.reflect.Type subType, java.lang.reflect.Type superType)
subType
is a sub-type of superType
.subType
- sub-type type.superType
- super-type type.true
in case the subType
is a sub-type of superType
,
false
otherwise.public static boolean isArray(java.lang.reflect.Type type)
type
- type to check.true
in case the type is an array type, false
otherwise.public static boolean isArrayOfType(java.lang.reflect.Type type, java.lang.Class<?> componentType)
type
- type to check.componentType
- array component type.true
in case the type is an array type of a given component type,
false
otherwise.public static java.lang.reflect.Type getArrayComponentType(java.lang.reflect.Type type)
type
- must be an array.java.lang.IllegalArgumentException
- in case the type is not an array type.public static java.lang.Class<?> getArrayForComponentType(java.lang.Class<?> c)
c
- the component class of the arraypublic static java.security.PrivilegedAction<java.lang.reflect.Method> getValueOfStringMethodPA(java.lang.Class<?> clazz)
clazz
- class to obtain the method.null
if the method is not present.AccessController.doPrivileged(java.security.PrivilegedAction)
public static java.security.PrivilegedAction<java.lang.reflect.Method> getFromStringStringMethodPA(java.lang.Class<?> clazz)
clazz
- class for which to get the method.null
if the method is not present.AccessController.doPrivileged(java.security.PrivilegedAction)
private static java.security.PrivilegedAction<java.lang.reflect.Method> getStringToObjectMethodPA(java.lang.Class<?> clazz, java.lang.String methodName)
clazz
- class for which to get the method.methodName
- name of the method to be obtained.null
if the method is not present.AccessController.doPrivileged(java.security.PrivilegedAction)
public static java.security.PrivilegedAction<java.lang.reflect.Constructor> getStringConstructorPA(java.lang.Class<?> clazz)
clazz
- The class for which to obtain the constructor.null
if the constructor is not present.AccessController.doPrivileged(java.security.PrivilegedAction)
public static java.security.PrivilegedAction<java.lang.reflect.Constructor<?>[]> getDeclaredConstructorsPA(java.lang.Class<?> clazz)
clazz
- The class for which to obtain the constructors.AccessController.doPrivileged(java.security.PrivilegedAction)
public static java.security.PrivilegedAction<java.lang.reflect.Constructor<?>> getDeclaredConstructorPA(java.lang.Class<?> clazz, java.lang.Class<?>... params)
clazz
- The class for which to obtain the constructor.params
- constructor parameters.null
, when constructor with given parameters
is not found.AccessController.doPrivileged(java.security.PrivilegedAction)
public static java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> getAnnotationTypes(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> metaAnnotation)
annotatedElement
- annotated element.metaAnnotation
- meta annotation attached to the annotation types we are looking for (if null, annotation
types of all attached annotations will be returned).public static boolean isGetter(java.lang.reflect.Method method)
getter
.method
- method to be examined.true
if the method is getter
, false
otherwise.public static javax.ws.rs.core.GenericType genericTypeFor(java.lang.Object instance)
generic type
information for a given
Java instance
.
If the supplied instance is an instance of GenericEntity
, the generic type
information will be computed using the GenericEntity.getType()
information. Otherwise the instance.getClass()
will be used.
instance
- Java instance for which the GenericType
description should be created.GenericType
describing the Java instance
.public static boolean isSetter(java.lang.reflect.Method method)
setter
.method
- method to be examined.true
if the method is setter
, false
otherwise.public static java.lang.String getPropertyName(java.lang.reflect.Method method)
method
- method to be examined.public static java.lang.Class<?> theMostSpecificTypeOf(java.util.Set<java.lang.reflect.Type> contractTypes)
contractTypes
- to be taken into account.public static java.lang.Class[] getParameterizedClassArguments(ReflectionHelper.DeclaringClassInterfacePair p)
p
- the declaring classpublic static java.lang.reflect.Type[] getParameterizedTypeArguments(ReflectionHelper.DeclaringClassInterfacePair p)
p
- the declaring classpublic static ReflectionHelper.DeclaringClassInterfacePair getClass(java.lang.Class<?> concrete, java.lang.Class<?> iface)
concrete
- the concrete class than directly or indirectly
implements or extends an interface class.iface
- the interface class.private static ReflectionHelper.DeclaringClassInterfacePair getClass(java.lang.Class<?> concrete, java.lang.Class<?> iface, java.lang.Class<?> c)
private static ReflectionHelper.DeclaringClassInterfacePair getType(java.lang.Class<?> concrete, java.lang.Class<?> iface, java.lang.Class<?> c, java.lang.reflect.Type[] ts)
private static ReflectionHelper.DeclaringClassInterfacePair getType(java.lang.Class<?> concrete, java.lang.Class<?> iface, java.lang.Class<?> c, java.lang.reflect.Type t)
public static ClassTypePair resolveGenericType(java.lang.Class concreteClass, java.lang.Class declaringClass, java.lang.Class rawResolvedType, java.lang.reflect.Type genericResolvedType)
concreteClass
- concrete implementation of the declaring class.declaringClass
- class declaring the generic type parameter(s) to be
resolved.rawResolvedType
- raw class of the generic type to be resolved.genericResolvedType
- generic type information of th type to be resolved.public static ClassTypePair resolveTypeVariable(java.lang.Class<?> c, java.lang.Class<?> dc, java.lang.reflect.TypeVariable tv)
c
- the concrete class from which all type variables are resolved.dc
- the declaring class where the type variable was defined.tv
- the type variable.private static ClassTypePair resolveTypeVariable(java.lang.Class<?> c, java.lang.Class<?> dc, java.lang.reflect.TypeVariable tv, java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> map)
private static ClassTypePair resolveTypeVariable(java.lang.reflect.ParameterizedType pt, java.lang.Class<?> c, java.lang.Class<?> dc, java.lang.reflect.TypeVariable tv, java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> map)
public static java.security.PrivilegedAction<java.lang.reflect.Method> findMethodOnClassPA(java.lang.Class<?> c, java.lang.reflect.Method m)
TypeVariable
then that public method is
returned from the action.c
- the class to search for a public methodm
- the method to findAccessController.doPrivileged(java.security.PrivilegedAction)
public static java.security.PrivilegedAction<java.lang.reflect.Method[]> getMethodsPA(java.lang.Class<?> c)
Method
objects reflecting all
the public member methods of the supplied class or interface
object, including those declared by the class or interface and those
inherited from superclasses and superinterfaces.
Array classes return all the (public) member methods
inherited from the Object
class. The elements in the array
returned are not sorted and are not in any particular order. This
method returns action providing an array of length 0 if this Class
object
represents a class or interface that has no public member methods, or if
this Class
object represents a primitive type or void.
The class initialization method <clinit>
is not
included in the returned array. If the class declares multiple public
member methods with the same parameter types, they are all included in
the returned array.
See The Java Language Specification, sections 8.2 and 8.4.
c
- class for which the methods should be returned.Method
objects representing the
public methods of the class.AccessController.doPrivileged(java.security.PrivilegedAction)
private static java.lang.reflect.Method[] _getMethods(java.lang.Class<?> clazz)
public static java.lang.reflect.Method findOverridingMethodOnClass(java.lang.Class<?> clazz, java.lang.reflect.Method method)
method
that overrides the given method
on the given class
.clazz
- class to find overriding method on.method
- an abstract method to find implementing method for.private static boolean compareParameterTypes(java.lang.reflect.Type[] ts, java.lang.reflect.Type[] _ts)
ts
- generic parameter types of the first method._ts
- generic parameter types of the second method.true
if the given types are understood to be equal, false
otherwise.compareParameterTypes(java.lang.reflect.Type, java.lang.reflect.Type)
private static boolean compareParameterTypes(java.lang.reflect.Type ts, java.lang.reflect.Type _ts)
ts
- generic parameter type of the first method._ts
- generic parameter type of the second method.true
if the given types are understood to be equal, false
otherwise.private static boolean checkTypeBounds(java.lang.Class type, java.lang.reflect.Type[] bounds)
public static OsgiRegistry getOsgiRegistryInstance()
OsgiRegistry
instance.OsgiRegistry
instance or null
if the class cannot be instantiated (not in OSGi environment).public static java.io.InputStream getResourceAsStream(java.lang.ClassLoader loader, java.lang.Class<?> originClass, java.lang.String name)
loader
- class loader where to lookup the resource in non-OSGi environment or if OSGi means fail.originClass
- if not null, and OSGi environment is detected, the resource will be taken from the bundle including
the originClass type.name
- filename of the desired resource.public static java.lang.Class<?> getRawClass(java.lang.reflect.Type type)
type
- the type to find the raw class on.