The documented natives must be implemented to support other provided class implementations in this package. An instance of class Class is the in-image representation of a Java class. There are three basic types of Classes
B
representing the byte
base type S
representing the short
base type I
representing the int
base type J
representing the long
base type F
representing the float
base type D
representing the double
base type C
representing the char
base type Z
representing the boolean
base type V
representing void function return values int
base type.
Public Member Functions | |
Class[] | getClasses () |
Answers an array containing all public class members of the class which the receiver represents and its super classes and interfaces. | |
Annotation[] | getAnnotations () |
Answers all the annotations of the receiver. | |
String | getCanonicalName () |
Answers the canonical name of the receiver. | |
ClassLoader | getClassLoader () |
Answers the class loader which was used to load the class represented by the receiver. | |
Class<?> | getComponentType () |
Answers a Class object which represents the receiver's component type if the receiver represents an array type. | |
Constructor< T > | getConstructor (Class...parameterTypes) throws NoSuchMethodException, SecurityException |
Answers a public Constructor object which represents the constructor described by the arguments. | |
Constructor[] | getConstructors () throws SecurityException |
Answers an array containing Constructor objects describing all constructors which are visible from the current execution context. | |
Annotation[] | getDeclaredAnnotations () |
Answers the annotations that are directly defined on this type. | |
Class[] | getDeclaredClasses () throws SecurityException |
Answers an array containing all class members of the class which the receiver represents. | |
Constructor< T > | getDeclaredConstructor (Class...parameterTypes) throws NoSuchMethodException, SecurityException |
Answers a Constructor object which represents the constructor described by the arguments. | |
Constructor[] | getDeclaredConstructors () throws SecurityException |
Answers an array containing Constructor objects describing all constructor which are defined by the receiver. | |
Field | getDeclaredField (String name) throws NoSuchFieldException, SecurityException |
Answers a Field object describing the field in the receiver named by the argument. | |
Field[] | getDeclaredFields () throws SecurityException |
Answers an array containing Field objects describing all fields which are defined by the receiver. | |
Method | getDeclaredMethod (String name, Class...parameterTypes) throws NoSuchMethodException, SecurityException |
Answers a Method object which represents the method described by the arguments. | |
Method[] | getDeclaredMethods () throws SecurityException |
Answers an array containing Method objects describing all methods which are defined by the receiver. | |
Class<?> | getDeclaringClass () |
Answers the class which declared the class represented by the receiver. | |
Class<?> | getEnclosingClass () |
Answers the class that directly encloses the receiver. | |
Constructor<?> | getEnclosingConstructor () |
Gets the Constructor, which encloses the declaration of this class, if it is an anonymous or local/automatic class, otherwise null . | |
Method | getEnclosingMethod () |
Gets the Method, which encloses the declaration of this class, if it is an anonymous or local/automatic class, otherwise null . | |
T[] | getEnumConstants () |
Gets the enum constants/fields associated with this class if it is an isEnum() enum}, otherwise null . | |
Field | getField (String name) throws NoSuchFieldException, SecurityException |
Answers a Field object describing the field in the receiver named by the argument which must be visible from the current execution context. | |
Field[] | getFields () throws SecurityException |
Answers an array containing Field objects describing all fields which are visible from the current execution context. | |
Type[] | getGenericInterfaces () |
Gets the types of the interface that this class directly implements. | |
Type | getGenericSuperclass () |
Gets the Type that represents the super class of this class. | |
Class[] | getInterfaces () |
Answers an array of Class objects which match the interfaces specified in the receiver classes implements declaration. | |
Method | getMethod (String name, Class...parameterTypes) throws NoSuchMethodException, SecurityException |
Answers a Method object which represents the method described by the arguments. | |
Method[] | getMethods () throws SecurityException |
Answers an array containing Method objects describing all methods which are visible from the current execution context. | |
int | getModifiers () |
Answers an integer which which is the receiver's modifiers. | |
String | getName () |
Answers the name of the class which the receiver represents. | |
String | getSimpleName () |
Answers the simple name of the receiver as defined in the source code. | |
ProtectionDomain | getProtectionDomain () |
Answers the ProtectionDomain of the receiver. | |
URL | getResource (String resName) |
Answers a read-only stream on the contents of the resource specified by resName. | |
InputStream | getResourceAsStream (String resName) |
Answers a read-only stream on the contents of the resource specified by resName. | |
Object[] | getSigners () |
Answers the signers for the class represented by the receiver, or null if there are no signers. | |
Class<?super T > | getSuperclass () |
Answers the Class which represents the receiver's superclass. | |
TypeVariable< Class< T > >[] | getTypeParameters () |
Gets the type variables associated with this class. | |
boolean | isAnnotation () |
Indicates whether or not this class is an annotation. | |
boolean | isAnnotationPresent (Class<?extends Annotation > annotationClass) |
Indicates whether or not the given annotation is present for this class. | |
boolean | isAnonymousClass () |
Indicates whether or not this class was anonymously declared. | |
boolean | isArray () |
Answers true if the receiver represents an array class. | |
boolean | isAssignableFrom (Class<?> cls) |
Answers true if the type represented by the argument can be converted via an identity conversion or a widening reference conversion (i.e. | |
boolean | isEnum () |
Indicates whether or not this class is an enum . | |
boolean | isInstance (Object object) |
Answers true if the argument is non-null and can be cast to the type of the receiver. | |
boolean | isInterface () |
Answers true if the receiver represents an interface. | |
boolean | isLocalClass () |
Answers whether the receiver is defined locally. | |
boolean | isMemberClass () |
Answers whether the receiver is a member class. | |
boolean | isPrimitive () |
Answers true if the receiver represents a base type. | |
boolean | isSynthetic () |
Answers whether the receiver is a synthetic type. | |
T | newInstance () throws IllegalAccessException, InstantiationException |
Answers a new instance of the class represented by the receiver, created by invoking the default (i.e. | |
String | toString () |
Answers a string containing a concise, human-readable description of the receiver. | |
Package | getPackage () |
Returns the Package of which this class is a member. | |
boolean | desiredAssertionStatus () |
Returns the assertion status for this class. | |
T | cast (Object obj) |
Cast the given object to the type T . | |
Static Public Member Functions | |
static Class<?> | forName (String className) throws ClassNotFoundException |
Answers a Class object which represents the class named by the argument. | |
static Class<?> | forName (String className, boolean initializeBoolean, ClassLoader classLoader) throws ClassNotFoundException |
Answers a Class object which represents the class named by the argument. | |
Package Functions | |
void | verify () |
Verify the specified Class using the VM byte code verifier. | |
public< A extends Annotation > A | getAnnotation (Class< A > annotationClass) |
Answers the annotation of the given type. | |
ClassLoader | getClassLoaderImpl () |
This must be provided by the VM vendor, as it is used by other provided class implementations in this package. | |
ProtectionDomain | getPDImpl () |
Answers the ProtectionDomain of the receiver. | |
public< U > Class<?extends U > | asSubclass (Class< U > clazz) |
Casts the receiver to a subclass of the given class. | |
Static Package Functions | |
static final Class[] | getStackClasses (int maxDepth, boolean stopAtPrivileged) |
This must be provided by the VM vendor, as it is used by other provided class implementations in this package. | |
Static Private Attributes | |
static final long | serialVersionUID = 3206093459760846163L |
static final Class [] java.lang.Class< T >.getStackClasses | ( | int | maxDepth, | |
boolean | stopAtPrivileged | |||
) | [static, package] |
This must be provided by the VM vendor, as it is used by other provided class implementations in this package.
This method is used by SecurityManager.classDepth(), and getClassContext() which use the parameters (-1, false) and SecurityManager.classLoaderDepth(), currentClassLoader(), and currentLoadedClass() which use the parameters (-1, true). Walk the stack and answer an array containing the maxDepth most recent classes on the stack of the calling thread. Starting with the caller of the caller of getStackClasses(), return an array of not more than maxDepth Classes representing the classes of running methods on the stack (including native methods). Frames representing the VM implementation of java.lang.reflect are not included in the list. If stopAtPrivileged is true, the walk will terminate at any frame running one of the following methods:
If one of the doPrivileged methods is found, the walk terminate and that frame is NOT included in the returned array. Notes:
maxDepth | maximum depth to walk the stack, -1 for the entire stack | |
stopAtPrivileged | stop at privileged classes |
static Class<?> java.lang.Class< T >.forName | ( | String | className | ) | throws ClassNotFoundException [static] |
Answers a Class object which represents the class named by the argument.
The name should be the name of a class as described in the class definition of Class
, however Classes representing base types can not be found using this method.
className | The name of the non-base type class to find |
ClassNotFoundException | If the class could not be found |
static Class<?> java.lang.Class< T >.forName | ( | String | className, | |
boolean | initializeBoolean, | |||
ClassLoader | classLoader | |||
) | throws ClassNotFoundException [static] |
Answers a Class object which represents the class named by the argument.
The name should be the name of a class as described in the class definition of Class
, however Classes representing base types can not be found using this method. Security rules will be obeyed.
className | The name of the non-base type class to find | |
initializeBoolean | A boolean indicating whether the class should be initialized | |
classLoader | The class loader to use to load the class |
ClassNotFoundException | If the class could not be found |
Class [] java.lang.Class< T >.getClasses | ( | ) |
Answers an array containing all public class members of the class which the receiver represents and its super classes and interfaces.
SecurityException | If member access is not allowed |
void java.lang.Class< T >.verify | ( | ) | [package] |
Verify the specified Class using the VM byte code verifier.
VerifyError | if the Class cannot be verified |
public<A extends Annotation> A java.lang.Class< T >.getAnnotation | ( | Class< A > | annotationClass | ) | [package] |
Answers the annotation of the given type.
If there is no annotation the method returns null
.
annotationClass | the annotation type. |
null
if none. Annotation [] java.lang.Class< T >.getAnnotations | ( | ) |
Answers all the annotations of the receiver.
If there are no annotations then answers an empty array.
String java.lang.Class< T >.getCanonicalName | ( | ) |
Answers the canonical name of the receiver.
If the receiver does not have a canonical name, as defined in the Java Language Specification, then the method returns null
.
null
. ClassLoader java.lang.Class< T >.getClassLoader | ( | ) |
Answers the class loader which was used to load the class represented by the receiver.
Answer null if the class was loaded by the system class loader
ClassLoader java.lang.Class< T >.getClassLoaderImpl | ( | ) | [package] |
This must be provided by the VM vendor, as it is used by other provided class implementations in this package.
Outside of this class, it is used by SecurityManager.checkMemberAccess(), classLoaderDepth(), currentClassLoader() and currentLoadedClass(). Return the ClassLoader for this Class without doing any security checks. The bootstrap ClassLoader is returned, unlike getClassLoader() which returns null in place of the bootstrap ClassLoader.
Class<?> java.lang.Class< T >.getComponentType | ( | ) |
Answers a Class object which represents the receiver's component type if the receiver represents an array type.
Otherwise answers null. The component type of an array type is the type of the elements of the array.
Constructor<T> java.lang.Class< T >.getConstructor | ( | Class< T >... | parameterTypes | ) | throws NoSuchMethodException, SecurityException |
Answers a public Constructor object which represents the constructor described by the arguments.
parameterTypes | the types of the arguments. |
NoSuchMethodException | if the constructor could not be found. | |
SecurityException | if member access is not allowed |
Constructor [] java.lang.Class< T >.getConstructors | ( | ) | throws SecurityException |
Answers an array containing Constructor objects describing all constructors which are visible from the current execution context.
SecurityException | if member access is not allowed |
Annotation [] java.lang.Class< T >.getDeclaredAnnotations | ( | ) |
Answers the annotations that are directly defined on this type.
Annotations that are inherited are not included in the result. If there are no annotations, returns an empty array.
Class [] java.lang.Class< T >.getDeclaredClasses | ( | ) | throws SecurityException |
Answers an array containing all class members of the class which the receiver represents.
Note that some of the fields which are returned may not be visible in the current execution context.
SecurityException | if member access is not allowed |
Constructor<T> java.lang.Class< T >.getDeclaredConstructor | ( | Class< T >... | parameterTypes | ) | throws NoSuchMethodException, SecurityException |
Answers a Constructor object which represents the constructor described by the arguments.
parameterTypes | the types of the arguments. |
NoSuchMethodException | if the constructor could not be found. | |
SecurityException | if member access is not allowed |
Constructor [] java.lang.Class< T >.getDeclaredConstructors | ( | ) | throws SecurityException |
Answers an array containing Constructor objects describing all constructor which are defined by the receiver.
Note that some of the fields which are returned may not be visible in the current execution context.
SecurityException | if member access is not allowed |
Field java.lang.Class< T >.getDeclaredField | ( | String | name | ) | throws NoSuchFieldException, SecurityException |
Answers a Field object describing the field in the receiver named by the argument.
Note that the Constructor may not be visible from the current execution context.
name | The name of the field to look for. |
NoSuchFieldException | if the requested field could not be found | |
SecurityException | if member access is not allowed |
Field [] java.lang.Class< T >.getDeclaredFields | ( | ) | throws SecurityException |
Answers an array containing Field objects describing all fields which are defined by the receiver.
Note that some of the fields which are returned may not be visible in the current execution context.
SecurityException | If member access is not allowed |
Method java.lang.Class< T >.getDeclaredMethod | ( | String | name, | |
Class< T >... | parameterTypes | |||
) | throws NoSuchMethodException, SecurityException |
Answers a Method object which represents the method described by the arguments.
Note that the associated method may not be visible from the current execution context.
name | the name of the method | |
parameterTypes | the types of the arguments. |
NoSuchMethodException | if the method could not be found. | |
SecurityException | If member access is not allowed | |
NullPointerException | if the name parameter is null . |
Method [] java.lang.Class< T >.getDeclaredMethods | ( | ) | throws SecurityException |
Answers an array containing Method objects describing all methods which are defined by the receiver.
Note that some of the methods which are returned may not be visible in the current execution context.
SecurityException | if member access is not allowed |
Class<?> java.lang.Class< T >.getDeclaringClass | ( | ) |
Answers the class which declared the class represented by the receiver.
This will return null if the receiver is a member of another class.
Class<?> java.lang.Class< T >.getEnclosingClass | ( | ) |
Answers the class that directly encloses the receiver.
If there is no enclosing class the method returns null
.
null
. Constructor<?> java.lang.Class< T >.getEnclosingConstructor | ( | ) |
Gets the Constructor, which encloses the declaration of this class, if it is an anonymous or local/automatic class, otherwise null
.
null
. Method java.lang.Class< T >.getEnclosingMethod | ( | ) |
T [] java.lang.Class< T >.getEnumConstants | ( | ) |
Gets the enum
constants/fields associated with this class if it is an isEnum() enum}, otherwise null
.
enum
constants for this class or null
. Field java.lang.Class< T >.getField | ( | String | name | ) | throws NoSuchFieldException, SecurityException |
Answers a Field object describing the field in the receiver named by the argument which must be visible from the current execution context.
name | The name of the field to look for. |
NoSuchFieldException | If the given field does not exist | |
SecurityException | If access is denied |
Field [] java.lang.Class< T >.getFields | ( | ) | throws SecurityException |
Answers an array containing Field objects describing all fields which are visible from the current execution context.
SecurityException | If member access is not allowed |
Type [] java.lang.Class< T >.getGenericInterfaces | ( | ) |
Type java.lang.Class< T >.getGenericSuperclass | ( | ) |
Class [] java.lang.Class< T >.getInterfaces | ( | ) |
Answers an array of Class objects which match the interfaces specified in the receiver classes implements
declaration.
Method java.lang.Class< T >.getMethod | ( | String | name, | |
Class< T >... | parameterTypes | |||
) | throws NoSuchMethodException, SecurityException |
Answers a Method object which represents the method described by the arguments.
name | String the name of the method | |
parameterTypes | Class[] the types of the arguments. |
NoSuchMethodException | if the method could not be found. | |
SecurityException | if member access is not allowed |
Method [] java.lang.Class< T >.getMethods | ( | ) | throws SecurityException |
Answers an array containing Method objects describing all methods which are visible from the current execution context.
SecurityException | if member access is not allowed |
int java.lang.Class< T >.getModifiers | ( | ) |
Answers an integer which which is the receiver's modifiers.
Note that the constants which describe the bits which are returned are implemented in class Modifier which may not be available on the target.
String java.lang.Class< T >.getName | ( | ) |
Answers the name of the class which the receiver represents.
For a description of the format which is used, see the class definition of Class
.
String java.lang.Class< T >.getSimpleName | ( | ) |
Answers the simple name of the receiver as defined in the source code.
If there is no name (the class is anonymous) returns an empty string, and if the receiver is an array returns the name of the underlying type with square braces appended (e.g. "Integer[]"
).
ProtectionDomain java.lang.Class< T >.getProtectionDomain | ( | ) |
Answers the ProtectionDomain of the receiver.
Note: In order to conserve space in embedded targets, we allow this method to answer null for classes in the system protection domain (i.e. for system classes). System classes are always given full permissions (i.e. AllPermission). This is not changeable via the java.security.Policy.
ProtectionDomain java.lang.Class< T >.getPDImpl | ( | ) | [package] |
Answers the ProtectionDomain of the receiver.
This method is for internal use only.
URL java.lang.Class< T >.getResource | ( | String | resName | ) |
Answers a read-only stream on the contents of the resource specified by resName.
The mapping between the resource name and the stream is managed by the class' class loader.
resName | the name of the resource. |
InputStream java.lang.Class< T >.getResourceAsStream | ( | String | resName | ) |
Answers a read-only stream on the contents of the resource specified by resName.
The mapping between the resource name and the stream is managed by the class' class loader.
resName | the name of the resource. |
Object [] java.lang.Class< T >.getSigners | ( | ) |
Answers the signers for the class represented by the receiver, or null if there are no signers.
Class<? super T> java.lang.Class< T >.getSuperclass | ( | ) |
Answers the Class which represents the receiver's superclass.
For Classes which represent base types, interfaces, and for Object the method answers null.
TypeVariable<Class<T> > [] java.lang.Class< T >.getTypeParameters | ( | ) |
Gets the type variables associated with this class.
boolean java.lang.Class< T >.isAnnotation | ( | ) |
Indicates whether or not this class is an annotation.
true
if this class is an annotation, otherwise false
. boolean java.lang.Class< T >.isAnnotationPresent | ( | Class<?extends Annotation > | annotationClass | ) |
Indicates whether or not the given annotation is present for this class.
annotationClass | The annotation to look for in this class. |
true
if the annotation is present, otherwise false
. boolean java.lang.Class< T >.isAnonymousClass | ( | ) |
Indicates whether or not this class was anonymously declared.
true
if this class is anonymous, otherwise false
. boolean java.lang.Class< T >.isArray | ( | ) |
Answers true if the receiver represents an array class.
true
if the receiver represents an array class false
if it does not represent an array class boolean java.lang.Class< T >.isAssignableFrom | ( | Class<?> | cls | ) |
Answers true if the type represented by the argument can be converted via an identity conversion or a widening reference conversion (i.e.
if either the receiver or the argument represent primitive types, only the identity conversion applies).
true
the argument can be assigned into the receiver false
the argument cannot be assigned into the receiver cls | Class the class to test |
NullPointerException | if the parameter is null |
boolean java.lang.Class< T >.isEnum | ( | ) |
Indicates whether or not this class is an enum
.
true
if this class is an Enum, otherwise false
. boolean java.lang.Class< T >.isInstance | ( | Object | object | ) |
Answers true if the argument is non-null and can be cast to the type of the receiver.
This is the runtime version of the instanceof
operator.
true
the argument can be cast to the type of the receiver false
the argument is null or cannot be cast to the type of the receiver object | Object the object to test |
boolean java.lang.Class< T >.isInterface | ( | ) |
Answers true if the receiver represents an interface.
true
if the receiver represents an interface false
if it does not represent an interface boolean java.lang.Class< T >.isLocalClass | ( | ) |
Answers whether the receiver is defined locally.
true
if the class is local, otherwise false
. boolean java.lang.Class< T >.isMemberClass | ( | ) |
Answers whether the receiver is a member class.
true
if the class is a member class, otherwise false
. boolean java.lang.Class< T >.isPrimitive | ( | ) |
Answers true if the receiver represents a base type.
true
if the receiver represents a base type false
if it does not represent a base type boolean java.lang.Class< T >.isSynthetic | ( | ) |
Answers whether the receiver is a synthetic type.
true
if the receiver is a synthetic type and false
otherwise. T java.lang.Class< T >.newInstance | ( | ) | throws IllegalAccessException, InstantiationException |
Answers a new instance of the class represented by the receiver, created by invoking the default (i.e.
zero-argument) constructor. If there is no such constructor, or if the creation fails (either because of a lack of available memory or because an exception is thrown by the constructor), an InstantiationException is thrown. If the default constructor exists, but is not accessible from the context where this message is sent, an IllegalAccessException is thrown.
IllegalAccessException | if the constructor is not visible to the sender. | |
InstantiationException | if the instance could not be created. |
String java.lang.Class< T >.toString | ( | ) |
Answers a string containing a concise, human-readable description of the receiver.
Package java.lang.Class< T >.getPackage | ( | ) |
boolean java.lang.Class< T >.desiredAssertionStatus | ( | ) |
Returns the assertion status for this class.
Assertion is enabled/disabled based on class loader default, package or class default at runtime
public<U> Class<? extends U> java.lang.Class< T >.asSubclass | ( | Class< U > | clazz | ) | [package] |
Casts the receiver to a subclass of the given class.
If successful answers the receiver, otherwise if the cast cannot be made throws a ClassCastException
.
clazz | the required type. |
ClassCastException | if the class cannot be cast to the given type. |
T java.lang.Class< T >.cast | ( | Object | obj | ) |
Cast the given object to the type T
.
If the object is null
the result is also null
.
obj | the object to cast |
ClassCastException | if the object cannot be cast to the given type. |
Genereated on Tue Dec 9 14:09:47 2008 by Doxygen.
(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.