aicas logoJamaica 6.1 release 1

java.lang
Class Class<T>

java.lang.Object
  extended by java.lang.Class<T>
All Implemented Interfaces:
Serializable, AnnotatedElement, GenericDeclaration, Type

public final class Class<T>
extends Object
implements Serializable, GenericDeclaration, Type, AnnotatedElement

Class whose instances represent Java classes.

Since:
JDK 1.0
See Also:
Serialized Form

Constructor Summary
Class()
           
 
Method Summary
<U> Class<? extends U>
asSubclass(Class<U> clazz)
          asSubclass casts this class to a subclass of this class.
 T cast(Object obj)
          cast casts a given object to this type.
 boolean desiredAssertionStatus()
          If this class would be initialized at this time, its assertion status would be set according to the value returned by this method.
static Class<?> forName(String className)
          forName loads a class with the given name using the class loader of the calling method's class.
static Class<?> forName(String name, boolean initialize, ClassLoader loader)
          forName loads a class with the given name using the class loader of the calling method's class.
<A extends Annotation>
A
getAnnotation(Class<A> annotationClass)
          Returns this element's annotation for the specified type if such an annotation is present, else null.
 Annotation[] getAnnotations()
          Returns all annotations present on this element.
 String getCanonicalName()
          Returns the canonical name of the underlying class as defined by the Java Language Specification.
 Class<?>[] getClasses()
          getClasses returns array of classes that are public members of this class or any of this class' superclasses.
 ClassLoader getClassLoader()
          getClassLoader return the class loader that loaded this class into the system.
 Class<?> getComponentType()
          getComponentType returns the element type of an array.
 Constructor<T> getConstructor(Class<?>... parameterTypes)
          getConstructor finds the public constructor with given parameter types in this class.
 Constructor<?>[] getConstructors()
          getConstructors returns an array of all public constructors of this class.
 Annotation[] getDeclaredAnnotations()
          Returns all annotations that are directly present on this element.
 Class<?>[] getDeclaredClasses()
          getDeclaredClasses returns array of classes that are members of this class.
 Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
          getDeclaredConstructor searches for a constructor with given parameter types in this clss.
 Constructor<T>[] getDeclaredConstructors()
          getDeclaredConstructors returns an array of all constructors declared in this class.
 Field getDeclaredField(String name)
          getDeclaredField searches for a field with the given name that is declared in this class.
 Field[] getDeclaredFields()
          getDeclaredFields returns an array of all the fields declared in this class.
 Method getDeclaredMethod(String name, Class<?>... parameterTypes)
          getDeclaredMethod searches for a method with the given name and parameter types in this class.
 Method[] getDeclaredMethods()
          getDeclaredMethods returns an array of all methods declared in this class.
 Class<?> getDeclaringClass()
          getDeclaringClass returns the declaring class for an anonymous inner class.
 Class<?> getEnclosingClass()
          getEnclosingClass returns the enclosing class of an inner class, or null if this is not an inner class.
 Constructor<?> getEnclosingConstructor()
          If this Class object represents a local or anonymous class within a constructor, returns a Constructor object representing the immediately enclosing constructor of the underlying class.
 Method getEnclosingMethod()
          If this Class object represents a local or anonymous class within a method, returns a Method object representing the immediately enclosing method of the underlying class.
 T[] getEnumConstants()
          getEnumConstants returns an array with all the constants of this enumeration type, or null if this is not an enumeration type.
 Field getField(String name)
          Looks for a public field accessible through this class.
 Field[] getFields()
          Looks for all public fields in this class and its super classes.
 Type[] getGenericInterfaces()
          Return array of interfaces implemented by this with actual generic parameters
 Type getGenericSuperclass()
          Return super class including actual generic parameters.
 Class[] getInterfaces()
          getInterfaces returns an array of all the interface classes this class implements directly.
 Method getMethod(String name, Class<?>... parameterTypes)
          getMethod finds the public method with given name and parameter types in this class.
 Method[] getMethods()
          getMethods returns an array of all public methods of this class.
 int getModifiers()
          getModifiers returns modifier set for this class
 String getName()
          getName returns the name of this class.
 Package getPackage()
          Gets the object representing the package which contains this class.
 ProtectionDomain getProtectionDomain()
          getProtectionDomain returns this class' protection domain.
 URL getResource(String name)
          getResource gets a resource from the class loader associated with this class.
 InputStream getResourceAsStream(String name)
          Opens resources as InputStream.
 Object[] getSigners()
          getSigners returns the signers of this class, or null if there are none or this is a primitive type.
 String getSimpleName()
          getSimpleName returns the plain name of this class without generic arguments.
 Class<? super T> getSuperclass()
          getSuperclass gets the super class of this class
 TypeVariable<Class<T>>[] getTypeParameters()
          Return an array of the declared type parameters for a generic class.
 boolean isAnnotation()
          check if this class instance represents an annotation.
 boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
          Returns true if an annotation for the specified type is present on this element, else false.
 boolean isAnonymousClass()
          Returns true if and only if the underlying class is an anonymous class.
 boolean isArray()
          Test if this class is an array.
 boolean isAssignableFrom(Class<?> cls)
          Checks if an object of type cls can be assigned to a variable of this type.
 boolean isEnum()
          isEnum checks if this class is an enumeration class.
 boolean isInstance(Object obj)
          isInstance checks if "obj instanceof >>this<<" would result in true, i.e., if this is a class, obj's class is equal to or a subclass of this, otherwise if this is an interface, obj's class implements the interface, otherwise if this is an array type, obj's type is an array that is assignment compatible to this.
 boolean isInterface()
          Test if this class is an interface.
 boolean isLocalClass()
          Returns true if and only if the underlying class is a local class.
 boolean isMemberClass()
          Returns true if and only if the underlying class is a member class.
 boolean isPrimitive()
          Test if this class represents a primitive type, i.e., it is one of the values Boolean.TYPE, Character.TYPE, Byte.TYPE, Short.TYPE, Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE, and Void.TYPE.
 boolean isSynthetic()
          check if this class instance represents a synthetic class
 T newInstance()
          newInstance creates a new instance of this class using the constructor with an empty argument list.
 String toString()
          toString creates a string representation of this class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Class

public Class()
Method Detail

getSuperclass

public Class<? super T> getSuperclass()
getSuperclass gets the super class of this class

Returns:
the super class, null if this is a primitive type, java.lang.Object or an interface. Object.class if this is an array type.

toString

public String toString()
toString creates a string representation of this class

Overrides:
toString in class Object
Returns:
the string representation

forName

public static Class<?> forName(String className)
                        throws ClassNotFoundException
forName loads a class with the given name using the class loader of the calling method's class.

For JamaicaVM, this method is never called from compiled code, the compiler replaces a call forName(x) by forName(x,true,null) since the class loader of any statically compiled method is the system class loader.

Parameters:
className - the name of the class to be loaded "." as package separator.
Returns:
the newly loaded class.
Throws:
OutOfMemoryError - in case of low memory.
StackOverflowError - in case of stack overflow
ClassFormatError - in case of loading a broken class
LinkageError - if class could not be linked
ClassNotFoundException - if class was not found.
InternalError - If class could not be found due to an internal error, e.g. use of too many dynamic types.
ExceptionInInitializerError - if initialization of the class caused an exception other than a RuntimeException.
Since:
1.2

forName

public static Class<?> forName(String name,
                               boolean initialize,
                               ClassLoader loader)
                        throws ClassNotFoundException
forName loads a class with the given name using the class loader of the calling method's class.

Parameters:
name - the name of the class to be loaded using "." as package separator.
initialize - true to ask for initialization of the class
loader - the loader to load the class from, null for system/boot class loader.
Returns:
the newly loaded class.
Throws:
OutOfMemoryError - in case of low memory.
StackOverflowError - in case of stack overflow
ClassFormatError - in case of loading a broken class
LinkageError - if class could not be linked
ClassNotFoundException - if class was not found.
InternalError - If class could not be found due to an internal error, e.g. use of too many dynamic types.
ExceptionInInitializerError - if initialization of the class caused an exception other than a RuntimeException.
Since:
1.2

newInstance

public T newInstance()
              throws InstantiationException,
                     IllegalAccessException
newInstance creates a new instance of this class using the constructor with an empty argument list.

If a security manager sm is installed, sm.checkMemberAccess(this,Member.PUBLIC) and sm.checkPermission(packageName()) will be called.

If this class does not define a

Returns:
the new instance, never null
Throws:
InstantiationException - if calling the constructor caused any of the exceptions InstantiationException, NoSuchMethodException, IllegalArgumentException or InvocationTargetException.
IllegalAccessException - if calling the constructor caused this exception, i.e., the constructor is not accessible.

isInstance

public boolean isInstance(Object obj)
isInstance checks if "obj instanceof >>this<<" would result in true, i.e., if this is a class, obj's class is equal to or a subclass of this, otherwise if this is an interface, obj's class implements the interface, otherwise if this is an array type, obj's type is an array that is assignment compatible to this.

If this is a primitive type or obj is null, the result is false..

Parameters:
obj - an object reference or null.
Returns:
true iff obj may be assigned to a variable of type this.
Since:
JDK 1.1

isAssignableFrom

public boolean isAssignableFrom(Class<?> cls)
Checks if an object of type cls can be assigned to a variable of this type.

The result is true iff this is a class and cls is equal to or a subclass of this, otherwise if this is an interface and cls is a class or an interface that is equal to or implements this, otherwise if this is an array type and cls is an array that is assignment compatible to this, else if this is a primitive type and cls is equal to this.

Parameters:
cls - the source type of the assignment
Returns:
true if cls is assignment compatible to this.
Throws:
NullPointerException - is cls is null
Since:
JDK 1.1

isInterface

public boolean isInterface()
Test if this class is an interface.

Returns:
true iff this is an interface.

isArray

public boolean isArray()
Test if this class is an array.

Returns:
true iff this is an array.
Since:
JDK 1.1

isPrimitive

public boolean isPrimitive()
Test if this class represents a primitive type, i.e., it is one of the values Boolean.TYPE, Character.TYPE, Byte.TYPE, Short.TYPE, Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE, and Void.TYPE.

Returns:
true iff this represents a primitive type.
Since:
JDK 1.1

getName

public String getName()
getName returns the name of this class. If this is a normal class or interface, return a name using dots as package separators, e.g. "java.lang.String", if this is an array. return the internal representation from the class file using dots, e.g. "[Ljava.lang.String;", "[[[I", if this is a primitive type, return the corresponding keyword, e.g., "byte", "long", "void".

The resulting string is interned().

Returns:
the name of this this class.

getClassLoader

public ClassLoader getClassLoader()
getClassLoader return the class loader that loaded this class into the system.

If a security manager is installed, this does a checkPermission on new RuntimePermission("getClassLoader").

Returns:
the class loader, null for the boot class loader.
Throws:
SecurityException - if checkPermission(new RuntimePermission("getClassLoader")) failed on the installed security manager.

getPackage

public Package getPackage()
Gets the object representing the package which contains this class. This returns null for primitive and array types and for classes that do not come from an archive that provides package information in the manifest.

Returns:
The package object.
Since:
1.2

getInterfaces

public Class[] getInterfaces()
getInterfaces returns an array of all the interface classes this class implements directly. This does not include interfaces implemented by a super class of this.

Returns:
array of interfaces, never null.

getComponentType

public Class<?> getComponentType()
getComponentType returns the element type of an array. If this is not an array, the result is null

Returns:
element type of this array type, or null for a non-array.
Since:
JDK 1.1

getModifiers

public int getModifiers()
getModifiers returns modifier set for this class

Returns:
the modifiers set of values Modifier.PUBLIC, Modifier.PRIVATE, Modifier.PROTECTED, Modifier.FINAL, Modifier.INTERFACE, Modifier.ABSTRACT, Modifier.STRICT;
Since:
JDK 1.1

getSigners

public Object[] getSigners()
getSigners returns the signers of this class, or null if there are none or this is a primitive type.

Returns:
array of signers or null.
Since:
JDK 1.1

getDeclaringClass

public Class<?> getDeclaringClass()
getDeclaringClass returns the declaring class for an anonymous inner class. The declaring class is the class that directly contains the inner class declaration.

Returns:
the declaring class or null if this is an array, primitive type or it is not an inner class.
Since:
JDK 1.1

getClasses

public Class<?>[] getClasses()
getClasses returns array of classes that are public members of this class or any of this class' superclasses. If this class has no public members or if it is an array or primitive type, this returns an empty array.

Returns:
a new array of the public members of this class.
Throws:
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.PUBLIC) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
Since:
JDK 1.1

getFields

public Field[] getFields()
                  throws SecurityException
Looks for all public fields in this class and its super classes.

Returns:
array containing all public fields accessible through this class.
Throws:
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.PUBLIC) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
Since:
JDK 1.1

getMethods

public Method[] getMethods()
                    throws SecurityException
getMethods returns an array of all public methods of this class.

Returns:
array of methods of this class.
Throws:
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.PUBLIC) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
Since:
JDK 1.1

getConstructors

public Constructor<?>[] getConstructors()
                                 throws SecurityException
getConstructors returns an array of all public constructors of this class.

Returns:
array of constructors of this class.
Throws:
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.PUBLIC) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
Since:
JDK 1.1

getField

public Field getField(String name)
               throws NoSuchFieldException,
                      SecurityException
Looks for a public field accessible through this class.

Parameters:
name - Name of the field.
Returns:
The field if one was found.
Throws:
NoSuchFieldException - If no public field with this name was found.
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.PUBLIC) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
Since:
JDK 1.1

getMethod

public Method getMethod(String name,
                        Class<?>... parameterTypes)
                 throws NoSuchMethodException,
                        SecurityException
getMethod finds the public method with given name and parameter types in this class.

Parameters:
name - the name of the method.
parameterTypes - the parameter types of the method.
Returns:
the method to be found
Throws:
NoSuchMethodException - in case the method was not found.
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.PUBLIC) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
Since:
JDK 1.1

getConstructor

public Constructor<T> getConstructor(Class<?>... parameterTypes)
                              throws NoSuchMethodException,
                                     SecurityException
getConstructor finds the public constructor with given parameter types in this class.

Parameters:
parameterTypes - the parameter types of the constructor.
Returns:
the constructor that was found, never null.
Throws:
NoSuchMethodException - in case the constructor was not found.
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.PUBLIC) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
Since:
JDK 1.1

getDeclaredClasses

public Class<?>[] getDeclaredClasses()
                              throws SecurityException
getDeclaredClasses returns array of classes that are members of this class. If this class has no members or if it is an array or primitive type, this returns an empty array.

Returns:
a new array of members of this class.
Throws:
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.DECLARED) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
Since:
JDK 1.1

getDeclaredFields

public Field[] getDeclaredFields()
                          throws SecurityException
getDeclaredFields returns an array of all the fields declared in this class. Returns an empty array if this class is primitive type or it does not declare any fields.

Returns:
array of fields declared in this class, never null.
Throws:
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.DECLARED) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
Since:
JDK 1.1

getDeclaredMethods

public Method[] getDeclaredMethods()
                            throws SecurityException
getDeclaredMethods returns an array of all methods declared in this class. Returns an empty array if this class is a primitive type or it does not declare any methods.

Returns:
array of methods declared in this class, never null.
Throws:
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.DECLARED) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
Since:
JDK 1.1

getDeclaredConstructors

public Constructor<T>[] getDeclaredConstructors()
getDeclaredConstructors returns an array of all constructors declared in this class. Returns an empty array if this class is a primitive type or it does not declare any constructors.

Returns:
array of constructors declared in this class, never null.
Throws:
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.DECLARED) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
Since:
JDK 1.1

getDeclaredField

public Field getDeclaredField(String name)
                       throws NoSuchFieldException,
                              SecurityException
getDeclaredField searches for a field with the given name that is declared in this class.

Parameters:
name - Name of the field to look for.
Returns:
The Field object of for the given name, never null.
Throws:
NoSuchFieldException - If there is no field with the given name.
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.DECLARED) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
Since:
JDK 1.1

getDeclaredMethod

public Method getDeclaredMethod(String name,
                                Class<?>... parameterTypes)
                         throws NoSuchMethodException,
                                SecurityException
getDeclaredMethod searches for a method with the given name and parameter types in this class.

Parameters:
name - the name of the method
parameterTypes - the parameter types of the method.
Returns:
the method that was found, never null.
Throws:
NoSuchMethodException - if the method was not found.
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.DECLARED) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
Since:
JDK 1.1

getDeclaredConstructor

public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
                                      throws NoSuchMethodException,
                                             SecurityException
getDeclaredConstructor searches for a constructor with given parameter types in this clss.

Parameters:
parameterTypes - the parameter types of the constructor.
Returns:
the constructor that was found, never null.
Throws:
SecurityException - if a security manager sm is installed and a call to sm.checkMemberAccess(c,Member.DECLARED) or sm.checkPackageAccess(c.packageName()) for c being this or any super class of this throws SecurityException.
NoSuchMethodException
Since:
JDK 1.1

getResourceAsStream

public InputStream getResourceAsStream(String name)
Opens resources as InputStream.

Parameters:
name - Name of the resource.
Returns:
An InputStream to read the reource from or null if the resource was not found.
Throws:
NullPointerException - if name is null
Since:
JDK 1.1
See Also:
getResource(String)

getResource

public URL getResource(String name)
getResource gets a resource from the class loader associated with this class. The resource is loaded via ClassLoader.getResource(name), or via ClassLoader.getSystemResource(name) if this class was loaded by the boot class loader.

Parameters:
name - the resource name.
Returns:
an URL to obtain the resource.
Since:
JDK 1.1

getProtectionDomain

public ProtectionDomain getProtectionDomain()
getProtectionDomain returns this class' protection domain.

Returns:
the protection domain obtained from this class' class loader.
Throws:
SecurityException - if a security manager sm is installed and a call to sm.checkPermission(new RuntimePermission("getProtectionDomain")) causes this exception.
Since:
JDK 1.2

desiredAssertionStatus

public boolean desiredAssertionStatus()
If this class would be initialized at this time, its assertion status would be set according to the value returned by this method.

Returns:
true
Since:
1.4

isAnnotation

public boolean isAnnotation()
check if this class instance represents an annotation.

Returns:
true if this is an annotation.
Since:
1.5

isSynthetic

public boolean isSynthetic()
check if this class instance represents a synthetic class

Returns:
true if this is synthetic
Since:
1.5

getGenericSuperclass

public Type getGenericSuperclass()
Return super class including actual generic parameters.

Returns:
super class with generic parameters
Since:
1.5

getGenericInterfaces

public Type[] getGenericInterfaces()
Return array of interfaces implemented by this with actual generic parameters

Returns:
interfaces array with actual generic classes
Since:
1.5

getEnclosingMethod

public Method getEnclosingMethod()
If this Class object represents a local or anonymous class within a method, returns a Method object representing the immediately enclosing method of the underlying class. Returns null otherwise. In particular, this method returns null if the underlying class is a local or anonymous class immediately enclosed by a type declaration, instance initializer or static initializer.

Returns:
the immediately enclosing method of the underlying class, if that class is a local or anonymous class; otherwise null.
Since:
1.5

getEnclosingConstructor

public Constructor<?> getEnclosingConstructor()
If this Class object represents a local or anonymous class within a constructor, returns a Constructor object representing the immediately enclosing constructor of the underlying class. Returns null otherwise. In particular, this method returns null if the underlying class is a local or anonymous class immediately enclosed by a type declaration, instance initializer or static initializer.

Returns:
the immediately enclosing constructor of the underlying class, if that class is a local or anonymous class; otherwise null.
Since:
1.5

getEnclosingClass

public Class<?> getEnclosingClass()
getEnclosingClass returns the enclosing class of an inner class, or null if this is not an inner class.

Returns:
the enclosing class or null.
Since:
1.5

getSimpleName

public String getSimpleName()
getSimpleName returns the plain name of this class without generic arguments. The result for an anonymous inner class is "". The result for an array class is the simple name of its component type followed by "[]".

Returns:
the simple name, never null.
Since:
1.5

getCanonicalName

public String getCanonicalName()
Returns the canonical name of the underlying class as defined by the Java Language Specification. Returns null if the underlying class does not have a canonical name (i.e., if it is a local or anonymous class or an array whose component type does not have a canonical name).

Returns:
the canonical name of the underlying class if it exists, and null otherwise.
Since:
1.5

isAnonymousClass

public boolean isAnonymousClass()
Returns true if and only if the underlying class is an anonymous class.

Returns:
true if and only if this class is an anonymous class.
Since:
1.5

isLocalClass

public boolean isLocalClass()
Returns true if and only if the underlying class is a local class.

Returns:
true if and only if this class is a local class.
Since:
1.5

isMemberClass

public boolean isMemberClass()
Returns true if and only if the underlying class is a member class.

Returns:
true if and only if this class is a member class.
Since:
1.5

isEnum

public boolean isEnum()
isEnum checks if this class is an enumeration class.

Returns:
true iff this is an enum.
Since:
1.5

getEnumConstants

public T[] getEnumConstants()
getEnumConstants returns an array with all the constants of this enumeration type, or null if this is not an enumeration type.

Returns:
array of enumeration constants if isEnum(), null otherwise.
Since:
1.5

cast

public T cast(Object obj)
cast casts a given object to this type.

Parameters:
obj - the object to be casted.
Returns:
the same object after casting
Throws:
ClassCastException - if !isInstance(obj).
Since:
1.5

asSubclass

public <U> Class<? extends U> asSubclass(Class<U> clazz)
asSubclass casts this class to a subclass of this class.

Parameters:
clazz - a subclass of this
Returns:
this class instance
Throws:
ClassCastException - if this is not a subclass of clazz.
Since:
1.5

isAnnotationPresent

public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
Description copied from interface: AnnotatedElement
Returns true if an annotation for the specified type is present on this element, else false. This method is designed primarily for convenient access to marker annotations.

Specified by:
isAnnotationPresent in interface AnnotatedElement
Parameters:
annotationClass - the Class object corresponding to the annotation type
Returns:
true if an annotation for the specified annotation type is present on this element, else false
Throws:
NullPointerException - if the given annotation class is null
Since:
1.5

getAnnotation

public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
Description copied from interface: AnnotatedElement
Returns this element's annotation for the specified type if such an annotation is present, else null.

Specified by:
getAnnotation in interface AnnotatedElement
Parameters:
annotationClass - the Class object corresponding to the annotation type
Returns:
this element's annotation for the specified annotation type if present on this element, else null
Throws:
NullPointerException - if the given annotation class is null
Since:
1.5

getAnnotations

public Annotation[] getAnnotations()
Description copied from interface: AnnotatedElement
Returns all annotations present on this element. (Returns an array of length zero if this element has no annotations.) The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Specified by:
getAnnotations in interface AnnotatedElement
Returns:
all annotations present on this element
Since:
1.5

getDeclaredAnnotations

public Annotation[] getDeclaredAnnotations()
Description copied from interface: AnnotatedElement
Returns all annotations that are directly present on this element. Unlike the other methods in this interface, this method ignores inherited annotations. (Returns an array of length zero if no annotations are directly present on this element.) The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Specified by:
getDeclaredAnnotations in interface AnnotatedElement
Returns:
All annotations directly present on this element
Since:
1.5

getTypeParameters

public TypeVariable<Class<T>>[] getTypeParameters()
Return an array of the declared type parameters for a generic class.

Specified by:
getTypeParameters in interface GenericDeclaration
Returns:
array of type declared type parameters.
Since:
1.5

aicas logoJamaica 6.1 release 1

aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2012 aicas GmbH. All Rights Reserved.