| java.lang.Object | |
| ↳ | java.lang.Class<T> |
This class must be implemented by the VM vendor. 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 typeS representing the short base typeI representing the int base typeJ representing the long base typeF representing the float base typeD representing the double base typeC representing the char base typeZ representing the boolean base typeV representing void function return valuesint
base type.| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Casts the receiver to a subclass of the given class.
| |||||||||||
Cast the given object to the type
T. | |||||||||||
Returns the assertion status for this class.
| |||||||||||
Returns a Class object which represents the class named by the argument.
| |||||||||||
Returns a Class object which represents the class named by the argument.
| |||||||||||
Returns the annotation of the given type.
| |||||||||||
Returns all the annotations of the receiver.
| |||||||||||
Returns the canonical name of the receiver.
| |||||||||||
Returns the class loader which was used to load the class represented by
the receiver.
| |||||||||||
Returns an array containing all public class members of the class which
the receiver represents and its super classes and interfaces
| |||||||||||
Returns a Class object which represents the receiver's component type if
the receiver represents an array type.
| |||||||||||
Returns a public Constructor object which represents the constructor
described by the arguments.
| |||||||||||
Returns an array containing Constructor objects describing all
constructors which are visible from the current execution context.
| |||||||||||
Returns the annotations that are directly defined on this type.
| |||||||||||
Returns an array containing all class members of the class which the
receiver represents.
| |||||||||||
Returns a Constructor object which represents the constructor described
by the arguments.
| |||||||||||
Returns an array containing Constructor objects describing all
constructor which are defined by the receiver.
| |||||||||||
Returns a Field object describing the field in the receiver named by the
argument.
| |||||||||||
Returns an array containing Field objects describing all fields which are
defined by the receiver.
| |||||||||||
Returns a Method object which represents the method described by the
arguments.
| |||||||||||
Returns an array containing Method objects describing all methods which
are defined by the receiver.
| |||||||||||
Returns the class which declared the class represented by the receiver.
| |||||||||||
Returns the class that directly encloses the receiver.
| |||||||||||
Gets the Constructor, which encloses the declaration of this
class, if it is an anonymous or local/automatic class, otherwise
null. | |||||||||||
Gets the Method, which encloses the declaration of this class,
if it is an anonymous or local/automatic class, otherwise
null. | |||||||||||
Returns a Field object describing the field in the receiver named by the
argument which must be visible from the current execution context.
| |||||||||||
Returns an array containing Field objects describing all fields which are
visible from the current execution context.
| |||||||||||
Gets the types of the interface that this class directly
implements.
| |||||||||||
Gets the Type that represents the super class of this class.
| |||||||||||
Returns an array of Class objects which match the interfaces specified in
the receiver classes
implements declaration. | |||||||||||
Returns a Method object which represents the method described by the
arguments.
| |||||||||||
Returns an array containing Method objects describing all methods which
are visible from the current execution context.
| |||||||||||
Returns an integer which which is the receiver's modifiers.
| |||||||||||
Returns the name of the class which the receiver represents.
| |||||||||||
Returns the Package of which this class is a member.
| |||||||||||
Returns the ProtectionDomain of the receiver.
| |||||||||||
Returns a read-only stream on the contents of the resource specified by
resName.
| |||||||||||
Returns a read-only stream on the contents of the resource specified by
resName.
| |||||||||||
Returns the signers for the class represented by the receiver, or null if
there are no signers.
| |||||||||||
Returns the simple name of the receiver as defined in the source code.
| |||||||||||
Returns the Class which represents the receiver's superclass.
| |||||||||||
Gets the type variables associated with this class.
| |||||||||||
Indicates whether or not this class is an annotation.
| |||||||||||
Indicates whether or not the given annotation is present for this class.
| |||||||||||
Indicates whether or not this class was anonymously declared.
| |||||||||||
Returns true if the receiver represents an array class.
| |||||||||||
Returns true if the type represented by the argument can be converted via
an identity conversion or a widening reference conversion (i.e.
| |||||||||||
Indicates whether or not this class is an
enum. | |||||||||||
Returns true if the argument is non-null and can be cast to the type of
the receiver.
| |||||||||||
Returns true if the receiver represents an interface.
| |||||||||||
Returns whether the receiver is defined locally.
| |||||||||||
Returns whether the receiver is a member class.
| |||||||||||
Returns true if the receiver represents a base type.
| |||||||||||
Returns whether the receiver is a synthetic type.
| |||||||||||
Returns a new instance of the class represented by the receiver, created
by invoking the default (i.e.
| |||||||||||
Returns a string containing a concise, human-readable description of the
receiver.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
| |||||||||||
From interface java.lang.reflect.AnnotatedElement
| |||||||||||
From interface java.lang.reflect.GenericDeclaration
| |||||||||||
Casts the receiver to a subclass of the given class. If successful
returns 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. |
|---|
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. |
|---|
Returns the assertion status for this class. Assertion is enabled/disabled based on class loader default, package or class default at runtime
Returns 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 |
|---|
Returns 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 |
|---|
Returns the annotation of the given type. If there is no annotation the
method returns null.
| annotationClass | the annotation type. |
|---|
null if none.Returns all the annotations of the receiver. If there are no annotations then returns an empty array.
Returns 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.
Returns the class loader which was used to load the class represented by the receiver. Returns null if the class was loaded by the bootstrap class loader
Returns 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 |
|---|
Returns a Class object which represents the receiver's component type if the receiver represents an array type. Otherwise returns nil. The component type of an array type is the type of the elements of the array.
Returns 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 |
Returns an array containing Constructor objects describing all constructors which are visible from the current execution context.
| SecurityException | if member access is not allowed |
|---|
Returns 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.
Returns 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 |
|---|
Returns 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 |
Returns 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 |
|---|
Returns 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 |
Returns 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 |
|---|
Returns 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. |
Returns 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 |
|---|
Returns the class which declared the class represented by the receiver. This will return null if the receiver is a member of another class.
Returns the class that directly encloses the receiver. If there is no
enclosing class the method returns null.
null.
Gets the Constructor, which encloses the declaration of this
class, if it is an anonymous or local/automatic class, otherwise
null.
null.Gets the enum constants/fields associated with this class
if it is an enum, otherwise null.
enum constants for this class or
null.Returns 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 |
Returns an array containing Field objects describing all fields which are visible from the current execution context.
| SecurityException | If member access is not allowed |
|---|
Returns an array of Class objects which match the interfaces specified in
the receiver classes implements declaration. The order of
entries equals the order in the original class declaration. If the
class doesn't implement any interfaces, an empty array is returned.
Returns 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 |
Returns an array containing Method objects describing all methods which are visible from the current execution context.
| SecurityException | if member access is not allowed |
|---|
Returns 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.
Returns the Package of which this class is a member. A class has a Package if it was loaded from a SecureClassLoader
Returns 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.
Returns 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. |
|---|
Returns 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. |
|---|
Returns the signers for the class represented by the receiver, or null if there are no signers.
Returns 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[]").
Returns the Class which represents the receiver's superclass. For Classes which represent base types, interfaces, and for Object the method returns null.
Gets the type variables associated with this class. Returns an empty array if the class is not generic or does not make use of type variables otherwise.
Indicates whether or not this class is an annotation.
true if this class is an annotation,
otherwise false.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.Indicates whether or not this class was anonymously declared.
true if this class is anonymous,
otherwise false.Returns 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
Returns 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).
| cls | Class the class to test |
|---|
true the argument can be assigned into the
receiver false the argument cannot be assigned
into the receiver| NullPointerException | if the parameter is null |
|---|
Indicates whether or not this class is an enum.
true if this class is an Enum,
otherwise false.Returns 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.
| object | Object the object to test |
|---|
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 receiverReturns true if the receiver represents an interface.
true if the receiver represents an interface
false if it does not represent an interface
Returns whether the receiver is defined locally.
true if the class is local, otherwise
false.
Returns whether the receiver is a member class.
true if the class is a member class, otherwise
false.
Returns 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
Returns whether the receiver is a synthetic type.
true if the receiver is a synthetic type and
false otherwise.
Returns 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. |
Returns a string containing a concise, human-readable description of the receiver.