Class represent classes and interfaces in a running Java application.
More...
#include <java_lang_Class.h>
Inheritance diagram for java::lang::Class:


Public Types | |
| enum | { xmogDefaultFlags = xmog_base::GLOBAL, xmogMajorVersion = 3, xmogMinorVersion = 2, xmogPatchVersion = 9, xmogBuildNumber = 2047 } |
|
typedef ::xmog_java_array_template< ::java::lang::Class > | array1D |
|
typedef ::xmog_java_array_template< ::xmog_java_array_template< ::java::lang::Class > > | array2D |
Public Member Functions | |
| bool | desiredAssertionStatus (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
| Returns the assertion status that would be assigned to this class if it were to be initialized at the time this method is invoked. | |
| ::xmog_java_array_template< ::java::lang::Class > | getClasses (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns an array containing Class objects representing all the public classes and interfaces that are members of the class represented by this Class object. | |
| ::java::lang::Class | getComponentType (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns the Class representing the component type of an array. | |
| ::java::lang::reflect::Constructor | getConstructor (const ::xmog_java_array_template< ::java::lang::Class > ¶meterTypes,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns a Constructor object that reflects the specified public constructor of the class represented by this Class object. | |
| ::xmog_java_array_template< ::java::lang::reflect::Constructor > | getConstructors (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns an array containing Constructor objects reflecting all the public constructors of the class represented by this Class object. | |
| ::xmog_java_array_template< ::java::lang::Class > | getDeclaredClasses (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns an array of Class objects reflecting all the classes and interfaces declared as members of the class represented by this Class object. | |
| ::java::lang::reflect::Constructor | getDeclaredConstructor (const ::xmog_java_array_template< ::java::lang::Class > ¶meterTypes,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns a Constructor object that reflects the specified constructor of the class or interface represented by this Class object. | |
| ::xmog_java_array_template< ::java::lang::reflect::Constructor > | getDeclaredConstructors (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns an array of Constructor objects reflecting all the constructors declared by the class represented by this Class object. | |
| ::java::lang::reflect::Field | getDeclaredField (const ::java::lang::String &name,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns a Field object that reflects the specified declared field of the class or interface represented by this Class object. | |
| ::xmog_java_array_template< ::java::lang::reflect::Field > | getDeclaredFields (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns an array of Field objects reflecting all the fields declared by the class or interface represented by this Class object. | |
| ::java::lang::reflect::Method | getDeclaredMethod (const ::java::lang::String &name, const ::xmog_java_array_template< ::java::lang::Class > ¶meterTypes,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns a Method object that reflects the specified declared method of the class or interface represented by this Class object. | |
| ::xmog_java_array_template< ::java::lang::reflect::Method > | getDeclaredMethods (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns an array of Method objects reflecting all the methods declared by the class or interface represented by this Class object. | |
| ::java::lang::Class | getDeclaringClass (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
If the class or interface represented by this Class object is a member of another class, returns the Class object representing the class in which it was declared. | |
| ::java::lang::reflect::Field | getField (const ::java::lang::String &name,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns a Field object that reflects the specified public member field of the class or interface represented by this Class object. | |
| ::xmog_java_array_template< ::java::lang::reflect::Field > | getFields (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns an array containing Field objects reflecting all the accessible public fields of the class or interface represented by this Class object. | |
| ::xmog_java_array_template< ::java::lang::Class > | getInterfaces (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
| Determines the interfaces implemented by the class or interface represented by this object. | |
| ::java::lang::reflect::Method | getMethod (const ::java::lang::String &name, const ::xmog_java_array_template< ::java::lang::Class > ¶meterTypes,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns a Method object that reflects the specified public member method of the class or interface represented by this Class object. | |
| ::xmog_java_array_template< ::java::lang::reflect::Method > | getMethods (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns an array containing Method objects reflecting all the public member methods of the class or interface represented by this Class object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces. | |
| jint | getModifiers (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
| Returns the Java language modifiers for this class or interface, encoded in an integer. | |
| ::java::lang::String | getName (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String. | |
| ::java::io::InputStream | getResourceAsStream (const ::java::lang::String &name,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
| Finds a resource with a given name. | |
| ::xmog_java_array_template< ::java::lang::Object > | getSigners (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
| Gets the signers of this class. | |
| ::java::lang::Class | getSuperclass (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns the Class representing the superclass of the entity (class, interface, primitive type or void) represented by this Class. | |
| bool | isArray (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Determines if this Class object represents an array class. | |
| bool | isAssignableFrom (const ::java::lang::Class &cls,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter. | |
| bool | isInstance (const ::java::lang::Object &obj,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Determines if the specified Object is assignment-compatible with the object represented by this Class. | |
| bool | isInterface (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Determines if the specified Class object represents an interface type. | |
| bool | isPrimitive (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Determines if the specified Class object represents a primitive type. | |
| ::java::lang::Object | newInstance (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Creates a new instance of the class represented by this Class object. | |
| ::java::lang::String | toString (::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
| Converts the object to a string. | |
Static Public Member Functions | |
| ::java::lang::Class | forName (const ::java::lang::String &className,::xmog_localenv *p_xenv=NULL, xmog_flags f_xflags=xmogDefaultFlags) |
Returns the Class object associated with the class or interface with the given string name. | |
Class represent classes and interfaces in a running Java application.
Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions. The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects.
Class has no public constructor. Instead Class objects are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to the defineClass method in the class loader.
The following example uses a Class object to print the class name of an object:
<blockquote>
void printClassName(Object obj) { System.out.println("The class of " + obj + " is " + obj.getClass().getName()); }
</blockquote>
It is also possible to get the Class object for a named type (or for void) using a class literal (JLS Section 15.8.2). For example:
<blockquote>
System.out.println("The name of class Foo is: "+Foo.class.getName());
</blockquote>
|
||||||||||||
|
Returns the assertion status that would be assigned to this class if it were to be initialized at the time this method is invoked. If this class has had its assertion status set, the most recent setting will be returned; otherwise, if any package default assertion status pertains to this class, the most recent setting for the most specific pertinent package default assertion status is returned; otherwise, if this class is not a system class (i.e., it has a class loader) its class loader's default assertion status is returned; otherwise, the system class default assertion status is returned. Few programmers will have any need for this method; it is provided for the benefit of the JRE itself. (It allows a class to determine at the time that it is initialized whether assertions should be enabled.) Note that this method is not guaranteed to return the actual assertion status that was (or will be) associated with the specified class when it was (or will be) initialized.
|
|
||||||||||||||||
|
Returns the Invoking this method is equivalent to: <blockquote>
Class.forName(className, true, currentLoader)
</blockquote>
where
For example, the following code fragment returns the runtime <blockquote>
Class t = Class.forName("java.lang.Thread")
</blockquote>
A call to
|
|
||||||||||||
|
Returns an array containing
This includes public class and interface members inherited from superclasses and public class and interface members declared by the class. This method returns an array of length 0 if this
For this class and each of its superclasses, the following security checks are performed: If there is a security manager, the security manager's
|
|
||||||||||||
|
Returns the If this class does not represent an array class this method returns null.
|
|
||||||||||||||||
|
Returns a
The
The constructor to reflect is the public constructor of the class represented by this
If there is a security manager, this method first calls the security manager's
|
|
||||||||||||
|
Returns an array containing An array of length 0 is returned if the class has no public constructors, or if the class is an array class, or if the class reflects a primitive type or void.
If there is a security manager, this method first calls the security manager's
|
|
||||||||||||
|
Returns an array of
This includes public, protected, default (package) access, and private classes and interfaces declared by the class, but excludes inherited classes and interfaces. This method returns an array of length 0 if the class declares no classes or interfaces as members, or if this
If there is a security manager, this method first calls the security manager's
|
|
||||||||||||||||
|
Returns a
The
If there is a security manager, this method first calls the security manager's
|
|
||||||||||||
|
Returns an array of
These are public, protected, default (package) access, and private constructors. The elements in the array returned are not sorted and are not in any particular order. If the class has a default constructor, it is included in the returned array. This method returns an array of length 0 if this See The Java Language Specification, section 8.2.
If there is a security manager, this method first calls the security manager's
|
|
||||||||||||||||
|
Returns a
The
If there is a security manager, this method first calls the security manager's
|
|
||||||||||||
|
Returns an array of
This includes public, protected, default (package) access, and private fields, but excludes inherited fields. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface declares no fields, or if this See The Java Language Specification, sections 8.2 and 8.3.
If there is a security manager, this method first calls the security manager's
|
|
||||||||||||||||||||
|
Returns a
The
If there is a security manager, this method first calls the security manager's
|
|
||||||||||||
|
Returns an array of
This includes public, protected, default (package) access, and private methods, but excludes inherited methods. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface declares no methods, or if this See The Java Language Specification, section 8.2.
If there is a security manager, this method first calls the security manager's
|
|
||||||||||||
|
If the class or interface represented by this
This method returns null if this class or interface is not a member of any other class. If this
|
|
||||||||||||||||
|
Returns a
The
If there is a security manager, this method first calls the security manager's The field to be reflected is determined by the algorithm that follows. Let C be the class represented by this object:
See The Java Language Specification, sections 8.2 and 8.3.
|
|
||||||||||||
|
Returns an array containing The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface has no accessible public fields, or if it represents an array class, a primitive type, or void.
Specifically, if this
If there is a security manager, this method first calls the security manager's
The implicit length field for array class is not reflected by this method. User code should use the methods of class See The Java Language Specification, sections 8.2 and 8.3.
|
|
||||||||||||
|
Determines the interfaces implemented by the class or interface represented by this object.
If this object represents a class, the return value is an array containing objects representing all interfaces implemented by the class. The order of the interface objects in the array corresponds to the order of the interface names in the
class Shimmer implements FloorWax, DessertTopping { ... }
</blockquote> suppose the value of
s.getClass().getInterfaces()[0]
</blockquote> is the
s.getClass().getInterfaces()[1]
</blockquote> is the
If this object represents an interface, the array contains objects representing all interfaces extended by the interface. The order of the interface objects in the array corresponds to the order of the interface names in the If this object represents a class or interface that implements no interfaces, the method returns an array of length 0. If this object represents a primitive type or void, the method returns an array of length 0.
|
|
||||||||||||||||||||
|
Returns a
The
If there is a security manager, this method first calls the security manager's
If the
To find a matching method in a class C: If C declares exactly one public method with the specified name and exactly the same formal parameter types, that is the method reflected. If more than one such method is found in C, and one of these methods has a return type that is more specific than any of the others, that method is reflected; otherwise one of the methods is chosen arbitrarily. See The Java Language Specification, sections 8.2 and 8.4.
|
|
||||||||||||
|
Returns an array containing
The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if this
If there is a security manager, this method first calls the security manager's
The class initialization method See The Java Language Specification, sections 8.2 and 8.4.
|
|
||||||||||||
|
Returns the Java language modifiers for this class or interface, encoded in an integer.
The modifiers consist of the Java Virtual Machine's constants for
If the underlying class is an array class, then its The modifier encodings are defined in The Java Virtual Machine Specification, table 4.1.
|
|
||||||||||||
|
Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this If this class object represents a reference type that is not an array type then the binary name of the class is returned, as specified by the Java Language Specification, Second Edition.
If this class object represents a primitive type or void, then the name returned is a
If this class object represents a class of arrays, then the internal form of the name consists of the name of the element type preceded by one or more ' <blockquote>
The class or interface name classname is the binary name of the class specified above. Examples: <blockquote>
String.class.getName()
returns "java.lang.String"
byte.class.getName()
returns "byte"
(new Object[3]).getClass().getName()
returns "[Ljava.lang.Object;"
(new int[3][4][5][6][7][8][9]).getClass().getName()
returns "[[[[[[[I"
</blockquote>
|
|
||||||||||||||||
|
Finds a resource with a given name. This method returns null if no resource with this name is found. The rules for searching resources associated with a given class are implemented by the defining class loader of the class.
This method delegates the call to its class loader, after making these changes to the resource name: if the resource name starts with "/", it is unchanged; otherwise, the package name is prepended to the resource name after converting "." to "/". If this object was loaded by the bootstrap loader, the call is delegated to
|
|
||||||||||||
|
Gets the signers of this class.
|
|
||||||||||||
|
Returns the
If this
|
|
||||||||||||
|
Determines if this
|
|
||||||||||||||||
|
Determines if the class or interface represented by this
It returns
Specifically, this method tests whether the type represented by the specified
|
|
||||||||||||||||
|
Determines if the specified
This method is the dynamic equivalent of the Java language
Specifically, if this
|
|
||||||||||||
|
Determines if the specified
|
|
||||||||||||
|
Determines if the specified
There are nine predefined
These objects may only be accessed via the following public static final variables, and are the only
|
|
||||||||||||
|
Creates a new instance of the class represented by this
The class is instantiated as if by a
If there is a security manager, this method first calls the security manager's
|
|
||||||||||||
|
Converts the object to a string.
The string representation is the string "class" or "interface", followed by a space, and then by the fully qualified name of the class in the format returned by
Reimplemented from java::lang::Object. |
1.4.1