fr.umlv.corosol.component.impl
Class JArrayClass

java.lang.Object
  extended by fr.umlv.corosol.component.impl.JArrayClass
All Implemented Interfaces:
JClass, JObject
Direct Known Subclasses:
JDK1_5JArrayClass

public class JArrayClass
extends java.lang.Object
implements JClass

A JArrayClass represents a JClass object for an array.

Author:
Christophe Deleray

Field Summary
 
Fields inherited from interface fr.umlv.corosol.component.JClass
CATEGORY1, CATEGORY2
 
Constructor Summary
JArrayClass(JClassLoader loader, java.lang.String name)
          Creates a new JArrayClass initialized with the specified class name and the specified class loader.
 
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 array 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.
 java.lang.String toString()
          Returns a string describing this JArrayClass.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JArrayClass

public JArrayClass(JClassLoader loader,
                   java.lang.String name)
Creates a new JArrayClass initialized with the specified class name and the specified class loader.

Parameters:
loader - the class loader of this class
name - the fully qualified name of the class
Method Detail

getNativeClass

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

Specified by:
getNativeClass in interface JClass
Returns:
the java.lang.Class object equivalent to this JClass object
See Also:
Class

isAssignableFrom

public 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.

Specified by:
isAssignableFrom in interface JClass
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

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

Specified by:
isInterface in interface JClass
Returns:
true if this object represents an interface; false otherwise.

isArray

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

Specified by:
isArray in interface JClass
Returns:
true if this object represents an array class; false otherwise.

isPrimitive

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

Specified by:
isPrimitive in interface JClass
Returns:
true if and only if this class represents a primitive type; false otherwise.

isAbstract

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

Specified by:
isAbstract in interface JClass
Returns:
true if and only if this class represents an abstract type; false otherwise.

isAnonymousClass

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

Specified by:
isAnonymousClass in interface JClass
Returns:
true if and only if this class represents an anonymous class; false otherwise.

isJObject

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

Specified by:
isJObject in interface JClass
Returns:
true if and only if this class represents a Corosol JObject; false otherwise.

getName

public 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.

Specified by:
getName in interface JClass
Returns:
the name of the class or interface represented by this object.

getSuperclass

public 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.

Specified by:
getSuperclass in interface JClass
Returns:
the superclass of the class represented by this object.

getInterfaces

public 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.

Specified by:
getInterfaces in interface JClass
Returns:
an array of interfaces implemented by this class.

getComponentType

public 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.

Specified by:
getComponentType in interface JClass
Returns:
the JClass representing the component type of this class if this class is an array

getModifiers

public 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.

Specified by:
getModifiers in interface JClass
Returns:
the int representing the modifiers for this class
See Also:
Modifier

getDeclaredFields

public 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.

Specified by:
getDeclaredFields in interface JClass
Returns:
the array of JField objects representing all the declared fields of this class

getDeclaredField

public 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.

Specified by:
getDeclaredField in interface JClass
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

public 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.

Specified by:
getDeclaredMethods in interface JClass
Returns:
the array of JMethod objects representing all the declared methods of this class

getDeclaredConstructors

public 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.

Specified by:
getDeclaredConstructors in interface JClass
Returns:
the array of JMethod objects representing all the declared constructors of this class

getConstantPool

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

Specified by:
getConstantPool in interface JClass

getClassLoader

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

Specified by:
getClassLoader in interface JClass

push

public 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.

Specified by:
push in interface JClass
Parameters:
value - the value to be pushed onto the operand stack of a frame
frame - a stack frame

pop

public 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.

Specified by:
pop in interface JClass
Parameters:
frame - a stack frame
Returns:
the value located at the top of the operand stack of the specified stack frame

getComputationalType

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

Specified by:
getComputationalType in interface JClass
Returns:
a value representing the computational type category
See Also:
JClass.CATEGORY1, JClass.CATEGORY2

doPutfield

public 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.

Specified by:
doPutfield in interface JClass
Parameters:
frame - the current frame of a thread
field - a JField object describing a field

doGetfield

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

Specified by:
doGetfield in interface JClass
Parameters:
frame - the current stack frame of a thread
field - a JField object describing the field to be pushed onto the stack frame

doPutstatic

public 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.

Specified by:
doPutstatic in interface JClass
Parameters:
frame - the current frame of a thread
field - a JField object describing a static field

doGetstatic

public 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.

Specified by:
doGetstatic in interface JClass
Parameters:
frame - the current stack frame of a thread
field - a JField object describing a static field

toString

public java.lang.String toString()
Returns a string describing this JArrayClass.

Overrides:
toString in class java.lang.Object

arrayCopy

public 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.

Specified by:
arrayCopy in interface JClass
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

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

Specified by:
fieldCopy in interface JClass
Parameters:
field - the array reference field whose the value have to be copied
src - the source class instance
dest - the destination class instance

copyValue

public void copyValue(JHeap srcHeap,
                      int src,
                      JHeap destHeap,
                      int dest)
Specified by:
copyValue in interface JClass