mirror of
https://github.com/revanced/smali.git
synced 2025-05-04 08:34:25 +02:00
Misc cleanup
git-svn-id: https://smali.googlecode.com/svn/trunk@202 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
ed91584410
commit
f730ada982
@ -124,15 +124,15 @@ public class AnnotationDirectoryItem extends OffsettedItem<AnnotationDirectoryIt
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<MethodAnnotation> getMethodAnnotations() {
|
public List<MethodAnnotation> getMethodAnnotations() {
|
||||||
return (List<MethodAnnotation>)methodAnnotationList.clone();
|
return Collections.unmodifiableList(methodAnnotationList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FieldAnnotation> getFieldAnnotations() {
|
public List<FieldAnnotation> getFieldAnnotations() {
|
||||||
return (List<FieldAnnotation>)fieldAnnotationList.clone();
|
return Collections.unmodifiableList(fieldAnnotationList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ParameterAnnotation> getParameterAnnotations() {
|
public List<ParameterAnnotation> getParameterAnnotations() {
|
||||||
return (List<ParameterAnnotation>)parameterAnnotationList.clone();
|
return Collections.unmodifiableList(parameterAnnotationList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import org.jf.dexlib.util.Input;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class CodeItem extends OffsettedItem<CodeItem> {
|
public class CodeItem extends OffsettedItem<CodeItem> {
|
||||||
private final ArrayList<InstructionField> instructionList;
|
private final ArrayList<InstructionField> instructionList;
|
||||||
@ -119,11 +120,11 @@ public class CodeItem extends OffsettedItem<CodeItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<InstructionField> getInstructions() {
|
public List<InstructionField> getInstructions() {
|
||||||
return (List<InstructionField>)instructionList.clone();
|
return Collections.unmodifiableList(instructionList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TryItem> getTries() {
|
public List<TryItem> getTries() {
|
||||||
return (List<TryItem>)tryItems.clone();
|
return Collections.unmodifiableList(tryItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DebugInfoItem getDebugInfo() {
|
public DebugInfoItem getDebugInfo() {
|
||||||
@ -437,18 +438,8 @@ public class CodeItem extends OffsettedItem<CodeItem> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: GROT
|
|
||||||
public int getHandlerCount() {
|
|
||||||
return list.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: GROT
|
|
||||||
public EncodedTypeAddrPair getHandler(int index) {
|
|
||||||
return list.get(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<EncodedTypeAddrPair> getHandlers() {
|
public List<EncodedTypeAddrPair> getHandlers() {
|
||||||
return (List<EncodedTypeAddrPair>)list.clone();
|
return Collections.unmodifiableList(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import org.jf.dexlib.util.Input;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class DebugInfoItem extends OffsettedItem<DebugInfoItem> {
|
public class DebugInfoItem extends OffsettedItem<DebugInfoItem> {
|
||||||
private final ArrayList<IndexedItemReference<StringIdItem>> parameterNames =
|
private final ArrayList<IndexedItemReference<StringIdItem>> parameterNames =
|
||||||
@ -95,7 +96,7 @@ public class DebugInfoItem extends OffsettedItem<DebugInfoItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<DebugInstruction> getDebugInstructions() {
|
public List<DebugInstruction> getDebugInstructions() {
|
||||||
return (List<DebugInstruction>)instructionFields.clone();
|
return Collections.unmodifiableList(instructionFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getParameterNames() {
|
public List<String> getParameterNames() {
|
||||||
|
@ -86,6 +86,6 @@ public class AnnotationEncodedValueSubField extends CompositeField<AnnotationEnc
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<AnnotationElement> getAnnotationElements() {
|
public List<AnnotationElement> getAnnotationElements() {
|
||||||
return (List<AnnotationElement>)annotationElementList.clone();
|
return Collections.unmodifiableList(annotationElementList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import org.jf.dexlib.*;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class ArrayEncodedValueSubField extends CompositeField<ArrayEncodedValueSubField>
|
public class ArrayEncodedValueSubField extends CompositeField<ArrayEncodedValueSubField>
|
||||||
implements EncodedValueSubField<ArrayEncodedValueSubField>
|
implements EncodedValueSubField<ArrayEncodedValueSubField>
|
||||||
@ -85,6 +86,6 @@ public class ArrayEncodedValueSubField extends CompositeField<ArrayEncodedValueS
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<EncodedValue> getValues() {
|
public List<EncodedValue> getValues() {
|
||||||
return (List<EncodedValue>)encodedValues.clone();
|
return Collections.unmodifiableList(encodedValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,29 +29,22 @@
|
|||||||
package org.jf.dexlib;
|
package org.jf.dexlib;
|
||||||
|
|
||||||
import org.jf.dexlib.util.AnnotatedOutput;
|
import org.jf.dexlib.util.AnnotatedOutput;
|
||||||
import org.jf.dexlib.util.ByteArray;
|
|
||||||
import org.jf.dexlib.util.Input;
|
import org.jf.dexlib.util.Input;
|
||||||
|
|
||||||
public class FixedByteArrayField implements Field<FixedByteArrayField> {
|
public class FixedSizeByteArrayField implements Field<FixedSizeByteArrayField> {
|
||||||
protected byte[] value;
|
protected byte[] value;
|
||||||
private final String fieldName;
|
private final String fieldName;
|
||||||
|
|
||||||
public FixedByteArrayField(int size, String fieldName) {
|
public FixedSizeByteArrayField(int size, String fieldName) {
|
||||||
value = new byte[size];
|
value = new byte[size];
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FixedByteArrayField(byte[] bytes, String fieldName) {
|
public FixedSizeByteArrayField(byte[] bytes, String fieldName) {
|
||||||
this.value = bytes.clone();
|
this.value = bytes.clone();
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FixedByteArrayField(ByteArray byteArray, String fieldName) {
|
|
||||||
value = new byte[byteArray.size()];
|
|
||||||
byteArray.getBytes(value, 0);
|
|
||||||
this.fieldName = fieldName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeTo(AnnotatedOutput out) {
|
public void writeTo(AnnotatedOutput out) {
|
||||||
if (fieldName != null) {
|
if (fieldName != null) {
|
||||||
out.annotate(fieldName);
|
out.annotate(fieldName);
|
||||||
@ -67,7 +60,7 @@ public class FixedByteArrayField implements Field<FixedByteArrayField> {
|
|||||||
return offset + value.length;
|
return offset + value.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyTo(DexFile dexFile, FixedByteArrayField copy) {
|
public void copyTo(DexFile dexFile, FixedSizeByteArrayField copy) {
|
||||||
copy.value = value.clone();
|
copy.value = value.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -45,9 +45,9 @@ public class HeaderItem extends IndexedItem<HeaderItem> {
|
|||||||
/** the endianness tag */
|
/** the endianness tag */
|
||||||
private static final int ENDIAN_TAG = 0x12345678;
|
private static final int ENDIAN_TAG = 0x12345678;
|
||||||
|
|
||||||
private final FixedByteArrayField magicField;
|
private final FixedSizeByteArrayField magicField;
|
||||||
private final IntegerField checksumField;
|
private final IntegerField checksumField;
|
||||||
private final FixedByteArrayField signatureField;
|
private final FixedSizeByteArrayField signatureField;
|
||||||
private final IntegerField fileSizeField;
|
private final IntegerField fileSizeField;
|
||||||
private final IntegerField headerSizeField;
|
private final IntegerField headerSizeField;
|
||||||
private final IntegerField endianTagField;
|
private final IntegerField endianTagField;
|
||||||
@ -69,14 +69,14 @@ public class HeaderItem extends IndexedItem<HeaderItem> {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
fields = new Field[] {
|
fields = new Field[] {
|
||||||
magicField = new FixedByteArrayField(MAGIC.getBytes("US-ASCII"), "magic"),
|
magicField = new FixedSizeByteArrayField(MAGIC.getBytes("US-ASCII"), "magic"),
|
||||||
checksumField = new IntegerField("checksum") {
|
checksumField = new IntegerField("checksum") {
|
||||||
public void writeTo(AnnotatedOutput out) {
|
public void writeTo(AnnotatedOutput out) {
|
||||||
cacheValue(0);
|
cacheValue(0);
|
||||||
super.writeTo(out);
|
super.writeTo(out);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
signatureField = new FixedByteArrayField(20, "signature") {
|
signatureField = new FixedSizeByteArrayField(20, "signature") {
|
||||||
public void writeTo(AnnotatedOutput out) {
|
public void writeTo(AnnotatedOutput out) {
|
||||||
for (int i = 0; i < value.length; i++) {
|
for (int i = 0; i < value.length; i++) {
|
||||||
value[i] = 0;
|
value[i] = 0;
|
||||||
|
@ -45,12 +45,6 @@ public class NullTerminatedByteArrayField implements Field<NullTerminatedByteArr
|
|||||||
this.value = value.clone();
|
this.value = value.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public NullTerminatedByteArrayField(ByteArray byteArray, String fieldName) {
|
|
||||||
this(fieldName);
|
|
||||||
value = new byte[byteArray.size()];
|
|
||||||
byteArray.getBytes(value, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeTo(AnnotatedOutput out) {
|
public void writeTo(AnnotatedOutput out) {
|
||||||
out.annotate(fieldName);
|
out.annotate(fieldName);
|
||||||
out.write(value);
|
out.write(value);
|
||||||
|
@ -65,7 +65,6 @@ public abstract class OffsettedSection<T extends OffsettedItem<T>> extends Secti
|
|||||||
T item = getByOffset(in.getCursor());
|
T item = getByOffset(in.getCursor());
|
||||||
item.readFrom(in, i);
|
item.readFrom(in, i);
|
||||||
|
|
||||||
//TODO: why are we aligning afterwards?
|
|
||||||
in.alignTo(item.getAlignment());
|
in.alignTo(item.getAlignment());
|
||||||
}
|
}
|
||||||
//sort the items list by offset
|
//sort the items list by offset
|
||||||
|
@ -65,10 +65,12 @@ public class TryListBuilderTest
|
|||||||
|
|
||||||
Assert.assertTrue(encodedCatchHandler.getCatchAllAddress() == catchAllAddress);
|
Assert.assertTrue(encodedCatchHandler.getCatchAllAddress() == catchAllAddress);
|
||||||
|
|
||||||
Assert.assertTrue(encodedCatchHandler.getHandlerCount() == handlers.length);
|
List<CodeItem.EncodedTypeAddrPair> typeAddrPairs = encodedCatchHandler.getHandlers();
|
||||||
|
|
||||||
|
Assert.assertTrue(typeAddrPairs.size() == handlers.length);
|
||||||
|
|
||||||
for (int i=0; i<handlers.length; i++) {
|
for (int i=0; i<handlers.length; i++) {
|
||||||
CodeItem.EncodedTypeAddrPair typeAddrPair = encodedCatchHandler.getHandler(i);
|
CodeItem.EncodedTypeAddrPair typeAddrPair = typeAddrPairs.get(i);
|
||||||
Handler handler = handlers[i];
|
Handler handler = handlers[i];
|
||||||
|
|
||||||
Assert.assertTrue(typeAddrPair.getTypeReferenceField().getTypeDescriptor().compareTo(handler.type) == 0);
|
Assert.assertTrue(typeAddrPair.getTypeReferenceField().getTypeDescriptor().compareTo(handler.type) == 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user