Class ClassHolder
java.lang.Object
org.apache.derby.iapi.services.classfile.ClassHolder
- Direct Known Subclasses:
ClassInvestigator
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
FieldsModifier and TypeFieldDescriptionprotected intprotected Attributesprotected Vector<ConstantPoolEntry> private intprotected Hashtable<Object, ConstantPoolEntry> protected MemberTableprotected int[]protected intMinor class format number defaults to VMDescriptor.JAVA_CLASS_FORMAT_MAJOR_VERSIONprotected MemberTableprotected intMinor 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_infoUsed to search for index entries to avoid object allocation in the case a referecne already exists.protected intprotected int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedClassHolder(int estimatedConstantPoolCount) 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 TypeMethodDescriptionvoidaddAttribute(String attributeName, ClassFormatOutput info) intaddClassReference(String fullyQualifiedName) Add a class entry to the pool.intaddConstant(double value) intaddConstant(float value) intaddConstant(int value) intaddConstant(long value) intaddConstant(String value) private intAdd an entry, but only if it doesn't exist.protected intaddEntry(Object key, ConstantPoolEntry item) Generic add entry to constant pool.private CONSTANT_Utf8_infoaddExtraUtf8(String value) Add an extra UTF8 into the poolintaddFieldReference(String className, String simpleName, String descriptor) intaddFieldReference(ClassMember field) private intaddIndexReference(int tag, int i1, int i2) Add an index reference.intaddMethodReference(String className, String simpleName, String descriptor, boolean isInterface) private intaddNameAndType(String name, String descriptor) Add a name and type entryprivate intaddReference(int tag, String className, String simpleName, String descriptor) private intaddReference(int tag, ClassMember member) private intAdd a string entryintprivate CONSTANT_Utf8_infoaddUtf8Entry(String value) Add a UTF8 into the pool and return the index to it.protected StringclassName(int classIndex) Return the class name for an index to a CONSTANT_Class_info.private static StringconvertToInternal(String externalName, boolean descriptor) static StringconvertToInternalClassName(String externalName) static StringconvertToInternalDescriptor(String externalName) protected voidcptPut(ClassFormatOutput out) intFind a class descriptor (section 4.4.1) and return its index, returns -1 if not found.protected CONSTANT_Index_infofindIndexEntry(int tag, int i1, int i2) protected intfindIndexIndex(int tag, int i1, int i2) protected ConstantPoolEntryfindMatchingEntry(Object key) intfindNameAndType(String name, String descriptor) Find a name and type descriptor (section 4.4.6) and return it's index.(package private) intReturn the index of a UTF entry or -1 if it doesn't exist.protected StringgetClassName(int index) get the class name of a Class given the index of its CONSTANT_Class_info entry in the Constant Pool.intgetEntry(int index) Convert the object representation of the class into its class file format.intgetName()static booleanisExternalClassName(String className) private static StringmakeDesc(char builtin, int arity) A helper to build a type description based on a built-in type and an array arity.private static StringA helper to build a type description based on a Java class and an array arity.(package private) StringnameIndexToString(int index) get a string (UTF) given a name_index into the constant poolprivate voidput(ClassFormatOutput out)
-
Field Details
-
minor_version
protected int minor_versionMinor 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. -
major_version
protected int major_versionMinor class format number defaults to VMDescriptor.JAVA_CLASS_FORMAT_MAJOR_VERSION -
access_flags
protected int access_flags -
this_class
protected int this_class -
super_class
protected int super_class -
interfaces
protected int[] interfaces -
field_info
-
method_info
-
attribute_info
-
cptHashTable
-
cptEntries
-
cptEstimatedSize
private int cptEstimatedSize -
searchIndex
Used to search for index entries to avoid object allocation in the case a referecne already exists.
-
-
Constructor Details
-
ClassHolder
protected ClassHolder(int estimatedConstantPoolCount) -
ClassHolder
-
-
Method Details
-
put
- Throws:
IOException
-
getFileFormat
Convert the object representation of the class into its class file format.- Throws:
IOException- error writing the class
-
getModifier
public int getModifier()- See Also:
-
getName
- See Also:
-
addMember
- See Also:
-
addFieldReference
-
addFieldReference
-
addMethodReference
-
addReference
-
addReference
-
addConstant
- See Also:
-
addUtf8
- See Also:
-
addConstant
public int addConstant(int value) - See Also:
-
addConstant
public int addConstant(float value) - See Also:
-
addConstant
public int addConstant(long value) - See Also:
-
addConstant
public int addConstant(double value) - See Also:
-
getConstantPoolIndex
public int getConstantPoolIndex()- See Also:
-
addAttribute
-
getSuperClassName
-
addEntry
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
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
Add a class entry to the pool. -
addNameAndType
-
addUtf8Entry
Add a UTF8 into the pool and return the index to it. -
addExtraUtf8
Add an extra UTF8 into the pool -
addString
Add a string entry -
cptPut
- Throws:
IOException
-
getEntry
-
className
Return the class name for an index to a CONSTANT_Class_info. -
findUtf8
Return the index of a UTF entry or -1 if it doesn't exist. -
findClass
Find a class descriptor (section 4.4.1) and return its index, returns -1 if not found. -
findNameAndType
-
findIndexEntry
-
findIndexIndex
protected int findIndexIndex(int tag, int i1, int i2) -
findMatchingEntry
-
nameIndexToString
get a string (UTF) given a name_index into the constant pool -
getClassName
get the class name of a Class given the index of its CONSTANT_Class_info entry in the Constant Pool. -
isExternalClassName
-
convertToInternalClassName
-
convertToInternalDescriptor
-
convertToInternal
-
makeDesc
A helper to build a type description based on a built-in type and an array arity. -
makeDesc
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.
-