diff --git a/dexlib/src/main/java/org/jf/dexlib/ClassDefItem.java b/dexlib/src/main/java/org/jf/dexlib/ClassDefItem.java index 7729715a..8d6eb0c6 100644 --- a/dexlib/src/main/java/org/jf/dexlib/ClassDefItem.java +++ b/dexlib/src/main/java/org/jf/dexlib/ClassDefItem.java @@ -324,7 +324,7 @@ public class ClassDefItem extends Item { } private void placeClass(ClassDefItem classDefItem) { - if (classDefItem.getOffset() == -1) { + if (!classDefItem.isPlaced()) { TypeIdItem superType = classDefItem.superType; ClassDefItem superClassDefItem = unplacedClassDefsByType.get(superType); diff --git a/dexlib/src/main/java/org/jf/dexlib/Item.java b/dexlib/src/main/java/org/jf/dexlib/Item.java index 9a2ec5fd..98c23389 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Item.java +++ b/dexlib/src/main/java/org/jf/dexlib/Item.java @@ -189,6 +189,7 @@ public abstract class Item implements Comparable { /** + * Note that the item must have been placed before calling this method (See DexFile.place()) * @return the offset in the dex file where this item is located */ public int getOffset() { @@ -198,7 +199,8 @@ public abstract class Item implements Comparable { } /** - * @return the index of this item within the item's containing section + * Note that the item must have been placed before calling this method (See DexFile.place()) + * @return the index of this item within the item's containing section. */ public int getIndex() { Preconditions.checkState(index != -1, @@ -206,6 +208,13 @@ public abstract class Item implements Comparable { return index; } + /** + * @return True if this item has been placed, otherwise False + */ + public boolean isPlaced() { + return offset != -1; + } + /** * @return the DexFile that contains this item */