fr.umlv.corosol.component.impl
Class DefaultJClassLoader

java.lang.Object
  extended by fr.umlv.corosol.component.impl.AbstractJVMComponent
      extended by fr.umlv.corosol.component.impl.DefaultJClassLoader
All Implemented Interfaces:
JClassLoader, JObject, JVMComponent
Direct Known Subclasses:
JDK1_5JClassLoader

public class DefaultJClassLoader
extends AbstractJVMComponent
implements JClassLoader

This class represents the default implementation of the fr.umlv.corosol.component.JClassLoader interface. It represents the default class loader component. Among all components of the JVM, this is the most important, becauces it create JClass, JField and JMethod instances, which are used by a lot of components.

Author:
Christophe Deleray

Constructor Summary
DefaultJClassLoader()
          The default constructor.
 
Method Summary
 void configure(JVirtualMachine jvm)
          Configures the component via the specified JVM.
 JClass createArrayClass(java.lang.String name)
          Creates a JClass corresponding to the class array specified by the fully qualified name passed in parameter.
 JClass createClass(JClassFile classfile)
          Creates a JClass object from the classfile data specified by the JClassFile instance.
 JField createField(JClass c, JClassMember fieldInfo)
          Creates a JField object from the data described by the specified classfile item containing the description of a field of the c class.
 JMethod createMethod(JClass c, JClassMember methodInfo)
          Creates a JMethod object from the data described by the specified classfile item containing the description of a method of the c class.
 java.lang.Class getComponentClass()
          Returns the class object describing this component.
 boolean isInterface(JClass fromClazz, JClass clazz)
          Determines if clazz is a superinterface of fromClass.
 boolean isSuperclass(JClass fromClazz, JClass clazz)
          Determines if clazz is a superclass of fromClass.
 JClass loadClass(java.lang.String name)
          Loads the specified class.
 JClass loadPrimitiveClass(java.lang.String descriptor)
          Loads the specified primitive class.
 JClass resolveClass(JClass fromClass, java.lang.String name)
          Executes the dynamic resolution of the class name from the specified class.
 JField resolveField(JClass fromClass, java.lang.String name, java.lang.String className)
          Executes the dynamic resolution of the field name from the specified class.
 JMethod resolveInterfaceMethod(JClass fromClass, java.lang.String name, java.lang.String className, java.lang.String desc)
          Executes the dynamic resolution of the interface method name from the specified class.
 JClassMethod resolveMethod(JClass fromClass, java.lang.String name, java.lang.String className, java.lang.String desc)
          Executes the dynamic resolution of the method name from the specified class.
 java.lang.String toString()
          Returns a string representation of this class loader and its components.
 
Methods inherited from class fr.umlv.corosol.component.impl.AbstractJVMComponent
replace
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface fr.umlv.corosol.component.JVMComponent
replace
 

Constructor Detail

DefaultJClassLoader

public DefaultJClassLoader()
The default constructor.

Method Detail

configure

public void configure(JVirtualMachine jvm)
Configures the component via the specified JVM. During this configuration operation, this component can meet any component via the specified JVM.

Specified by:
configure in interface JVMComponent
Overrides:
configure in class AbstractJVMComponent
Parameters:
jvm - the Java Virtual Machine

loadClass

public JClass loadClass(java.lang.String name)
Loads the specified class. If the specified class is not alrady load a new JClass instance is created by the createClass and returned.

Specified by:
loadClass in interface JClassLoader
Parameters:
name - the name of a class
Returns:
the loaded class
See Also:
createClass(JClassFile)

loadPrimitiveClass

public JClass loadPrimitiveClass(java.lang.String descriptor)
Loads the specified primitive class.

Specified by:
loadPrimitiveClass in interface JClassLoader
Parameters:
descriptor - the descriptor of a primitive type

createClass

public JClass createClass(JClassFile classfile)
Creates a JClass object from the classfile data specified by the JClassFile instance.

Specified by:
createClass in interface JClassLoader
Parameters:
classfile - a classfile
Returns:
a new instance of the JClass class

createArrayClass

public JClass createArrayClass(java.lang.String name)
Creates a JClass corresponding to the class array specified by the fully qualified name passed in parameter.

Specified by:
createArrayClass in interface JClassLoader
Parameters:
name - the fully qualified name of an array class
Returns:
a new instance of an array class

createField

public JField createField(JClass c,
                          JClassMember fieldInfo)
Creates a JField object from the data described by the specified classfile item containing the description of a field of the c class.

Specified by:
createField in interface JClassLoader
Parameters:
c - the class declaring the field which the JField object is created
fieldInfo - a classfile item containing the description of the field object to be created
Returns:
a new instance of the JField describing a field data

createMethod

public JMethod createMethod(JClass c,
                            JClassMember methodInfo)
Creates a JMethod object from the data described by the specified classfile item containing the description of a method of the c class.

Specified by:
createMethod in interface JClassLoader
Parameters:
c - the class declaring the method which the JMethod object is created
methodInfo - a classfile item containing the description of the method object to be created
Returns:
a new instance of the JMethod describing a field data

getComponentClass

public java.lang.Class getComponentClass()
Returns the class object describing this component.

Specified by:
getComponentClass in interface JVMComponent

resolveClass

public JClass resolveClass(JClass fromClass,
                           java.lang.String name)
Executes the dynamic resolution of the class name from the specified class.

Specified by:
resolveClass in interface JClassLoader
Parameters:
fromClass - the class from which the resolution is executed
name - the name of the class to resolve
Returns:
the resolved class

resolveField

public JField resolveField(JClass fromClass,
                           java.lang.String name,
                           java.lang.String className)
Executes the dynamic resolution of the field name from the specified class.

Specified by:
resolveField in interface JClassLoader
Parameters:
fromClass - the class from which the resolution is executed
name - the name of the field to resolve
className - the name of the class declaring the field to resolve
Returns:
the resolved field

resolveMethod

public JClassMethod resolveMethod(JClass fromClass,
                                  java.lang.String name,
                                  java.lang.String className,
                                  java.lang.String desc)
Executes the dynamic resolution of the method name from the specified class.

Specified by:
resolveMethod in interface JClassLoader
Parameters:
fromClass - the class from which the resolution is executed
name - the name of the method to resolve
className - the name of the class declaring the method to resolve
Returns:
the resolved method

resolveInterfaceMethod

public JMethod resolveInterfaceMethod(JClass fromClass,
                                      java.lang.String name,
                                      java.lang.String className,
                                      java.lang.String desc)
Executes the dynamic resolution of the interface method name from the specified class.

Specified by:
resolveInterfaceMethod in interface JClassLoader
Parameters:
fromClass - the class from which the resolution is executed
name - the name of the method to resolve
className - the name of the class declaring the method to resolve
Returns:
the resolved method

isInterface

public boolean isInterface(JClass fromClazz,
                           JClass clazz)
Determines if clazz is a superinterface of fromClass.

Specified by:
isInterface in interface JClassLoader
Parameters:
fromClazz - class from which we start the research
clazz - class whose we will dertermine if is is a superinterface of fromClass
Returns:
true if clazz is a superinterface of fromClazz and false otherwise

isSuperclass

public boolean isSuperclass(JClass fromClazz,
                            JClass clazz)
Determines if clazz is a superclass of fromClass.

Specified by:
isSuperclass in interface JClassLoader
Parameters:
fromClazz - class from which we start the research
clazz - class whose we will dertermine if is is a superclass of fromClass
Returns:
true if clazz is a superclass of fromClazz and false otherwise

toString

public java.lang.String toString()
Returns a string representation of this class loader and its components.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this class loader