- Fixed an issue when trying to set a null AnnotationDirectoryItem to a ClassDefItem

- Fixed an issue when interning a CodeItem with no debug info
- Fixed an issue where the MapItem wasn't getting added to the dex file  correctly when creating a dex file from scratch

git-svn-id: https://smali.googlecode.com/svn/trunk@213 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2009-06-23 02:37:34 +00:00
parent 81014659d9
commit fdef6422d2
3 changed files with 13 additions and 9 deletions

View File

@ -209,7 +209,9 @@ public class ClassDefItem extends IndexedItem<ClassDefItem> {
public void setAnnotations(AnnotationDirectoryItem annotations) { public void setAnnotations(AnnotationDirectoryItem annotations) {
this.classAnnotationsReferenceField.setReference(annotations); this.classAnnotationsReferenceField.setReference(annotations);
annotations.setParent(this); if (annotations != null) {
annotations.setParent(this);
}
} }
public void setClassDataItem(ClassDataItem classDataItem) { public void setClassDataItem(ClassDataItem classDataItem) {
@ -261,12 +263,14 @@ public class ClassDefItem extends IndexedItem<ClassDefItem> {
public int placeSection(int offset) { public int placeSection(int offset) {
currentOffset = offset; currentOffset = offset;
//presort the list, to guarantee a unique ordering if (section.dexFile.getSortAllItems()) {
Collections.sort(section.items, new Comparator<ClassDefItem>() { //presort the list, to guarantee a unique ordering
public int compare(ClassDefItem classDefItem, ClassDefItem classDefItem1) { Collections.sort(section.items, new Comparator<ClassDefItem>() {
return classDefItem.getClassType().compareTo(classDefItem1.getClassType()); public int compare(ClassDefItem classDefItem, ClassDefItem classDefItem1) {
} return classDefItem.getClassType().compareTo(classDefItem1.getClassType());
}); }
});
}
for (ClassDefItem classDefItem: section.items) { for (ClassDefItem classDefItem: section.items) {
classDefItem.offset = -1; classDefItem.offset = -1;

View File

@ -152,7 +152,7 @@ public class CodeItem extends OffsettedItem<CodeItem> {
triesListField.copyTo(dexFile, copy.triesListField); triesListField.copyTo(dexFile, copy.triesListField);
DebugInfoItem copyDebugInfo = copy.getDebugInfo(); DebugInfoItem copyDebugInfo = copy.getDebugInfo();
if (copy != null) { if (copyDebugInfo != null) {
copyDebugInfo.setParent(copy); copyDebugInfo.setParent(copy);
} }
} }

View File

@ -588,7 +588,7 @@ public class DexFile
return new MapItem(dexFile, index); return new MapItem(dexFile, index);
} }
public MapItem intern(DexFile dexFile, MapItem item) { public MapItem intern(MapItem item) {
this.items.add(item); this.items.add(item);
return item; return item;
} }