|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ow2.asmdex.structureWriter.ConstantPool
public class ConstantPool
Constant Pool of the Application. It has a link to every element the Application holds.
Dalvik requires some structures to be sorted. It is faster to sort them once the Application is parsed
than adding elements one after one, so we manage first simple collections, and then the
prepareGeneration method builds the sorted ones.
Also, we use Symbolic elements from Strings, Fields, Types and Methods so that we can generate the bytecode
right after each method is parsed. This is useful to be able to destroy the elements related the Methods
when their parsing is over. The indexes are then remapped correctly after the Application is fully parsed
(see CodeItem.mapResolvedIndexes()).
NOTES :
- Empty Strings can be added to the Constant Pool, but only if useful. Empty parameters aren't encoded
in the Constant Pool (yet they are declared in the Debug Item). This is tested by the Debug Item
encoder though, not the Constant Pool itself.
- a "this" String is added by dx, I don't know exactly where it comes from. I add it when a
non-static/non-constructor Method is found, it seems logical.
| Constructor Summary | |
|---|---|
ConstantPool()
|
|
| Method Summary | |
|---|---|
void |
addAnnotationDirectoryItem(AnnotationDirectoryItem annotationDirectoryItem)
Adds an annotation_directory_item to the Constant Pool. |
void |
addAnnotationItemToConstantPool(AnnotationItem annotationItem)
Adds an annotation_item to the Constant Pool. |
void |
addAnnotationSetItemNoSizeCheck(AnnotationSetItem annotationSetItem)
Adds an annotation_set_item to the Constant Pool. |
void |
addAnnotationSetItemToConstantPool(AnnotationSetItem annotationSetItem)
Adds an annotation_set_item to the Constant Pool. |
void |
addAnnotationSetRefListToConstantPool(AnnotationSetRefList annotationSetRefList)
Adds an annotation_set_ref_list to the Constant Pool. |
ClassDefinitionItem |
addClassToConstantPool(java.lang.String className,
java.lang.String superName,
int access,
java.lang.String[] interfaceNames,
java.lang.String[] signature)
Adds a class to the constant pool. |
Field |
addFieldToConstantPool(java.lang.String fieldName,
java.lang.String desc,
java.lang.String classOwningName,
int access,
java.lang.String[] signature,
java.lang.Object value)
Adds a Field in the Constant Pool. |
Method |
addMethodToConstantPool(java.lang.String methodName,
java.lang.String className,
java.lang.String methodDescriptor,
int access,
java.lang.String[] signature,
java.lang.String[] exceptionNames)
Adds a Method to the Constant Pool being built. |
void |
addOffsetForStaticValuesEncodedArrayItemOfClass(ClassDefinitionItem cdi,
int offset)
Adds an offset for the encoded_array_item of a static_values_offset for one Class. |
void |
addPrototypeToConstantPool(Prototype prototype)
Adds a Prototype to the Constant Pool. |
Prototype |
addPrototypeToConstantPool(java.lang.String descriptor)
Creates a Prototype from the descriptor and adds it to the Constant Pool, as well as the Strings inside. |
void |
addStringsToConstantPool(java.lang.String[] strings)
Adds Strings to the Constant pool. |
void |
addStringToConstantPool(java.lang.String string)
Adds a String to the Constant Pool. |
void |
addTypeListToConstantPool(TypeList typeList)
Adds a TypeList to the Constant Pool, as well as the Strings inside. |
void |
addTypesToConstantPool(java.lang.String[] types)
Adds Types to the Constant Pool. |
void |
addTypeToConstantPool(java.lang.String type)
Adds a Type to the Constant Pool. |
int |
getAnnotationDirectoryItemCount()
Returns the count of the annotation_directory_item. |
int |
getAnnotationDirectoryItemOffset(AnnotationDirectoryItem annotationDirectoryItem)
Returns the offset of an annotation_directory_item, or 0 if the Class doesn't have an annotation_directory_item. |
java.util.HashSet<AnnotationDirectoryItem> |
getAnnotationDirectoryItems()
Returns the annotation_directory_items, unique but non-ordered. |
int |
getAnnotationItemCount()
Returns the count of annotation_items. |
int |
getAnnotationItemOffset(AnnotationItem annotationItem)
Returns the offset of an annotation_item. |
java.util.TreeSet<AnnotationItem> |
getAnnotationItems()
Returns the Set of annotation_items. |
int |
getAnnotationSetItemCount()
Returns the count of annotation_set_items. |
int |
getAnnotationSetItemOffset(AnnotationSetItem annotationSetItem)
Returns the offset of an annotation_set_item. |
java.util.TreeSet<AnnotationSetItem> |
getAnnotationSetItems()
Returns the set of annotation_set_item. |
int |
getAnnotationSetRefListOffset(AnnotationSetRefList annotationSetRefList)
Returns the offset of an annotation_set_ref_list. |
java.util.HashSet<AnnotationSetRefList> |
getAnnotationSetRefLists()
Returns the set of annotation_set_ref_list. |
int |
getAnnotationSetRefListsCount()
Returns the count of annotation_set_ref_lists. |
int |
getClassDefinitionCount()
Returns the number of Classes currently parsed. |
java.util.ArrayList<ClassDefinitionItem> |
getClasses()
Returns an ordered list of the classes of the Application. |
int |
getFieldCount()
Returns the number of Fields currently parsed. |
int |
getFieldIndex(Field field)
Returns the Index of a Field. |
java.util.TreeSet<Field> |
getFields()
Returns the ordered Fields of the Application. |
int |
getMethodCount()
Returns the number of Methods currently parsed. |
int |
getMethodIndex(Method method)
Returns the Index of a Method. |
java.util.TreeSet<Method> |
getMethods()
Returns the ordered Methods of the Application. |
int |
getOffsetOfStaticValuesEncodedArrayItemOfClass(ClassDefinitionItem cdi)
Returns the offset of the encoded_array_item of a static_values_offset for one Class if it exists. |
int |
getPrototypeCount()
Returns the number of Prototypes currently parsed. |
int |
getPrototypeIndex(Prototype prototype)
Returns the Index of a Prototype. |
java.util.TreeSet<Prototype> |
getPrototypes()
Returns the ordered Prototypes of the Application. |
int |
getResolvedFieldIndexFromSymbolicFieldIndex(int fieldIndex)
Returns the resolved Field index from the symbolic index. |
int |
getResolvedMethodIndexFromSymbolicMethodIndex(int methodIndex)
Returns the resolved method index from the symbolic index. |
int |
getResolvedStringIndexFromSymbolicStringIndex(int stringIndex)
Returns the resolved String index from the symbolic index. |
int |
getResolvedTypeIndexFromSymbolicTypeIndex(int typeIndex)
Returns the resolved Type index from the symbolic index. |
int |
getStringCount()
Returns the number of Strings currently parsed. |
int |
getStringIndex(java.lang.String string)
Returns the index of a String. |
java.util.TreeSet<java.lang.String> |
getStrings()
Returns the ordered Strings of the Application. |
int |
getTypeCount()
Returns the number of Types currently parsed. |
int |
getTypeIndex(java.lang.String type)
Returns the Index of a Type. |
java.util.TreeSet<TypeList> |
getTypeList()
Returns the ordered TypeLists of the Application. |
int |
getTypeListCount()
Returns the number of TypeList currently parsed. |
int |
getTypeListOffset(TypeList typeList)
Returns the Offset of a TypeList. |
java.util.TreeSet<java.lang.String> |
getTypes()
Returns the ordered Types of the Application. |
void |
prepareGeneration()
Prepares the various elements to be generated. |
void |
setAnnotationDirectoryItemOffset(AnnotationDirectoryItem annotationDirectoryItem,
int offset)
Sets the offset of an annotation_directory_item. |
void |
setAnnotationItemOffset(AnnotationItem annotationItem,
int offset)
Sets the offset of an annotation_item. |
void |
setAnnotationSetItemOffset(AnnotationSetItem annotationSetItem,
int offset)
Sets the offset of an annotation_set_item. |
void |
setAnnotationSetRefListOffset(AnnotationSetRefList annotationSetRefList,
int offset)
Sets the offset of an annotation_set_ref_list. |
void |
setTypeListOffset(TypeList typeList,
int offset)
Sets an Offset to a TypeList. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ConstantPool()
| Method Detail |
|---|
public int getStringCount()
public int getTypeCount()
public int getPrototypeCount()
public int getFieldCount()
public int getMethodCount()
public int getClassDefinitionCount()
public int getTypeListCount()
public java.util.TreeSet<java.lang.String> getStrings()
public java.util.TreeSet<java.lang.String> getTypes()
public java.util.TreeSet<Field> getFields()
public java.util.TreeSet<Prototype> getPrototypes()
public java.util.TreeSet<Method> getMethods()
public java.util.TreeSet<TypeList> getTypeList()
public int getStringIndex(java.lang.String string)
string - the String we want the index of.
public int getTypeListOffset(TypeList typeList)
typeList - the TypeList to find.
public void setTypeListOffset(TypeList typeList,
int offset)
typeList - the TypeList to give the Offset.offset - the Offset to set.public int getTypeIndex(java.lang.String type)
type - name of the Type.
public int getPrototypeIndex(Prototype prototype)
prototype - the Prototype.
public int getFieldIndex(Field field)
field - the Field.
public int getMethodIndex(Method method)
method - the Method.
public int getAnnotationItemOffset(AnnotationItem annotationItem)
annotationItem - the offset of the annotation_item.
public void setAnnotationItemOffset(AnnotationItem annotationItem,
int offset)
annotationItem - the annotation_item.offset - the Offset of the annotation_item.public int getAnnotationSetItemOffset(AnnotationSetItem annotationSetItem)
annotationSetItem - the annotation_set_item.
public void setAnnotationSetItemOffset(AnnotationSetItem annotationSetItem,
int offset)
annotationSetItem - the annotation_set_item.offset - the offset of the annotation_set_item.public int getAnnotationSetRefListOffset(AnnotationSetRefList annotationSetRefList)
annotationSetRefList - the annotation_set_ref_list.
public void setAnnotationSetRefListOffset(AnnotationSetRefList annotationSetRefList,
int offset)
annotationSetRefList - the annotation_set_ref_list.offset - the offset of the annotation_set_ref_list.public int getAnnotationDirectoryItemOffset(AnnotationDirectoryItem annotationDirectoryItem)
annotationDirectoryItem - the annotation_directory_item.
public void setAnnotationDirectoryItemOffset(AnnotationDirectoryItem annotationDirectoryItem,
int offset)
annotationDirectoryItem - the annotation_directory_item belongs to.offset - the offset of the annotation_directory_item.public java.util.TreeSet<AnnotationItem> getAnnotationItems()
public java.util.TreeSet<AnnotationSetItem> getAnnotationSetItems()
public java.util.HashSet<AnnotationSetRefList> getAnnotationSetRefLists()
public int getAnnotationItemCount()
public int getAnnotationSetItemCount()
public int getAnnotationSetRefListsCount()
public int getAnnotationDirectoryItemCount()
public int getOffsetOfStaticValuesEncodedArrayItemOfClass(ClassDefinitionItem cdi)
cdi - the Class.
public java.util.ArrayList<ClassDefinitionItem> getClasses()
public java.util.HashSet<AnnotationDirectoryItem> getAnnotationDirectoryItems()
public int getResolvedMethodIndexFromSymbolicMethodIndex(int methodIndex)
methodIndex - the symbolic method index.
public int getResolvedFieldIndexFromSymbolicFieldIndex(int fieldIndex)
fieldIndex - the symbolic Field index.
public int getResolvedTypeIndexFromSymbolicTypeIndex(int typeIndex)
typeIndex - the symbolic Type index.
public int getResolvedStringIndexFromSymbolicStringIndex(int stringIndex)
stringIndex - the symbolic String index.
public void addStringToConstantPool(java.lang.String string)
string - the String to add.public void addStringsToConstantPool(java.lang.String[] strings)
strings - the Strings to add.public void addTypeToConstantPool(java.lang.String type)
type - the Type to add.public void addTypesToConstantPool(java.lang.String[] types)
types - the Types to add.public void addPrototypeToConstantPool(Prototype prototype)
prototype - Prototype to add.public Prototype addPrototypeToConstantPool(java.lang.String descriptor)
descriptor - full descriptor in the TypeDescriptor format.
public void addTypeListToConstantPool(TypeList typeList)
typeList - the TypeList to add to the Constant Pool.
public Method addMethodToConstantPool(java.lang.String methodName,
java.lang.String className,
java.lang.String methodDescriptor,
int access,
java.lang.String[] signature,
java.lang.String[] exceptionNames)
methodName - the method name.className - the class name of the method.methodDescriptor - the method descriptor.access - the access flags of the method.signature - the signature of the method. May be Null.exceptionNames - the exceptions of the method. May be null.
public Field addFieldToConstantPool(java.lang.String fieldName,
java.lang.String desc,
java.lang.String classOwningName,
int access,
java.lang.String[] signature,
java.lang.Object value)
fieldName - name of the Fielddesc - type of the field in TypeDescriptor format.classOwningName - name of the class owning the Field.access - the access flags of the Field.signature - the Signature of the field. May be Null.value - the value of the Field. Null for non-final static Fields.
public ClassDefinitionItem addClassToConstantPool(java.lang.String className,
java.lang.String superName,
int access,
java.lang.String[] interfaceNames,
java.lang.String[] signature)
className - the name of the class.superName - the name of the super class.access - the access flags of the class.interfaceNames - the name of the interfaces of the class.signature - the signature of the class. Used only for generics. May be null.
public void addAnnotationItemToConstantPool(AnnotationItem annotationItem)
annotationItem - the annotation_item to add.public void addAnnotationSetItemToConstantPool(AnnotationSetItem annotationSetItem)
annotationSetItem - the annotation_set_item to add.public void addAnnotationSetItemNoSizeCheck(AnnotationSetItem annotationSetItem)
annotationSetItem - the annotation_set_item to add.public void addAnnotationSetRefListToConstantPool(AnnotationSetRefList annotationSetRefList)
annotationSetRefList - the annotation_set_ref_list to add.
public void addOffsetForStaticValuesEncodedArrayItemOfClass(ClassDefinitionItem cdi,
int offset)
cdi - the class.offset - the offset to add.public void addAnnotationDirectoryItem(AnnotationDirectoryItem annotationDirectoryItem)
annotationDirectoryItem - the annotation_directory_item to add.public void prepareGeneration()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||