Top Description Fields Constructors Methods
org.apache.derby.iapi.services.classfile

public Class ClassHolder

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.derby.iapi.services.classfile.ClassInvestigator
Imports
org.apache.derby.shared.common.sanity.SanityManager, java.io.InputStream, .OutputStream, .IOException, java.util.Enumeration, .Vector, .Hashtable, .Vector, .Enumeration, org.apache.derby.iapi.util.ByteArray, org.apache.derby.iapi.services.classfile.VMDescriptor, .VMDescriptor

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

Modifier and TypeField and Description
protected int
protected Attributes
protected Vector<ConstantPoolEntry>
private int
protected Hashtable<Object, ConstantPoolEntry>
protected MemberTable
protected int[]
protected int
major_version

Minor class format number defaults to VMDescriptor.JAVA_CLASS_FORMAT_MAJOR_VERSION

protected MemberTable
protected int
minor_version

Minor class format number defaults to VMDescriptor.JAVA_CLASS_FORMAT_MINOR_VERSION which currently corresponds to a really old (JDK 1.0.2) setting.

private final CONSTANT_Index_info
searchIndex

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

protected int
protected int

Constructor Summary

AccessConstructor and Description
protected
ClassHolder(int estimatedConstantPoolCount)

public
ClassHolder(String fullyQualifiedName, String superClassName, int modifiers)

This will not define a constructor -- it is up to the caller to add at least one.

Method Summary

Modifier and TypeMethod and Description
public void
addAttribute(String attributeName, ClassFormatOutput info)

public int
addClassReference(String fullyQualifiedName)

Add a class entry to the pool.

public int
public int
addConstant(int value)

public int
addConstant(float value)

public int
addConstant(long value)

public int
addConstant(double value)

private int

Returns:

the constant pool index of the added or existing item.
addDirectEntry
(ConstantPoolEntry item)

Add an entry, but only if it doesn't exist.

protected int

Returns:

The number of slots occupied by the entry. .
addEntry
(Object key, ConstantPoolEntry item)

Generic add entry to constant pool.

private CONSTANT_Utf8_info
addExtraUtf8(String value)

Add an extra UTF8 into the pool

public int
addFieldReference(String className, String simpleName, String descriptor)

public int
private int
addIndexReference(int tag, int i1, int i2)

Add an index reference.

public ClassMember
addMember(String simpleName, String descriptor, int modifier)

public int
addMethodReference(String className, String simpleName, String descriptor, boolean isInterface)

private int
addNameAndType(String name, String descriptor)

Add a name and type entry

private int
addReference(int tag, String className, String simpleName, String descriptor)

private int
addReference(int tag, ClassMember member)

private int
addString(String value)

Add a string entry

public int
addUtf8(String value)

private CONSTANT_Utf8_info
addUtf8Entry(String value)

Add a UTF8 into the pool and return the index to it.

protected String
className(int classIndex)

Return the class name for an index to a CONSTANT_Class_info.

private static String
convertToInternal(String externalName, boolean descriptor)

public static String
public static String
protected void
public int
findClass(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
public int
findNameAndType(String name, String descriptor)

Find a name and type descriptor (section 4.4.6) and return it's index.

pack-priv int
findUtf8(String value)

Return the index of a UTF entry or -1 if it doesn't exist.

protected String
getClassName(int index)

get the class name of a Class given the index of its CONSTANT_Class_info entry in the Constant Pool.

public int
public ConstantPoolEntry
getEntry(int index)

public ByteArray
getFileFormat()

Convert the object representation of the class into its class file format.

public int
public String
public String
public static boolean
private static 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 String
makeDesc(String className, int arity, boolean descriptor)

A helper to build a type description based on a Java class and an array arity.

pack-priv String
nameIndexToString(int index)

get a string (UTF) given a name_index into the constant pool

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

access_flagsback to summary
protected int access_flags
attribute_infoback to summary
protected Attributes attribute_info
cptEntriesback to summary
protected Vector<ConstantPoolEntry> cptEntries
cptEstimatedSizeback to summary
private int cptEstimatedSize
cptHashTableback to summary
protected Hashtable<Object, ConstantPoolEntry> cptHashTable
field_infoback to summary
protected MemberTable field_info
interfacesback to summary
protected int[] interfaces
major_versionback to summary
protected int major_version

Minor class format number defaults to VMDescriptor.JAVA_CLASS_FORMAT_MAJOR_VERSION

method_infoback to summary
protected MemberTable method_info
minor_versionback to summary
protected int minor_version

Minor class format number defaults to VMDescriptor.JAVA_CLASS_FORMAT_MINOR_VERSION which currently corresponds to a really old (JDK 1.0.2) setting. The default major and minor value is used by the generated code for Derby's SQL statements. Currently there is no need to bump the version number as the generated code does not take advantage of any of the new elements in the class file format. If such a need exists then this can be bumped. One issue is that the change in format numbers is not well documented.

searchIndexback to summary
private final CONSTANT_Index_info searchIndex

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

super_classback to summary
protected int super_class
this_classback to summary
protected int this_class

Constructor Detail

ClassHolderback to summary
protected ClassHolder(int estimatedConstantPoolCount)
ClassHolderback to summary
public ClassHolder(String fullyQualifiedName, String superClassName, int modifiers)

This will not define a constructor -- it is up to the caller to add at least one.

Method Detail

addAttributeback to summary
public void addAttribute(String attributeName, ClassFormatOutput info)
addClassReferenceback to summary
public int addClassReference(String fullyQualifiedName)

Add a class entry to the pool.

addConstantback to summary
public int addConstant(String value)
See Also
ClassHolder#addConstant
addConstantback to summary
public int addConstant(int value)
See Also
ClassHolder#addConstant
addConstantback to summary
public int addConstant(float value)
See Also
ClassHolder#addConstant
addConstantback to summary
public int addConstant(long value)
See Also
ClassHolder#addConstant
addConstantback to summary
public int addConstant(double value)
See Also
ClassHolder#addConstant
addDirectEntryback to summary
private int addDirectEntry(ConstantPoolEntry item)

Add an entry, but only if it doesn't exist.

Returns:int

the constant pool index of the added or existing item.

addEntryback to summary
protected int addEntry(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:int

The number of slots occupied by the entry. .

addExtraUtf8back to summary
private CONSTANT_Utf8_info addExtraUtf8(String value)

Add an extra UTF8 into the pool

addFieldReferenceback to summary
public int addFieldReference(String className, String simpleName, String descriptor)
See Also
ClassHolder#addFieldReference
addFieldReferenceback to summary
public int addFieldReference(ClassMember field)
addIndexReferenceback to summary
private int addIndexReference(int tag, int i1, int i2)

Add an index reference.

addMemberback to summary
public ClassMember addMember(String simpleName, String descriptor, int modifier)
See Also
ClassHolder#addMember
addMethodReferenceback to summary
public int addMethodReference(String className, String simpleName, String descriptor, boolean isInterface)
See Also
ClassHolder#addMethodReference
addNameAndTypeback to summary
private int addNameAndType(String name, String descriptor)

Add a name and type entry

addReferenceback to summary
private int addReference(int tag, String className, String simpleName, String descriptor)
addReferenceback to summary
private int addReference(int tag, ClassMember member)
addStringback to summary
private int addString(String value)

Add a string entry

addUtf8back to summary
public int addUtf8(String value)
See Also
ClassHolder#addUtf8
addUtf8Entryback to summary
private CONSTANT_Utf8_info addUtf8Entry(String value)

Add a UTF8 into the pool and return the index to it.

classNameback to summary
protected String className(int classIndex)

Return the class name for an index to a CONSTANT_Class_info.

convertToInternalback to summary
private static String convertToInternal(String externalName, boolean descriptor)
convertToInternalClassNameback to summary
public static String convertToInternalClassName(String externalName)
convertToInternalDescriptorback to summary
public static String convertToInternalDescriptor(String externalName)
cptPutback to summary
protected void cptPut(ClassFormatOutput out) throws IOException
findClassback to summary
public int findClass(String fullyQualifiedName)

Find a class descriptor (section 4.4.1) and return its index, returns -1 if not found.

findIndexEntryback to summary
protected CONSTANT_Index_info findIndexEntry(int tag, int i1, int i2)
findIndexIndexback to summary
protected int findIndexIndex(int tag, int i1, int i2)
findMatchingEntryback to summary
protected ConstantPoolEntry findMatchingEntry(Object key)
findNameAndTypeback to summary
public int findNameAndType(String name, String descriptor)

Find a name and type descriptor (section 4.4.6) and return it's index.

returns -1 if not found.

findUtf8back to summary
pack-priv int findUtf8(String value)

Return the index of a UTF entry or -1 if it doesn't exist.

getClassNameback to summary
protected String getClassName(int index)

get the class name of a Class given the index of its CONSTANT_Class_info entry in the Constant Pool.

getConstantPoolIndexback to summary
public int getConstantPoolIndex()
See Also
ClassMember
getEntryback to summary
public ConstantPoolEntry getEntry(int index)
getFileFormatback to summary
public ByteArray getFileFormat() throws IOException

Convert the object representation of the class into its class file format.

Exceptions
IOException:
error writing the class
getModifierback to summary
public int getModifier()
See Also
ClassMember
getNameback to summary
public String getName()
See Also
ClassMember
getSuperClassNameback to summary
public String getSuperClassName()
isExternalClassNameback to summary
public static boolean isExternalClassName(String className)
makeDescback to summary
private static String makeDesc(char builtin, int arity)

A helper to build a type description based on a built-in type and an array arity.

makeDescback to summary
private static String makeDesc(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.

nameIndexToStringback to summary
pack-priv String nameIndexToString(int index)

get a string (UTF) given a name_index into the constant pool

putback to summary
private void put(ClassFormatOutput out) throws IOException