harpoon.ClassFile
Class Linker

java.lang.Object
  extended by harpoon.ClassFile.Linker
All Implemented Interfaces:
ReferenceUnique
Direct Known Subclasses:
Relinker

public abstract class Linker
extends Object
implements ReferenceUnique

A Linker object manages the association of symbolic names to code/data/object descriptions.

Version:
$Id: Linker.java,v 1.7 2004/02/08 01:58:03 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Field Summary
protected  Map descCache
          private linker cache, for efficiency.
 
Constructor Summary
protected Linker()
           
 
Method Summary
 HClass createMutableClass(String name, HClass template)
          Creates a new mutable class with the given name which is based on the given template class.
 HClass forClass(Class cls)
          Deprecated. Don't use java.lang.Class objects if you can help it.
 HClass forDescriptor(String descriptor)
          Returns the HClass object associated with the ComponentType descriptor given.
protected abstract  HClass forDescriptor0(String descriptor)
          Sub-classes will provide implementation for the forDescriptor0 method in order to implement a linking strategy.
 HClass forName(String className)
          Returns the HClass object associated with the class with the given string name.
protected  HClass makeArray(HClass baseType, int dims)
          Allow Linker subclass to substitute a different (mutable?)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

descCache

protected final Map descCache
private linker cache, for efficiency.

Constructor Detail

Linker

protected Linker()
Method Detail

forDescriptor0

protected abstract HClass forDescriptor0(String descriptor)
                                  throws NoSuchClassException
Sub-classes will provide implementation for the forDescriptor0 method in order to implement a linking strategy. This method is only passed descriptors for class types; never array or primitive type descriptors. (Hence neither primitive types or array types can be re-linked, which might violate java language semantics.)

Throws:
NoSuchClassException - if the class could not be found.

forDescriptor

public HClass forDescriptor(String descriptor)
                     throws NoSuchClassException
Returns the HClass object associated with the ComponentType descriptor given. Throws NoSuchClassException if the descriptor references a class that cannot be found. Throws Error if an invalid descriptor is given.

Throws:
Error - if an invalid descriptor is given.
NoSuchClassException - if the class could not be found.

makeArray

protected HClass makeArray(HClass baseType,
                           int dims)
Allow Linker subclass to substitute a different (mutable?) array class type.


forName

public final HClass forName(String className)
                     throws NoSuchClassException
Returns the HClass object associated with the class with the given string name. Given the fully-qualified name for a class or interface, this method attempts to locate and load the class. If it succeeds, returns the HClass object representing the class. If it fails, the method throws a NoSuchClassException.

Parameters:
className - the fully qualified name of the desired class.
Returns:
the HClass descriptor for the class with the specified name.
Throws:
NoSuchClassException - if the class could not be found.

forClass

public final HClass forClass(Class cls)
                      throws NoSuchClassException
Deprecated. Don't use java.lang.Class objects if you can help it.

Returns the HClass object associated with the given java Class object. If (for some reason) the class file cannot be found, the method throws a NoSuchClassException.

Returns:
the HClass descriptor for this Class.
Throws:
NoSuchClassException - if the classfile could not be found.

createMutableClass

public HClass createMutableClass(String name,
                                 HClass template)
                          throws DuplicateClassException
Creates a new mutable class with the given name which is based on the given template class. The name must be unique.

Throws:
DuplicateClassException - if the given name is not unique; that is, it corresponds to a loadable class.