fr.umlv.corosol.component
Interface JClass

All Superinterfaces:
JObject
All Known Implementing Classes:
BooleanClass, ByteClass, CharClass, DefaultJClass, DoubleClass, FloatClass, IntClass, JArrayClass, JDK1_5JArrayClass, JDK1_5JClass, JPrimitiveClass, LongClass, ShortClass, VoidClass

public interface JClass
extends JObject

This interface represents a class object and contains methods which permit to retrieve all informations about a class.

Author:
Christophe Deleray

Field Summary
static int CATEGORY1
          The integer corresponding to a category 1 computational type.
static int CATEGORY2
          The integer corresponding to a category 2 computational type.
 
Method Summary
 void arrayCopy(JArray src, int srcPos, JArray dest, int destPos, int length)
          Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array.
 void copyValue(JHeap srcHeap, int src, JHeap destHeap, int dest)
           
 void doGetfield(JStackFrame frame, JField field)
          Does the getfield operations on the specified stack frame.
 void doGetstatic(JStackFrame frame, JField field)
          Does the getstatic operations on the specified stack frame.
 void doPutfield(JStackFrame frame, JField field)
          Does the putfield operations on the specified stack frame.
 void doPutstatic(JStackFrame frame, JField field)
          Does the putstatic operations on the specified stack frame.
 void fieldCopy(JField field, JClassInstance src, JClassInstance dest)
          Copies the reference value of the specified field from the specified source class instance to the specified class instance destination.
 JClassLoader getClassLoader()
          Returns the class loader of the class represented by this JClass object.
 JClass getComponentType()
          Returns the JClass representing the component type of an array.
 int getComputationalType()
          Returns the number representing the computational type category of this class.
 JConstantPool getConstantPool()
          Returns the constant pool of the class;
 JConstructor[] getDeclaredConstructors()
          Returns an array of JConstructor objects reflecting all the constructors declared by the class represented by this JClass object.
 JField getDeclaredField(java.lang.String name)
          Returns a JField object that reflects the specified declared field of the class or interface represented by this JClass object.
 JField[] getDeclaredFields()
          Returns an array of JField objects reflecting all the fields declared by the class or interface represented by this JClass object.
 JMethod[] getDeclaredMethods()
          Returns an array of JMethod objects reflecting all the methods declared by the class or interface represented by this JClass object.
 JClass[] getInterfaces()
          Determines the interfaces implemented by the class or interface represented by this object.
 int getModifiers()
          Returns the Java language modifiers for this class or interface, encoded in an integer.
 java.lang.String getName()
          Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this JClass object, as a String.
 java.lang.Class getNativeClass()
          Returns the java.lang.Class object equivalent to this JClass object.
 JClass getSuperclass()
          Returns the JClass representing the superclass of the entity (class, interface, primitive type or void) represented by this Class.
 boolean isAbstract()
          Determines if the specified JClass object represents an abstract type.
 boolean isAnonymousClass()
          Determines if the specified JClass object represents an anonymous class.
 boolean isArray()
          Determines if this JClass object represents an array class.
 boolean isAssignableFrom(JClass c)
          Determines if the class or interface represented by this JClass object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified JClass parameter.
 boolean isInterface()
          Determines if the specified JClass object represents an interface type.
 boolean isJObject()
          Determines if the specified JClass object represents a Corosol JObject element.
 boolean isPrimitive()
          Determines if the specified JClass object represents a primitive type.
 JHeapObject pop(JStackFrame frame)
          Returns the value located at the top of the operand stack of the specified frame.
 void push(java.lang.Object value, JStackFrame frame)
          Pushes the specified value onto the operand stack of the frame frame.
 

Field Detail

CATEGORY1

static final int CATEGORY1
The integer corresponding to a category 1 computational type.

See Also:
Constant Field Values

CATEGORY2

static final int CATEGORY2
The integer corresponding to a category 2 computational type.

See Also:
Constant Field Values
Method Detail

isAssignableFrom

boolean isAssignableFrom(JClass c)
Determines if the class or interface represented by this JClass object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified JClass parameter. It returns true if so; otherwise it returns false. If this JClass object represents a primitive type, this method returns true if the specified JClass parameter is exactly this JClass object; otherwise it returns false.

Parameters:
c - the JClass object to be checked
Returns:
the boolean value indicating whether objects of the type c can be assigned to objects of this class

isInterface

boolean isInterface()
Determines if the specified JClass object represents an interface type.

Returns:
true if this object represents an interface; false otherwise.

isArray

boolean isArray()
Determines if this JClass object represents an array class.

Returns:
true if this object represents an array class; false otherwise.

isPrimitive

boolean isPrimitive()
Determines if the specified JClass object represents a primitive type.

Returns:
true if and only if this class represents a primitive type; false otherwise.

isAbstract

boolean isAbstract()
Determines if the specified JClass object represents an abstract type.

Returns:
true if and only if this class represents an abstract type; false otherwise.

isAnonymousClass

boolean isAnonymousClass()
Determines if the specified JClass object represents an anonymous class.

Returns:
true if and only if this class represents an anonymous class; false otherwise.

isJObject

boolean isJObject()
Determines if the specified JClass object represents a Corosol JObject element.

Returns:
true if and only if this class represents a Corosol JObject; false otherwise.

getName

java.lang.String getName()
Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this JClass object, as a String.

Returns:
the name of the class or interface represented by this object.

getSuperclass

JClass getSuperclass()
Returns the JClass representing the superclass of the entity (class, interface, primitive type or void) represented by this Class. If this JClass represents either the Object class, an interface, a primitive type, or void, then null is returned. If this object represents an array class then the JClass object representing the Object class is returned.

Returns:
the superclass of the class represented by this object.

getInterfaces

JClass[] getInterfaces()
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 implements clause of the declaration of the class represented by this object.

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 extends clause of the declaration of the interface represented by this object.

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:
an array of interfaces implemented by this class.

getComponentType

JClass getComponentType()
Returns the JClass representing the component type of an array. If this class does not represent an array class this method returns null.

Returns:
the JClass representing the component type of this class if this class is an array

getModifiers

int getModifiers()
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 public, protected, private, final, static, abstract and interface; they should be decoded using the methods of class Modifier.

If the underlying class is an array class, then its public, private and protected modifiers are the same as those of its component type. If this Class represents a primitive type or void, its public modifier is always true, and its protected and private modifiers are always false. If this object represents an array class, a primitive type or void, then its final modifier is always true and its interface modifier is always false. The values of its other modifiers are not determined by this specification.

The modifier encodings are defined in The Java Virtual Machine Specification, table 4.1.

Returns:
the int representing the modifiers for this class
See Also:
Modifier

getDeclaredFields

JField[] getDeclaredFields()
Returns an array of JField objects reflecting all the fields declared by the class or interface represented by this JClass object. 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 Class object represents a primitive type, an array class, or void.

See The Java Language Specification, sections 8.2 and 8.3.

Returns:
the array of JField objects representing all the declared fields of this class

getDeclaredField

JField getDeclaredField(java.lang.String name)
                        throws java.lang.NoSuchFieldException
Returns a JField object that reflects the specified declared field of the class or interface represented by this JClass object. The name parameter is a String that specifies the simple name of the desired field. Note that this method will not reflect the length field of an array class.

Parameters:
name - the name of the field
Returns:
the JField object for the specified field in this class
Throws:
java.lang.NoSuchFieldException - if a field with the specified name is not found.

getDeclaredMethods

JMethod[] getDeclaredMethods()
Returns an array of JMethod objects reflecting all the methods declared by the class or interface represented by this JClass object. 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 Class object represents a primitive type, an array class, or void. The class initialization method <clinit> is not included in the returned array. If the class declares multiple public member methods with the same parameter types, they are all included in the returned array.

See The Java Language Specification, section 8.2.

Returns:
the array of JMethod objects representing all the declared methods of this class

getDeclaredConstructors

JConstructor[] getDeclaredConstructors()
Returns an array of JConstructor objects reflecting all the constructors declared by the class represented by this JClass object. 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 JClass object represents an interface, a primitive type, an array class, or void.

See The Java Language Specification, section 8.2.

Returns:
the array of JMethod objects representing all the declared constructors of this class

getConstantPool

JConstantPool getConstantPool()
Returns the constant pool of the class;


getClassLoader

JClassLoader getClassLoader()
Returns the class loader of the class represented by this JClass object.


push

void push(java.lang.Object value,
          JStackFrame frame)
Pushes the specified value onto the operand stack of the frame frame. If this class is a class of a primitive type, the specified value corresponds to an instance of a primitive wrapping class like java.lang.Integer and the wrapped value is pushed onto the operand stack of the specified stack frame. Otherwise, the value is pushed onto the operand stack of the specified stack frame.

Parameters:
value - the value to be pushed onto the operand stack of a frame
frame - a stack frame

pop

JHeapObject pop(JStackFrame frame)
Returns the value located at the top of the operand stack of the specified frame. If this class is a class of a primitive type, we return the value popped as an embedded value (e.g. an instance of the java.lang.Integer class). Otherwise, the popped value is returned.

Parameters:
frame - a stack frame
Returns:
the value located at the top of the operand stack of the specified stack frame

getComputationalType

int getComputationalType()
Returns the number representing the computational type category of this class.

Returns:
a value representing the computational type category
See Also:
CATEGORY1, CATEGORY2

doPutfield

void doPutfield(JStackFrame frame,
                JField field)
Does the putfield operations on the specified stack frame. This operation pop a value and an object reference. Then, it sets the specified field of the object with the popped value.

Parameters:
frame - the current frame of a thread
field - a JField object describing the field to be setted

doGetfield

void doGetfield(JStackFrame frame,
                JField field)
Does the getfield operations on the specified stack frame. This operation pop an object reference and sets. Then, it pushes onto the specified stack frame the value of the specified field of the popped reference object.

Parameters:
frame - the current stack frame of a thread
field - a JField object describing the field to be pushed onto the stack frame

doPutstatic

void doPutstatic(JStackFrame frame,
                 JField field)
Does the putstatic operations on the specified stack frame. This operation pop a value from the current stack frame. Then, it sets the specified static field with the popped value.

Parameters:
frame - the current frame of a thread
field - a JField object describing a field

doGetstatic

void doGetstatic(JStackFrame frame,
                 JField field)
Does the getstatic operations on the specified stack frame. This operation push onto the current stack frame the value of the specified static field.

Parameters:
frame - the current stack frame of a thread
field - a JField object describing a static field

arrayCopy

void arrayCopy(JArray src,
               int srcPos,
               JArray dest,
               int destPos,
               int length)
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array. A subsequence of array components are copied from the source array referenced by src to the destination array referenced by dest. The number of components copied is equal to the length argument. The components at positions srcPos through srcPos+length-1 in the source array are copied into positions destPos through destPos+length-1, respectively, of the destination array.

Parameters:
src - the source array.
srcPos - starting position in the source array.
dest - the destination array.
destPos - starting position in the destination data.
length - the number of array elements to be copied.

fieldCopy

void fieldCopy(JField field,
               JClassInstance src,
               JClassInstance dest)
Copies the reference value of the specified field from the specified source class instance to the specified class instance destination.

Parameters:
field - the reference field whose the value have to be copied
src - the source class instance
dest - the destination class instance

getNativeClass

java.lang.Class getNativeClass()
Returns the java.lang.Class object equivalent to this JClass object.

Returns:
the java.lang.Class object equivalent to this JClass object
See Also:
Class

copyValue

void copyValue(JHeap srcHeap,
               int src,
               JHeap destHeap,
               int dest)