public TypeList readTypeList() { int size = readInt(); short[] types = readShortArray(size);
alignToFourBytes(); returnnew TypeList(Dex.this, types);
}
public String readString() { int offset = readInt(); int savedPosition = data.position(); int savedLimit = data.limit();
data.position(offset);
data.limit(data.capacity()); try { int expectedLength = readUleb128();
String result = Mutf8.decode(this, newchar[expectedLength]); if (result.length() != expectedLength) { thrownew DexException("Declared length " + expectedLength
+ " doesn't match decoded length of " + result.length());
} return result;
} catch (UTFDataFormatException e) { thrownew DexException(e);
} finally {
data.position(savedPosition);
data.limit(savedLimit);
}
}
public FieldId readFieldId() { int declaringClassIndex = readUnsignedShort(); int typeIndex = readUnsignedShort(); int nameIndex = readInt(); returnnew FieldId(Dex.this, declaringClassIndex, typeIndex, nameIndex);
}
public MethodId readMethodId() { int declaringClassIndex = readUnsignedShort(); int protoIndex = readUnsignedShort(); int nameIndex = readInt(); returnnew MethodId(Dex.this, declaringClassIndex, protoIndex, nameIndex);
}
public ProtoId readProtoId() { int shortyIndex = readInt(); int returnTypeIndex = readInt(); int parametersOffset = readInt(); returnnew ProtoId(Dex.this, shortyIndex, returnTypeIndex, parametersOffset);
}
public CallSiteId readCallSiteId() { int offset = readInt(); returnnew CallSiteId(Dex.this, offset);
}
public MethodHandle readMethodHandle() {
MethodHandleType methodHandleType = MethodHandleType.fromValue(readUnsignedShort()); int unused1 = readUnsignedShort(); int fieldOrMethodId = readUnsignedShort(); int unused2 = readUnsignedShort(); returnnew MethodHandle(Dex.this, methodHandleType, unused1, fieldOrMethodId, unused2);
}
public ClassDef readClassDef() { int offset = getPosition(); int type = readInt(); int accessFlags = readInt(); int supertype = readInt(); int interfacesOffset = readInt(); int sourceFileIndex = readInt(); int annotationsOffset = readInt(); int classDataOffset = readInt(); int staticValuesOffset = readInt(); returnnew ClassDef(Dex.this, offset, type, accessFlags, supertype,
interfacesOffset, sourceFileIndex, annotationsOffset, classDataOffset,
staticValuesOffset);
}
private Code readCode() { int registersSize = readUnsignedShort(); int insSize = readUnsignedShort(); int outsSize = readUnsignedShort(); int triesSize = readUnsignedShort(); int debugInfoOffset = readInt(); int instructionsSize = readInt(); short[] instructions = readShortArray(instructionsSize); Try[] tries;
CatchHandler[] catchHandlers; if (triesSize > 0) { if (instructions.length % 2 == 1) {
readShort(); // padding
}
private CatchHandler[] readCatchHandlers() { int baseOffset = data.position(); int catchHandlersSize = readUleb128();
CatchHandler[] result = new CatchHandler[catchHandlersSize]; for (int i = 0; i < catchHandlersSize; i++) { int offset = data.position() - baseOffset;
result[i] = readCatchHandler(offset);
} return result;
}
privateTry[] readTries(int triesSize, CatchHandler[] catchHandlers) { Try[] result = newTry[triesSize]; for (int i = 0; i < triesSize; i++) { int startAddress = readInt(); int instructionCount = readUnsignedShort(); int handlerOffset = readUnsignedShort(); int catchHandlerIndex = findCatchHandlerIndex(catchHandlers, handlerOffset);
result[i] = newTry(startAddress, instructionCount, catchHandlerIndex);
} return result;
}
privateint findCatchHandlerIndex(CatchHandler[] catchHandlers, int offset) { for (int i = 0; i < catchHandlers.length; i++) {
CatchHandler catchHandler = catchHandlers[i]; if (catchHandler.getOffset() == offset) { return i;
}
} thrownew IllegalArgumentException();
}
private CatchHandler readCatchHandler(int offset) { int size = readSleb128(); int handlersCount = Math.abs(size); int[] typeIndexes = newint[handlersCount]; int[] addresses = newint[handlersCount]; for (int i = 0; i < handlersCount; i++) {
typeIndexes[i] = readUleb128();
addresses[i] = readUleb128();
} int catchAllAddress = size <= 0 ? readUleb128() : -1; returnnew CatchHandler(typeIndexes, addresses, catchAllAddress, offset);
}
private ClassData.Field[] readFields(int count) {
ClassData.Field[] result = new ClassData.Field[count]; int fieldIndex = 0; for (int i = 0; i < count; i++) {
fieldIndex += readUleb128(); // field index diff int accessFlags = readUleb128();
result[i] = new ClassData.Field(fieldIndex, accessFlags);
} return result;
}
private ClassData.Method[] readMethods(int count) {
ClassData.Method[] result = new ClassData.Method[count]; int methodIndex = 0; for (int i = 0; i < count; i++) {
methodIndex += readUleb128(); // method index diff int accessFlags = readUleb128(); int codeOff = readUleb128();
result[i] = new ClassData.Method(methodIndex, accessFlags, codeOff);
} return result;
}
/** *Returnsabytearraycontainingthebytesfrom{@codestart}tothis *section'scurrentposition.
*/ privatebyte[] getBytesFrom(int start) { int end = data.position(); byte[] result = newbyte[end - start];
data.position(start);
data.get(result); return result;
}
public Annotation readAnnotation() { byte visibility = readByte(); int start = data.position(); new EncodedValueReader(this, EncodedValueReader.ENCODED_ANNOTATION).skipValue(); returnnew Annotation(Dex.this, visibility, new EncodedValue(getBytesFrom(start)));
}
public EncodedValue readEncodedArray() { int start = data.position(); new EncodedValueReader(this, EncodedValueReader.ENCODED_ARRAY).skipValue(); returnnew EncodedValue(getBytesFrom(start));
}
publicvoid writeUnsignedShort(int i) { short s = (short) i; if (i != (s & 0xffff)) { thrownew IllegalArgumentException("Expected an unsigned short: " + i);
}
writeShort(s);
}
publicvoid write(short[] shorts) { for (short s : shorts) {
writeShort(s);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.