General cleanup

This commit is contained in:
Ben Gruver 2012-10-20 23:58:36 -07:00
parent 380ca70a2c
commit 25d385a441
22 changed files with 82 additions and 68 deletions

View File

@ -285,8 +285,8 @@ public enum Opcode
SGET_OBJECT_VOLATILE((short)0xfd, "sget-object-volatile", ReferenceType.FIELD, Format.Format21c, Opcode.ODEX_ONLY | Opcode.ODEXED_STATIC_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER),
SPUT_OBJECT_VOLATILE((short)0xfe, "sput-object-volatile", ReferenceType.FIELD, Format.Format21c, Opcode.ODEX_ONLY | Opcode.ODEXED_STATIC_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE);
private static Opcode[] opcodesByValue;
private static HashMap<Integer, Opcode> opcodesByName;
private static final Opcode[] opcodesByValue;
private static final HashMap<Integer, Opcode> opcodesByName;
//if the instruction can throw an exception
public static final int CAN_THROW = 0x1;

View File

@ -67,12 +67,12 @@ public class DexBackedAnnotation implements Annotation {
return new VariableSizeList<AnnotationElement>(dexBuf, reader.getOffset()) {
@Nonnull
@Override
protected AnnotationElement readItem(DexReader reader, int index) {
protected AnnotationElement readItem(@Nonnull DexReader reader, int index) {
return new DexBackedAnnotationElement(reader);
}
@Override
protected void skipItem(DexReader reader, int index) {
protected void skipItem(@Nonnull DexReader reader, int index) {
DexBackedAnnotationElement.skipFrom(reader);
}

View File

@ -41,12 +41,12 @@ public class DexBackedAnnotationElement implements AnnotationElement {
@Nonnull public final String name;
@Nonnull public final EncodedValue value;
public DexBackedAnnotationElement(DexReader reader) {
public DexBackedAnnotationElement(@Nonnull DexReader reader) {
this.name = reader.getString(reader.readSmallUleb128());
this.value = DexBackedEncodedValue.readFrom(reader);
}
public static void skipFrom(DexReader reader) {
public static void skipFrom(@Nonnull DexReader reader) {
reader.skipUleb128();
DexBackedEncodedValue.skipFrom(reader);
}

View File

@ -43,7 +43,7 @@ public class DexBackedCatchAllExceptionHandler extends ImmutableExceptionHandler
instructionOffsetMap.getInstructionIndexAtOffsetExact(reader.readSmallUleb128()));
}
public static void skipFrom(DexReader reader) {
public static void skipFrom(@Nonnull DexReader reader) {
reader.skipUleb128();
}
}

View File

@ -92,6 +92,7 @@ public class DexBackedClassDef implements ClassDef {
if (interfacesOffset > 0) {
final int size = dexBuf.readSmallUint(interfacesOffset);
return new FixedSizeList<String>() {
@Nonnull
@Override
public String readItem(int index) {
return dexBuf.getString(dexBuf.readSmallUint(interfacesOffset + 4 + (2*index)));
@ -136,7 +137,7 @@ public class DexBackedClassDef implements ClassDef {
@Nonnull
@Override
protected DexBackedField readItem(DexReader reader, int index) {
protected DexBackedField readItem(@Nonnull DexReader reader, int index) {
DexBackedField item = new DexBackedField(reader, previousFieldIndex,
staticInitialValueIterator, annotationIterator);
previousFieldIndex = item.fieldIndex;
@ -144,7 +145,7 @@ public class DexBackedClassDef implements ClassDef {
}
@Override
protected void skipItem(DexReader reader, int index) {
protected void skipItem(@Nonnull DexReader reader, int index) {
previousFieldIndex = DexBackedField.skipEncodedField(reader, previousFieldIndex);
staticInitialValueIterator.skipNext();
}
@ -188,7 +189,7 @@ public class DexBackedClassDef implements ClassDef {
@Nonnull
@Override
protected DexBackedMethod readItem(DexReader reader, int index) {
protected DexBackedMethod readItem(@Nonnull DexReader reader, int index) {
DexBackedMethod item = new DexBackedMethod(reader, previousMethodIndex,
methodAnnotationIterator, parameterAnnotationIterator);
previousMethodIndex = item.methodIndex;
@ -196,7 +197,7 @@ public class DexBackedClassDef implements ClassDef {
}
@Override
protected void skipItem(DexReader reader, int index) {
protected void skipItem(@Nonnull DexReader reader, int index) {
previousMethodIndex = DexBackedMethod.skipEncodedMethod(reader, previousMethodIndex);
staticInitialValueIterator.skipNext();
}

View File

@ -41,9 +41,7 @@ import java.util.List;
public class DexBackedDexFile implements DexFile {
@Nonnull public final DexBuffer dexBuf;
private static final int CLASS_DEF_SIZE = 32;
public DexBackedDexFile(DexBuffer dexBuf) {
public DexBackedDexFile(@Nonnull DexBuffer dexBuf) {
this.dexBuf = dexBuf;
}
@ -53,6 +51,7 @@ public class DexBackedDexFile implements DexFile {
final int classCount = dexBuf.getClassCount();
return new FixedSizeList<ClassDef>() {
@Nonnull
@Override
public ClassDef readItem(int index) {
int classOffset = dexBuf.getClassDefOffset(index);

View File

@ -44,7 +44,7 @@ public class DexBackedExceptionHandler extends ImmutableExceptionHandler {
instructionOffsetMap.getInstructionIndexAtOffsetExact(reader.readSmallUleb128()));
}
public static void skipFrom(DexReader reader) {
public static void skipFrom(@Nonnull DexReader reader) {
reader.skipUleb128();
reader.skipUleb128();
}

View File

@ -73,7 +73,6 @@ public class DexBackedField implements Field {
this.name = reader.getString(reader.readSmallUint(fieldIdItemOffset + NAME_OFFSET));
}
@Nonnull @Override public String getName() { return name; }
@Nonnull @Override public String getType() { return type; }
@Override public int getAccessFlags() { return accessFlags; }

View File

@ -103,6 +103,7 @@ public class DexBackedMethod implements Method {
final int size = dexBuf.readSmallUint(parametersOffset);
return new FixedSizeList<MethodParameter>() {
@Nonnull
@Override
public MethodParameter readItem(final int index) {
return new MethodParameter() {

View File

@ -83,6 +83,7 @@ public class DexBackedMethodImplementation implements MethodImplementation {
final int handlersStartOffset = triesStartOffset + triesSize*TRY_ITEM_SIZE;
return new FixedSizeList<TryBlock>() {
@Nonnull
@Override
public TryBlock readItem(int index) {
return new DexBackedTryBlock(dexBuf,
@ -100,6 +101,7 @@ public class DexBackedMethodImplementation implements MethodImplementation {
return ImmutableList.of();
}
@Nonnull
private ImmutableList<? extends Instruction> buildInstructionList() {
// instructionsSize is the number of 16-bit code units in the instruction list, not the number of instructions
int instructionsSize = dexBuf.readSmallUint(codeOffset + INSTRUCTIONS_SIZE_OFFSET);
@ -124,6 +126,7 @@ public class DexBackedMethodImplementation implements MethodImplementation {
*
* @return An InstructionOffsetMap object
*/
@Nonnull
private InstructionOffsetMap buildInstructionOffsetMap() {
int[] offsets = new int[instructions.size()];
int currentOffset = 0;

View File

@ -40,8 +40,8 @@ import javax.annotation.Nonnull;
import java.util.List;
public class DexBackedTryBlock implements TryBlock {
public final DexBuffer dexBuf;
private final InstructionOffsetMap instructionOffsetMap;
@Nonnull public final DexBuffer dexBuf;
@Nonnull private final InstructionOffsetMap instructionOffsetMap;
public final int startIndex;
public final int instructionCount;
@ -52,10 +52,10 @@ public class DexBackedTryBlock implements TryBlock {
private static final int CODE_UNIT_COUNT_OFFSET = 4;
private static final int HANDLER_OFFSET_OFFSET = 6;
public DexBackedTryBlock(DexBuffer dexBuf,
public DexBackedTryBlock(@Nonnull DexBuffer dexBuf,
int tryItemOffset,
int handlersStartOffset,
InstructionOffsetMap instructionOffsetMap) {
@Nonnull InstructionOffsetMap instructionOffsetMap) {
this.dexBuf = dexBuf;
this.instructionOffsetMap = instructionOffsetMap;
@ -89,12 +89,12 @@ public class DexBackedTryBlock implements TryBlock {
return new VariableSizeList<ExceptionHandler>(dexBuf, reader.getOffset()) {
@Nonnull
@Override
protected ExceptionHandler readItem(DexReader reader, int index) {
protected ExceptionHandler readItem(@Nonnull DexReader reader, int index) {
return new DexBackedExceptionHandler(reader, instructionOffsetMap);
}
@Override
protected void skipItem(DexReader dexReader, int index) {
protected void skipItem(@Nonnull DexReader dexReader, int index) {
DexBackedExceptionHandler.skipFrom(dexReader);
}
@ -106,7 +106,7 @@ public class DexBackedTryBlock implements TryBlock {
return new VariableSizeList<ExceptionHandler>(dexBuf, reader.getOffset()) {
@Nonnull
@Override
protected ExceptionHandler readItem(DexReader dexReader, int index) {
protected ExceptionHandler readItem(@Nonnull DexReader dexReader, int index) {
if (index == sizeWithCatchAll-1) {
return new DexBackedCatchAllExceptionHandler(dexReader, instructionOffsetMap);
} else {
@ -115,7 +115,7 @@ public class DexBackedTryBlock implements TryBlock {
}
@Override
protected void skipItem(DexReader dexReader, int index) {
protected void skipItem(@Nonnull DexReader dexReader, int index) {
if (index == sizeWithCatchAll-1) {
DexBackedCatchAllExceptionHandler.skipFrom(dexReader);
} else {

View File

@ -293,7 +293,7 @@ public class DexReader {
int o = offset;
byte[] buf = dexBuf.buf;
int result = 0;
int result;
switch (bytes) {
case 4:
result = (buf[o] & 0xff) |
@ -325,7 +325,7 @@ public class DexReader {
int o = offset;
byte[] buf = dexBuf.buf;
long result = 0;
long result;
switch (bytes) {
case 8:
result = (buf[o] & 0xff) |
@ -391,7 +391,7 @@ public class DexReader {
int o = offset;
byte[] buf = dexBuf.buf;
long result = 0;
long result;
switch (bytes) {
case 8:
result = (buf[o] & 0xff) |

View File

@ -42,7 +42,8 @@ import org.jf.util.NibbleUtils;
import javax.annotation.Nonnull;
public abstract class DexBackedInstruction {
public static Instruction readFrom(DexReader reader) {
@Nonnull
public static Instruction readFrom(@Nonnull DexReader reader) {
int opcodeValue = reader.readUbyte();
Opcode opcode = Opcode.getOpcodeByValue(opcodeValue);
@ -106,19 +107,19 @@ public abstract class DexBackedInstruction {
}
@Nonnull
private static Instruction10t instruction10t(Opcode opcode, DexReader reader) {
private static Instruction10t instruction10t(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int offset = reader.readByte();
return new ImmutableInstruction10t(opcode, offset);
}
@Nonnull
private static Instruction10x instruction10x(Opcode opcode, DexReader reader) {
private static Instruction10x instruction10x(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
reader.skipByte();
return new ImmutableInstruction10x(opcode);
}
@Nonnull
private static Instruction11n instruction11n(Opcode opcode, DexReader reader) {
private static Instruction11n instruction11n(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int b = reader.readUbyte();
int registerA = NibbleUtils.extractLowUnsignedNibble(b);
int literal = NibbleUtils.extractHighSignedNibble(b);
@ -126,13 +127,13 @@ public abstract class DexBackedInstruction {
}
@Nonnull
private static Instruction11x instruction11x(Opcode opcode, DexReader reader) {
private static Instruction11x instruction11x(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerA = reader.readUbyte();
return new ImmutableInstruction11x(opcode, registerA);
}
@Nonnull
private static Instruction12x instruction12x(Opcode opcode, DexReader reader) {
private static Instruction12x instruction12x(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int b = reader.readUbyte();
int registerA = NibbleUtils.extractLowUnsignedNibble(b);
int registerB = NibbleUtils.extractHighUnsignedNibble(b);
@ -140,14 +141,14 @@ public abstract class DexBackedInstruction {
}
@Nonnull
private static Instruction20t instruction20t(Opcode opcode, DexReader reader) {
private static Instruction20t instruction20t(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
reader.skipByte();
int offset = reader.readShort();
return new ImmutableInstruction20t(opcode, offset);
}
@Nonnull
private static Instruction21c instruction21c(Opcode opcode, DexReader reader) {
private static Instruction21c instruction21c(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerA = reader.readUbyte();
int referenceIndex = reader.readUshort();
String reference = reader.getReference(opcode.referenceType, referenceIndex);
@ -155,35 +156,35 @@ public abstract class DexBackedInstruction {
}
@Nonnull
private static Instruction21ih instruction21ih(Opcode opcode, DexReader reader) {
private static Instruction21ih instruction21ih(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerA = reader.readUbyte();
int literalHat = reader.readShort();
return new ImmutableInstruction21ih(opcode, registerA, literalHat << 16);
}
@Nonnull
private static Instruction21lh instruction21lh(Opcode opcode, DexReader reader) {
private static Instruction21lh instruction21lh(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerA = reader.readUbyte();
int literalHat = reader.readShort();
return new ImmutableInstruction21lh(opcode, registerA, ((long)literalHat) << 48);
}
@Nonnull
private static Instruction21s instruction21s(Opcode opcode, DexReader reader) {
private static Instruction21s instruction21s(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerA = reader.readUbyte();
int literal = reader.readShort();
return new ImmutableInstruction21s(opcode, registerA, literal);
}
@Nonnull
private static Instruction21t instruction21t(Opcode opcode, DexReader reader) {
private static Instruction21t instruction21t(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerA = reader.readUbyte();
int offset = reader.readShort();
return new ImmutableInstruction21t(opcode, registerA, offset);
}
@Nonnull
private static Instruction22b instruction22b(Opcode opcode, DexReader reader) {
private static Instruction22b instruction22b(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerA = reader.readUbyte();
int registerB = reader.readUbyte();
int literal = reader.readByte();
@ -191,7 +192,7 @@ public abstract class DexBackedInstruction {
}
@Nonnull
private static Instruction22c instruction22c(Opcode opcode, DexReader reader) {
private static Instruction22c instruction22c(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int b = reader.readUbyte();
int registerA = NibbleUtils.extractLowUnsignedNibble(b);
int registerB = NibbleUtils.extractHighUnsignedNibble(b);
@ -202,7 +203,7 @@ public abstract class DexBackedInstruction {
}
@Nonnull
private static Instruction22s instruction22s(Opcode opcode, DexReader reader) {
private static Instruction22s instruction22s(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int b = reader.readUbyte();
int registerA = NibbleUtils.extractLowUnsignedNibble(b);
int registerB = NibbleUtils.extractHighUnsignedNibble(b);
@ -211,7 +212,7 @@ public abstract class DexBackedInstruction {
}
@Nonnull
private static Instruction22t instruction22t(Opcode opcode, DexReader reader) {
private static Instruction22t instruction22t(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int b = reader.readUbyte();
int registerA = NibbleUtils.extractLowUnsignedNibble(b);
int registerB = NibbleUtils.extractHighUnsignedNibble(b);
@ -220,14 +221,14 @@ public abstract class DexBackedInstruction {
}
@Nonnull
private static Instruction22x instruction22x(Opcode opcode, DexReader reader) {
private static Instruction22x instruction22x(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerA = reader.readUbyte();
int registerB = reader.readUshort();
return new ImmutableInstruction22x(opcode, registerA, registerB);
}
@Nonnull
private static Instruction23x instruction23x(Opcode opcode, DexReader reader) {
private static Instruction23x instruction23x(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerA = reader.readUbyte();
int registerB = reader.readUbyte();
int registerC = reader.readUbyte();
@ -235,14 +236,14 @@ public abstract class DexBackedInstruction {
}
@Nonnull
private static Instruction30t instruction30t(Opcode opcode, DexReader reader) {
private static Instruction30t instruction30t(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
reader.skipByte();
int offset = reader.readInt();
return new ImmutableInstruction30t(opcode, offset);
}
@Nonnull
private static Instruction31c instruction31c(Opcode opcode, DexReader reader) {
private static Instruction31c instruction31c(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerA = reader.readUbyte();
int referenceIndex = reader.readSmallUint();
String reference = reader.getReference(opcode.referenceType, referenceIndex);
@ -250,21 +251,21 @@ public abstract class DexBackedInstruction {
}
@Nonnull
private static Instruction31i instruction31i(Opcode opcode, DexReader reader) {
private static Instruction31i instruction31i(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerA = reader.readUbyte();
int literal = reader.readInt();
return new ImmutableInstruction31i(opcode, registerA, literal);
}
@Nonnull
private static Instruction31t instruction31t(Opcode opcode, DexReader reader) {
private static Instruction31t instruction31t(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerA = reader.readUbyte();
int offset = reader.readInt();
return new ImmutableInstruction31t(opcode, registerA, offset);
}
@Nonnull
private static Instruction32x instruction32x(Opcode opcode, DexReader reader) {
private static Instruction32x instruction32x(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
reader.skipByte();
int registerA = reader.readUshort();
int registerB = reader.readUshort();
@ -272,7 +273,7 @@ public abstract class DexBackedInstruction {
}
@Nonnull
private static Instruction35c instruction35c(Opcode opcode, DexReader reader) {
private static Instruction35c instruction35c(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int b = reader.readUbyte();
int registerCount = NibbleUtils.extractHighUnsignedNibble(b);
int registerG = NibbleUtils.extractLowUnsignedNibble(b);
@ -293,7 +294,7 @@ public abstract class DexBackedInstruction {
}
@Nonnull
private static Instruction3rc instruction3rc(Opcode opcode, DexReader reader) {
private static Instruction3rc instruction3rc(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerCount = reader.readUbyte();
int referenceIndex = reader.readUshort();
String reference = reader.getReference(opcode.referenceType, referenceIndex);
@ -302,7 +303,7 @@ public abstract class DexBackedInstruction {
}
@Nonnull
private static Instruction51l instruction51l(Opcode opcode, DexReader reader) {
private static Instruction51l instruction51l(@Nonnull Opcode opcode, @Nonnull DexReader reader) {
int registerA = reader.readUbyte();
long literal = reader.readLong();
return new ImmutableInstruction51l(opcode, registerA, literal);

View File

@ -53,6 +53,7 @@ public abstract class AnnotationsDirectory {
@Nonnull public abstract AnnotationIterator getMethodAnnotationIterator();
@Nonnull public abstract AnnotationIterator getParameterAnnotationIterator();
@Nonnull
public static AnnotationsDirectory newOrEmpty(@Nonnull DexBuffer dexBuf,
int directoryAnnotationsOffset) {
if (directoryAnnotationsOffset == 0) {
@ -76,6 +77,7 @@ public abstract class AnnotationsDirectory {
if (annotationSetOffset != 0) {
final int size = dexBuf.readSmallUint(annotationSetOffset);
return new FixedSizeList<DexBackedAnnotation>() {
@Nonnull
@Override
public DexBackedAnnotation readItem(int index) {
int annotationOffset = dexBuf.readSmallUint(annotationSetOffset + 4 + (4*index));
@ -89,12 +91,14 @@ public abstract class AnnotationsDirectory {
return ImmutableList.of();
}
@Nonnull
public static List<List<? extends DexBackedAnnotation>> getParameterAnnotations(@Nonnull final DexBuffer dexBuf,
final int annotationSetListOffset) {
if (annotationSetListOffset > 0) {
final int size = dexBuf.readSmallUint(annotationSetListOffset);
return new FixedSizeList<List<? extends DexBackedAnnotation>>() {
@Nonnull
@Override
public List<? extends DexBackedAnnotation> readItem(int index) {
int annotationSetOffset = dexBuf.readSmallUint(annotationSetListOffset + 4 + index * 4);

View File

@ -31,6 +31,7 @@
package org.jf.dexlib2.dexbacked.util;
import javax.annotation.Nonnull;
import java.util.AbstractList;
/**
@ -51,5 +52,6 @@ public abstract class FixedSizeList<T> extends AbstractList<T> {
* @param index The index of the item. This is guaranteed to be in [0, size)
* @return The item at the given index
*/
@Nonnull
public abstract T readItem(int index);
}

View File

@ -33,12 +33,13 @@ package org.jf.dexlib2.dexbacked.util;
import org.jf.util.ExceptionWithContext;
import javax.annotation.Nonnull;
import java.util.Arrays;
public class InstructionOffsetMap {
private final int[] instructionOffsets;
@Nonnull private final int[] instructionOffsets;
public InstructionOffsetMap(int[] instructionOffsets) {
public InstructionOffsetMap(@Nonnull int[] instructionOffsets) {
this.instructionOffsets = instructionOffsets;
}

View File

@ -41,7 +41,7 @@ import javax.annotation.Nullable;
public abstract class StaticInitialValueIterator {
public static final StaticInitialValueIterator EMPTY = new StaticInitialValueIterator() {
@Override public EncodedValue getNextOrNull() { return null; }
@Nullable @Override public EncodedValue getNextOrNull() { return null; }
@Override public void skipNext() {}
};

View File

@ -53,9 +53,9 @@ public abstract class VariableSizeList<T> extends AbstractSequentialList<T> {
}
@Nonnull
protected abstract T readItem(DexReader reader, int index);
protected abstract T readItem(@Nonnull DexReader reader, int index);
protected void skipItem(DexReader reader, int index) {
protected void skipItem(@Nonnull DexReader reader, int index) {
readItem(reader, index);
}

View File

@ -68,7 +68,7 @@ public abstract class VariableSizeListWithContext<T> extends AbstractSequentialL
private int index = 0;
@Nonnull private final DexReader reader;
public Iterator(DexBuffer dexBuf, int offset) {
public Iterator(@Nonnull DexBuffer dexBuf, int offset) {
this.reader = dexBuf.readerAt(offset);
}
@ -79,7 +79,7 @@ public abstract class VariableSizeListWithContext<T> extends AbstractSequentialL
*
* @return The next item that was read from {@code reader}
*/
@Nonnull protected abstract T readItem(DexReader reader, int index);
@Nonnull protected abstract T readItem(@Nonnull DexReader reader, int index);
/**
* Skip the next item in {@code reader}.
@ -88,7 +88,7 @@ public abstract class VariableSizeListWithContext<T> extends AbstractSequentialL
* can be overridden if skipping an item can be implemented more efficiently than reading
* the same item.
*/
protected void skipItem(DexReader reader, int index) {
protected void skipItem(@Nonnull DexReader reader, int index) {
readItem(reader, index);
}

View File

@ -54,12 +54,12 @@ public class DexBackedAnnotationEncodedValue implements AnnotationEncodedValue {
skipElements(reader);
}
public static void skipFrom(DexReader reader) {
public static void skipFrom(@Nonnull DexReader reader) {
reader.skipUleb128();
skipElements(reader);
}
private static void skipElements(DexReader reader) {
private static void skipElements(@Nonnull DexReader reader) {
int elementCount = reader.readSmallUleb128();
for (int i=0; i<elementCount; i++) {
reader.skipUleb128();
@ -79,12 +79,12 @@ public class DexBackedAnnotationEncodedValue implements AnnotationEncodedValue {
return new VariableSizeList<AnnotationElement>(dexBuf, reader.getOffset()) {
@Nonnull
@Override
protected AnnotationElement readItem(DexReader dexReader, int index) {
protected AnnotationElement readItem(@Nonnull DexReader dexReader, int index) {
return new DexBackedAnnotationElement(dexReader);
}
@Override
protected void skipItem(DexReader reader, int index) {
protected void skipItem(@Nonnull DexReader reader, int index) {
DexBackedAnnotationElement.skipFrom(reader);
}

View File

@ -74,7 +74,7 @@ public class DexBackedArrayEncodedValue implements ArrayEncodedValue {
}
@Override
protected void skipItem(DexReader reader, int index) {
protected void skipItem(@Nonnull DexReader reader, int index) {
DexBackedEncodedValue.skipFrom(reader);
}

View File

@ -38,8 +38,11 @@ import org.jf.dexlib2.immutable.value.*;
import org.jf.dexlib2.util.Preconditions;
import org.jf.util.ExceptionWithContext;
import javax.annotation.Nonnull;
public abstract class DexBackedEncodedValue {
public static EncodedValue readFrom(DexReader reader) {
@Nonnull
public static EncodedValue readFrom(@Nonnull DexReader reader) {
int startOffset = reader.getOffset();
try {
@ -105,7 +108,7 @@ public abstract class DexBackedEncodedValue {
}
}
public static void skipFrom(DexReader reader) {
public static void skipFrom(@Nonnull DexReader reader) {
int startOffset = reader.getOffset();
try {