org.apache.derby.iapi.services.classfile
Class ClassHolder

java.lang.Object
  extended byorg.apache.derby.iapi.services.classfile.ClassHolder
Direct Known Subclasses:
ClassInvestigator

public class ClassHolder
extends java.lang.Object

Based upon "THE class FILE FORMAT" chapter of "The Java Virtual Machine Specification" corresponding to version 1.0.2 of the Java Virtual Machine and 1.0.2 of the Java Language Specification. ISBN 0-201-63452-X, September 1996.


Field Summary
protected  int access_flags
           
protected  Attributes attribute_info
           
protected  java.util.Vector cptEntries
           
private  int cptEstimatedSize
           
protected  java.util.Hashtable cptHashTable
           
protected  MemberTable field_info
           
protected  int[] interfaces
           
protected  MemberTable method_info
           
private  CONSTANT_Index_info searchIndex
          Used to search for index entries to avoid object allocation in the case a referecne already exists.
protected  int super_class
           
protected  int this_class
           
 
Constructor Summary
protected ClassHolder(int estimatedConstantPoolCount)
           
  ClassHolder(java.lang.String fullyQualifiedName, java.lang.String superClassName, int modifiers)
          This will not define a constructor -- it is up to the caller to add at least one.
 
Method Summary
 void addAttribute(java.lang.String attributeName, ClassFormatOutput info)
           
 int addClassReference(java.lang.String fullyQualifiedName)
          Add a class entry to the pool.
private  int addCodeUtf8(java.lang.String value)
          Add a string entry
 int addConstant(double value)
           
 int addConstant(float value)
           
 int addConstant(int value)
           
 int addConstant(long value)
           
 int addConstant(java.lang.String value)
           
private  int addDirectEntry(ConstantPoolEntry item)
          Add an entry, but only if it doesn't exist.
protected  int addEntry(java.lang.Object key, ConstantPoolEntry item)
          Generic add entry to constant pool.
private  CONSTANT_Utf8_info addExtraUtf8(java.lang.String value)
          Add an extra UTF8 into the pool
 int addFieldReference(ClassMember field)
           
 int addFieldReference(java.lang.String className, java.lang.String simpleName, java.lang.String descriptor)
           
private  int addIndexReference(int tag, int i1, int i2)
          Add an index reference.
 ClassMember addMember(java.lang.String simpleName, java.lang.String descriptor, int modifier)
           
 int addMethodReference(java.lang.String className, java.lang.String simpleName, java.lang.String descriptor, boolean isInterface)
           
private  int addNameAndType(java.lang.String name, java.lang.String descriptor)
          Add a name and type entry
private  int addReference(int tag, ClassMember member)
           
private  int addReference(int tag, java.lang.String className, java.lang.String simpleName, java.lang.String descriptor)
           
private  int addString(java.lang.String value)
          Add a string entry
 int addUtf8(java.lang.String value)
           
private  CONSTANT_Utf8_info addUtf8Entry(java.lang.String value)
          Add a UTF8 into the pool and return the index to it.
protected  java.lang.String className(int classIndex)
          Return the class name for an index to a CONSTANT_Class_info.
private static java.lang.String convertToInternal(java.lang.String externalName, boolean descriptor)
           
static java.lang.String convertToInternalClassName(java.lang.String externalName)
           
static java.lang.String convertToInternalDescriptor(java.lang.String externalName)
           
protected  void cptPut(ClassFormatOutput out)
           
 int findClass(java.lang.String fullyQualifiedName)
          Find a class descriptor (section 4.4.1) and return its index, returns -1 if not found.
protected  CONSTANT_Index_info findIndexEntry(int tag, int i1, int i2)
           
protected  int findIndexIndex(int tag, int i1, int i2)
           
protected  ConstantPoolEntry findMatchingEntry(java.lang.Object key)
           
 int findNameAndType(java.lang.String name, java.lang.String descriptor)
          Find a name and type descriptor (section 4.4.6) and return ita index. returns -1 if not found.
(package private)  int findUtf8(java.lang.String value)
          Return the index of a UTF entry or -1 if it doesn't exist.
protected  java.lang.String getClassName(int index)
          get the class name of a Class given the index of its CONSTANT_Class_info entry in the Constant Pool.
 int getConstantPoolIndex()
           
(package private)  ConstantPoolEntry getEntry(int index)
           
 ByteArray getFileFormat()
           
 int getModifier()
           
 java.lang.String getName()
           
 java.lang.String getSuperClassName()
           
static boolean isExternalClassName(java.lang.String className)
           
private static java.lang.String makeDesc(char builtin, int arity)
          A helper to build a type description based on a built-in type and an array arity.
private static java.lang.String makeDesc(java.lang.String className, int arity, boolean descriptor)
          A helper to build a type description based on a Java class and an array arity.
(package private)  java.lang.String nameIndexToString(int index)
          get a string (UTF) given a name_index into the constant pool
 void put(ClassFormatOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

access_flags

protected int access_flags

this_class

protected int this_class

super_class

protected int super_class

interfaces

protected int[] interfaces

field_info

protected MemberTable field_info

method_info

protected MemberTable method_info

attribute_info

protected Attributes attribute_info

cptHashTable

protected java.util.Hashtable cptHashTable

cptEntries

protected java.util.Vector cptEntries

cptEstimatedSize

private int cptEstimatedSize

searchIndex

private final CONSTANT_Index_info searchIndex
Used to search for index entries to avoid object allocation in the case a referecne already exists.

Constructor Detail

ClassHolder

protected ClassHolder(int estimatedConstantPoolCount)

ClassHolder

public ClassHolder(java.lang.String fullyQualifiedName,
                   java.lang.String superClassName,
                   int modifiers)
This will not define a constructor -- it is up to the caller to add at least one.

Method Detail

put

public void put(ClassFormatOutput out)
         throws java.io.IOException
Throws:
java.io.IOException

getFileFormat

public ByteArray getFileFormat()

getModifier

public int getModifier()
See Also:
ClassMember

getName

public java.lang.String getName()
See Also:
ClassMember

addMember

public ClassMember addMember(java.lang.String simpleName,
                             java.lang.String descriptor,
                             int modifier)
See Also:
addMember(java.lang.String, java.lang.String, int)

addFieldReference

public int addFieldReference(java.lang.String className,
                             java.lang.String simpleName,
                             java.lang.String descriptor)
See Also:
addFieldReference(java.lang.String, java.lang.String, java.lang.String)

addFieldReference

public int addFieldReference(ClassMember field)

addMethodReference

public int addMethodReference(java.lang.String className,
                              java.lang.String simpleName,
                              java.lang.String descriptor,
                              boolean isInterface)
See Also:
addMethodReference(java.lang.String, java.lang.String, java.lang.String, boolean)

addReference

private int addReference(int tag,
                         java.lang.String className,
                         java.lang.String simpleName,
                         java.lang.String descriptor)

addReference

private int addReference(int tag,
                         ClassMember member)

addConstant

public int addConstant(java.lang.String value)
See Also:
addConstant(java.lang.String)

addUtf8

public int addUtf8(java.lang.String value)
See Also:
addUtf8(java.lang.String)

addConstant

public int addConstant(int value)
See Also:
ClassHolder#addInteger

addConstant

public int addConstant(float value)
See Also:
ClassHolder#addFloat

addConstant

public int addConstant(long value)
See Also:
ClassHolder#addLong

addConstant

public int addConstant(double value)
See Also:
ClassHolder#addDouble

getConstantPoolIndex

public int getConstantPoolIndex()
See Also:
ClassMember

addAttribute

public void addAttribute(java.lang.String attributeName,
                         ClassFormatOutput info)

getSuperClassName

public java.lang.String getSuperClassName()

addEntry

protected int addEntry(java.lang.Object key,
                       ConstantPoolEntry item)
Generic add entry to constant pool. Includes the logic for an entry to occupy more than one slot (e.g. long).

Returns:
The number of slots occupied by the entry. .

addDirectEntry

private int addDirectEntry(ConstantPoolEntry item)
Add an entry, but only if it doesn't exist.

Returns:
the constant pool index of the added or existing item.

addIndexReference

private int addIndexReference(int tag,
                              int i1,
                              int i2)
Add an index reference.


addClassReference

public int addClassReference(java.lang.String fullyQualifiedName)
Add a class entry to the pool.


addNameAndType

private int addNameAndType(java.lang.String name,
                           java.lang.String descriptor)
Add a name and type entry


addUtf8Entry

private CONSTANT_Utf8_info addUtf8Entry(java.lang.String value)
Add a UTF8 into the pool and return the index to it.


addExtraUtf8

private CONSTANT_Utf8_info addExtraUtf8(java.lang.String value)
Add an extra UTF8 into the pool


addString

private int addString(java.lang.String value)
Add a string entry


addCodeUtf8

private int addCodeUtf8(java.lang.String value)
Add a string entry


cptPut

protected void cptPut(ClassFormatOutput out)
               throws java.io.IOException
Throws:
java.io.IOException

getEntry

ConstantPoolEntry getEntry(int index)

className

protected java.lang.String className(int classIndex)
Return the class name for an index to a CONSTANT_Class_info.


findUtf8

int findUtf8(java.lang.String value)
Return the index of a UTF entry or -1 if it doesn't exist.


findClass

public int findClass(java.lang.String fullyQualifiedName)
Find a class descriptor (section 4.4.1) and return its index, returns -1 if not found.


findNameAndType

public int findNameAndType(java.lang.String name,
                           java.lang.String descriptor)
Find a name and type descriptor (section 4.4.6) and return ita index. returns -1 if not found.


findIndexEntry

protected CONSTANT_Index_info findIndexEntry(int tag,
                                             int i1,
                                             int i2)

findIndexIndex

protected int findIndexIndex(int tag,
                             int i1,
                             int i2)

findMatchingEntry

protected ConstantPoolEntry findMatchingEntry(java.lang.Object key)

nameIndexToString

java.lang.String nameIndexToString(int index)
get a string (UTF) given a name_index into the constant pool


getClassName

protected java.lang.String getClassName(int index)
get the class name of a Class given the index of its CONSTANT_Class_info entry in the Constant Pool.


isExternalClassName

public static boolean isExternalClassName(java.lang.String className)

convertToInternalClassName

public static java.lang.String convertToInternalClassName(java.lang.String externalName)

convertToInternalDescriptor

public static java.lang.String convertToInternalDescriptor(java.lang.String externalName)

convertToInternal

private static java.lang.String convertToInternal(java.lang.String externalName,
                                                  boolean descriptor)

makeDesc

private static java.lang.String makeDesc(char builtin,
                                         int arity)
A helper to build a type description based on a built-in type and an array arity.


makeDesc

private static java.lang.String makeDesc(java.lang.String className,
                                         int arity,
                                         boolean descriptor)
A helper to build a type description based on a Java class and an array arity. If descriptor is true create a descriptor according to section 4.3.2 of the vm spec. If false create a class name according to sections 4.3.2 and 4.4.1 of the vm spec.



Apache Derby V10.0 Engine Documentation - Copyright © 1997,2004 The Apache Software Foundation or its licensors, as applicable.