Search in sources :

Example 6 with TypeEncodedValue

use of org.jf.dexlib2.iface.value.TypeEncodedValue in project atlas by alibaba.

the class EncodedValueAdaptor method writeTo.

public static void writeTo(@Nonnull IndentingWriter writer, @Nonnull EncodedValue encodedValue, @Nullable String containingClass) throws IOException {
    switch(encodedValue.getValueType()) {
        case ValueType.ANNOTATION:
            AnnotationEncodedValueAdaptor.writeTo(writer, (AnnotationEncodedValue) encodedValue, containingClass);
            return;
        case ValueType.ARRAY:
            ArrayEncodedValueAdaptor.writeTo(writer, (ArrayEncodedValue) encodedValue, containingClass);
            return;
        case ValueType.BOOLEAN:
            BooleanRenderer.writeTo(writer, ((BooleanEncodedValue) encodedValue).getValue());
            return;
        case ValueType.BYTE:
            ByteRenderer.writeTo(writer, ((ByteEncodedValue) encodedValue).getValue());
            return;
        case ValueType.CHAR:
            CharRenderer.writeTo(writer, ((CharEncodedValue) encodedValue).getValue());
            return;
        case ValueType.DOUBLE:
            DoubleRenderer.writeTo(writer, ((DoubleEncodedValue) encodedValue).getValue());
            return;
        case ValueType.ENUM:
            EnumEncodedValue enumEncodedValue = (EnumEncodedValue) encodedValue;
            boolean useImplicitReference = false;
            if (enumEncodedValue.getValue().getDefiningClass().equals(containingClass)) {
                useImplicitReference = true;
            }
            writer.write(".enum ");
            ReferenceUtil.writeFieldDescriptor(writer, enumEncodedValue.getValue(), useImplicitReference);
            return;
        case ValueType.FIELD:
            FieldEncodedValue fieldEncodedValue = (FieldEncodedValue) encodedValue;
            useImplicitReference = false;
            if (fieldEncodedValue.getValue().getDefiningClass().equals(containingClass)) {
                useImplicitReference = true;
            }
            ReferenceUtil.writeFieldDescriptor(writer, fieldEncodedValue.getValue(), useImplicitReference);
            return;
        case ValueType.FLOAT:
            FloatRenderer.writeTo(writer, ((FloatEncodedValue) encodedValue).getValue());
            return;
        case ValueType.INT:
            IntegerRenderer.writeTo(writer, ((IntEncodedValue) encodedValue).getValue());
            return;
        case ValueType.LONG:
            LongRenderer.writeTo(writer, ((LongEncodedValue) encodedValue).getValue());
            return;
        case ValueType.METHOD:
            MethodEncodedValue methodEncodedValue = (MethodEncodedValue) encodedValue;
            useImplicitReference = false;
            if (methodEncodedValue.getValue().getDefiningClass().equals(containingClass)) {
                useImplicitReference = true;
            }
            ReferenceUtil.writeMethodDescriptor(writer, methodEncodedValue.getValue(), useImplicitReference);
            return;
        case ValueType.NULL:
            writer.write("null");
            return;
        case ValueType.SHORT:
            ShortRenderer.writeTo(writer, ((ShortEncodedValue) encodedValue).getValue());
            return;
        case ValueType.STRING:
            ReferenceFormatter.writeStringReference(writer, ((StringEncodedValue) encodedValue).getValue());
            return;
        case ValueType.TYPE:
            writer.write(((TypeEncodedValue) encodedValue).getValue());
    }
}
Also used : FieldEncodedValue(org.jf.dexlib2.iface.value.FieldEncodedValue) EnumEncodedValue(org.jf.dexlib2.iface.value.EnumEncodedValue) MethodEncodedValue(org.jf.dexlib2.iface.value.MethodEncodedValue)

Example 7 with TypeEncodedValue

use of org.jf.dexlib2.iface.value.TypeEncodedValue in project smali by JesusFreke.

the class ImplicitReferenceTest method testImplicitMethodLiteral.

@Test
public void testImplicitMethodLiteral() throws RecognitionException, IOException {
    ClassDef classDef = SmaliTestUtils.compileSmali("" + ".class public LHelloWorld;\n" + ".super Ljava/lang/Object;\n" + ".field public static field1:Ljava/lang/reflect/Method; = toString()V\n" + ".field public static field2:Ljava/lang/reflect/Method; = V()V\n" + ".field public static field3:Ljava/lang/reflect/Method; = I()V\n" + ".field public static field4:Ljava/lang/Class; = I");
    Map<String, Field> fields = Maps.newHashMap();
    for (Field field : classDef.getFields()) {
        fields.put(field.getName(), field);
    }
    Field field = fields.get("field1");
    Assert.assertNotNull(field);
    Assert.assertNotNull(field.getInitialValue());
    Assert.assertEquals(ValueType.METHOD, field.getInitialValue().getValueType());
    MethodEncodedValue methodEncodedValue = (MethodEncodedValue) field.getInitialValue();
    Assert.assertEquals(classDef.getType(), methodEncodedValue.getValue().getDefiningClass());
    Assert.assertEquals("toString", methodEncodedValue.getValue().getName());
    field = fields.get("field2");
    Assert.assertNotNull(field);
    Assert.assertNotNull(field.getInitialValue());
    Assert.assertEquals(ValueType.METHOD, field.getInitialValue().getValueType());
    methodEncodedValue = (MethodEncodedValue) field.getInitialValue();
    Assert.assertEquals(classDef.getType(), methodEncodedValue.getValue().getDefiningClass());
    Assert.assertEquals("V", methodEncodedValue.getValue().getName());
    field = fields.get("field3");
    Assert.assertNotNull(field);
    Assert.assertNotNull(field.getInitialValue());
    Assert.assertEquals(ValueType.METHOD, field.getInitialValue().getValueType());
    methodEncodedValue = (MethodEncodedValue) field.getInitialValue();
    Assert.assertEquals(classDef.getType(), methodEncodedValue.getValue().getDefiningClass());
    Assert.assertEquals("I", methodEncodedValue.getValue().getName());
    field = fields.get("field4");
    Assert.assertNotNull(field);
    Assert.assertNotNull(field.getInitialValue());
    Assert.assertEquals(ValueType.TYPE, field.getInitialValue().getValueType());
    TypeEncodedValue typeEncodedValue = (TypeEncodedValue) field.getInitialValue();
    Assert.assertEquals("I", typeEncodedValue.getValue());
}
Also used : Field(org.jf.dexlib2.iface.Field) ClassDef(org.jf.dexlib2.iface.ClassDef) TypeEncodedValue(org.jf.dexlib2.iface.value.TypeEncodedValue) MethodEncodedValue(org.jf.dexlib2.iface.value.MethodEncodedValue) Test(org.junit.Test)

Example 8 with TypeEncodedValue

use of org.jf.dexlib2.iface.value.TypeEncodedValue in project soot by Sable.

the class DexAnnotation method handleAnnotationElement.

private ArrayList<AnnotationElem> handleAnnotationElement(AnnotationElement ae, List<? extends EncodedValue> evList) {
    ArrayList<AnnotationElem> aelemList = new ArrayList<AnnotationElem>();
    for (EncodedValue ev : evList) {
        int type = ev.getValueType();
        AnnotationElem elem = null;
        switch(type) {
            case // BYTE
            0x00:
                {
                    ByteEncodedValue v = (ByteEncodedValue) ev;
                    elem = new AnnotationIntElem(v.getValue(), 'B', ae.getName());
                    break;
                }
            case // SHORT
            0x02:
                {
                    ShortEncodedValue v = (ShortEncodedValue) ev;
                    elem = new AnnotationIntElem(v.getValue(), 'S', ae.getName());
                    break;
                }
            case // CHAR
            0x03:
                {
                    CharEncodedValue v = (CharEncodedValue) ev;
                    elem = new AnnotationIntElem(v.getValue(), 'C', ae.getName());
                    break;
                }
            case // INT
            0x04:
                {
                    IntEncodedValue v = (IntEncodedValue) ev;
                    elem = new AnnotationIntElem(v.getValue(), 'I', ae.getName());
                    break;
                }
            case // LONG
            0x06:
                {
                    LongEncodedValue v = (LongEncodedValue) ev;
                    elem = new AnnotationLongElem(v.getValue(), 'J', ae.getName());
                    break;
                }
            case // FLOAT
            0x10:
                {
                    FloatEncodedValue v = (FloatEncodedValue) ev;
                    elem = new AnnotationFloatElem(v.getValue(), 'F', ae.getName());
                    break;
                }
            case // DOUBLE
            0x11:
                {
                    DoubleEncodedValue v = (DoubleEncodedValue) ev;
                    elem = new AnnotationDoubleElem(v.getValue(), 'D', ae.getName());
                    break;
                }
            case // STRING
            0x17:
                {
                    StringEncodedValue v = (StringEncodedValue) ev;
                    elem = new AnnotationStringElem(v.getValue(), 's', ae.getName());
                    break;
                }
            case // TYPE
            0x18:
                {
                    TypeEncodedValue v = (TypeEncodedValue) ev;
                    elem = new AnnotationClassElem(v.getValue(), 'c', ae.getName());
                    break;
                }
            case // FIELD (Dalvik specific?)
            0x19:
                {
                    FieldEncodedValue v = (FieldEncodedValue) ev;
                    FieldReference fr = v.getValue();
                    String fieldSig = "";
                    fieldSig += DexType.toSootAT(fr.getDefiningClass()) + ": ";
                    fieldSig += DexType.toSootAT(fr.getType()) + " ";
                    fieldSig += fr.getName();
                    elem = new AnnotationStringElem(fieldSig, 'f', ae.getName());
                    break;
                }
            case // METHOD (Dalvik specific?)
            0x1a:
                {
                    MethodEncodedValue v = (MethodEncodedValue) ev;
                    MethodReference mr = v.getValue();
                    String className = DexType.toSootICAT(mr.getDefiningClass());
                    String returnType = DexType.toSootAT(mr.getReturnType());
                    String methodName = mr.getName();
                    String parameters = "";
                    for (CharSequence p : mr.getParameterTypes()) {
                        parameters += DexType.toSootAT(p.toString());
                    }
                    String mSig = className + " |" + methodName + " |" + parameters + " |" + returnType;
                    elem = new AnnotationStringElem(mSig, 'M', ae.getName());
                    break;
                }
            case // ENUM : Warning -> encoding Dalvik specific!
            0x1b:
                {
                    EnumEncodedValue v = (EnumEncodedValue) ev;
                    FieldReference fr = v.getValue();
                    elem = new AnnotationEnumElem(DexType.toSootAT(fr.getType()).toString(), fr.getName(), 'e', ae.getName());
                    break;
                }
            case // ARRAY
            0x1c:
                {
                    ArrayEncodedValue v = (ArrayEncodedValue) ev;
                    ArrayList<AnnotationElem> l = handleAnnotationElement(ae, v.getValue());
                    if (l != null)
                        elem = new AnnotationArrayElem(l, '[', ae.getName());
                    break;
                }
            case // ANNOTATION
            0x1d:
                {
                    AnnotationEncodedValue v = (AnnotationEncodedValue) ev;
                    AnnotationTag t = new AnnotationTag(DexType.toSootAT(v.getType()).toString());
                    for (AnnotationElement newElem : v.getElements()) {
                        List<EncodedValue> l = new ArrayList<EncodedValue>();
                        l.add(newElem.getValue());
                        List<AnnotationElem> aList = handleAnnotationElement(newElem, l);
                        if (aList != null)
                            for (AnnotationElem e : aList) t.addElem(e);
                    }
                    elem = new AnnotationAnnotationElem(t, '@', ae.getName());
                    break;
                }
            case // NULL (Dalvik specific?)
            0x1e:
                {
                    elem = new AnnotationStringElem(null, 'N', ae.getName());
                    break;
                }
            case // BOOLEAN
            0x1f:
                {
                    BooleanEncodedValue v = (BooleanEncodedValue) ev;
                    elem = new AnnotationBooleanElem(v.getValue(), 'Z', ae.getName());
                    break;
                }
            default:
                {
                    throw new RuntimeException("Unknown annotation element 0x" + Integer.toHexString(type));
                }
        }
        if (elem != null)
            aelemList.add(elem);
    }
    return aelemList;
}
Also used : AnnotationStringElem(soot.tagkit.AnnotationStringElem) AnnotationEncodedValue(org.jf.dexlib2.iface.value.AnnotationEncodedValue) AnnotationAnnotationElem(soot.tagkit.AnnotationAnnotationElem) FloatEncodedValue(org.jf.dexlib2.iface.value.FloatEncodedValue) ArrayList(java.util.ArrayList) ArrayEncodedValue(org.jf.dexlib2.iface.value.ArrayEncodedValue) VisibilityAnnotationTag(soot.tagkit.VisibilityAnnotationTag) AnnotationTag(soot.tagkit.AnnotationTag) VisibilityParameterAnnotationTag(soot.tagkit.VisibilityParameterAnnotationTag) ShortEncodedValue(org.jf.dexlib2.iface.value.ShortEncodedValue) FieldEncodedValue(org.jf.dexlib2.iface.value.FieldEncodedValue) EnumEncodedValue(org.jf.dexlib2.iface.value.EnumEncodedValue) AnnotationElement(org.jf.dexlib2.iface.AnnotationElement) AnnotationFloatElem(soot.tagkit.AnnotationFloatElem) ByteEncodedValue(org.jf.dexlib2.iface.value.ByteEncodedValue) StringEncodedValue(org.jf.dexlib2.iface.value.StringEncodedValue) List(java.util.List) ArrayList(java.util.ArrayList) CharEncodedValue(org.jf.dexlib2.iface.value.CharEncodedValue) AnnotationElem(soot.tagkit.AnnotationElem) AnnotationAnnotationElem(soot.tagkit.AnnotationAnnotationElem) TypeEncodedValue(org.jf.dexlib2.iface.value.TypeEncodedValue) FieldReference(org.jf.dexlib2.iface.reference.FieldReference) MethodEncodedValue(org.jf.dexlib2.iface.value.MethodEncodedValue) AnnotationBooleanElem(soot.tagkit.AnnotationBooleanElem) AnnotationLongElem(soot.tagkit.AnnotationLongElem) AnnotationArrayElem(soot.tagkit.AnnotationArrayElem) AnnotationEnumElem(soot.tagkit.AnnotationEnumElem) AnnotationEncodedValue(org.jf.dexlib2.iface.value.AnnotationEncodedValue) DoubleEncodedValue(org.jf.dexlib2.iface.value.DoubleEncodedValue) ShortEncodedValue(org.jf.dexlib2.iface.value.ShortEncodedValue) TypeEncodedValue(org.jf.dexlib2.iface.value.TypeEncodedValue) ArrayEncodedValue(org.jf.dexlib2.iface.value.ArrayEncodedValue) LongEncodedValue(org.jf.dexlib2.iface.value.LongEncodedValue) BooleanEncodedValue(org.jf.dexlib2.iface.value.BooleanEncodedValue) MethodEncodedValue(org.jf.dexlib2.iface.value.MethodEncodedValue) IntEncodedValue(org.jf.dexlib2.iface.value.IntEncodedValue) CharEncodedValue(org.jf.dexlib2.iface.value.CharEncodedValue) ByteEncodedValue(org.jf.dexlib2.iface.value.ByteEncodedValue) FieldEncodedValue(org.jf.dexlib2.iface.value.FieldEncodedValue) StringEncodedValue(org.jf.dexlib2.iface.value.StringEncodedValue) FloatEncodedValue(org.jf.dexlib2.iface.value.FloatEncodedValue) EncodedValue(org.jf.dexlib2.iface.value.EncodedValue) EnumEncodedValue(org.jf.dexlib2.iface.value.EnumEncodedValue) DoubleEncodedValue(org.jf.dexlib2.iface.value.DoubleEncodedValue) AnnotationDoubleElem(soot.tagkit.AnnotationDoubleElem) AnnotationIntElem(soot.tagkit.AnnotationIntElem) BooleanEncodedValue(org.jf.dexlib2.iface.value.BooleanEncodedValue) AnnotationClassElem(soot.tagkit.AnnotationClassElem) LongEncodedValue(org.jf.dexlib2.iface.value.LongEncodedValue) MethodReference(org.jf.dexlib2.iface.reference.MethodReference) IntEncodedValue(org.jf.dexlib2.iface.value.IntEncodedValue)

Example 9 with TypeEncodedValue

use of org.jf.dexlib2.iface.value.TypeEncodedValue in project atlas by alibaba.

the class ClassReIClassDef method getAnnotation.

public Set<? extends Annotation> getAnnotation(Set<? extends Annotation> annotations) {
    Set<ImmutableAnnotation> newAnnotations = new HashSet<ImmutableAnnotation>();
    for (Annotation annotation : annotations) {
        String type = annotation.getType();
        boolean isArray = false;
        if (type.startsWith("[")) {
            isArray = true;
        }
        String newType = DefineUtils.getDefineClassName(classProcessor.classProcess(DefineUtils.getDalvikClassName(type)).className, isArray);
        Set<? extends AnnotationElement> sets = annotation.getElements();
        Set<ImmutableAnnotationElement> newAnnotationElement = new HashSet<ImmutableAnnotationElement>();
        for (AnnotationElement annotationElement : sets) {
            String name = annotationElement.getName();
            EncodedValue encodedValue = annotationElement.getValue();
            if (encodedValue instanceof ArrayEncodedValue) {
                List<EncodedValue> lists = new ArrayList<EncodedValue>();
                for (EncodedValue encodedValueSub : ((ArrayEncodedValue) encodedValue).getValue()) {
                    if (encodedValueSub instanceof StringEncodedValue) {
                        String newValue = null;
                        boolean isArray1 = false;
                        String value = ((StringEncodedValue) encodedValueSub).getValue();
                        if (value.startsWith("[")) {
                            isArray1 = true;
                        }
                        if (basicValue.contains(value)) {
                            newValue = value;
                        } else if (value.startsWith("Ljava/util/") || !value.endsWith(";") || value.startsWith("Ljava/lang/") || !value.startsWith("L")) {
                            newValue = value;
                        } else {
                            newValue = DefineUtils.getDefineClassName(classProcessor.classProcess(DefineUtils.getDalvikClassName(value)).className, isArray1);
                        }
                        ImmutableStringEncodedValue immutableStringEncodedValue = new ImmutableStringEncodedValue(newValue);
                        lists.add(immutableStringEncodedValue);
                    } else if (encodedValueSub instanceof TypeEncodedValue) {
                        String newValueSub = null;
                        String value = ((TypeEncodedValue) encodedValueSub).getValue();
                        boolean isArray2 = false;
                        if (value.startsWith("[")) {
                            isArray2 = true;
                        }
                        if (basicValue.contains(value)) {
                            newValueSub = value;
                        } else if (value.startsWith("Ljava/util/") || value.startsWith("Ljava/lang/") || !value.endsWith(";")) {
                            newValueSub = value;
                        } else {
                            newValueSub = DefineUtils.getDefineClassName(classProcessor.classProcess(DefineUtils.getDalvikClassName(value)).className, isArray2);
                        }
                        ImmutableTypeEncodedValue immutableTypeEncodedValue = new ImmutableTypeEncodedValue(newValueSub);
                        lists.add(immutableTypeEncodedValue);
                    } else {
                        lists.add(encodedValue);
                    }
                }
                ImmutableArrayEncodedValue immutableArrayEncodedValue = new ImmutableArrayEncodedValue(lists);
                ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableArrayEncodedValue);
                newAnnotationElement.add(immutableAnnotationElement);
            } else if (encodedValue instanceof StringEncodedValue) {
                String value = ((StringEncodedValue) encodedValue).getValue();
                boolean isArray3 = false;
                if (value.startsWith("[")) {
                    isArray3 = true;
                }
                String newValue = null;
                if (basicValue.contains(value)) {
                    newValue = value;
                } else if (value.startsWith("Ljava/util/") || value.startsWith("Ljava/lang/") || !value.endsWith(";")) {
                    newValue = value;
                } else {
                    newValue = DefineUtils.getDefineClassName(classProcessor.classProcess(DefineUtils.getDalvikClassName(value)).className, isArray3);
                }
                ImmutableStringEncodedValue immutableStringEncodedValue = new ImmutableStringEncodedValue(newValue);
                ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableStringEncodedValue);
                newAnnotationElement.add(immutableAnnotationElement);
            } else if (encodedValue instanceof MethodEncodedValue) {
                MethodReference methodReference = ((MethodEncodedValue) encodedValue).getValue();
                String returnType = methodReference.getReturnType();
                boolean isBasic = false;
                List<? extends CharSequence> paramTypes = methodReference.getParameterTypes();
                List<CharSequence> dalvikParamTypes = new ArrayList<CharSequence>();
                List<CharSequence> newParamTypes = new ArrayList<CharSequence>();
                for (CharSequence charSequence : paramTypes) {
                    if (basicType.containsKey(charSequence.toString())) {
                        newParamTypes.add(charSequence);
                        dalvikParamTypes.add(basicType.get(charSequence.toString()));
                        continue;
                    }
                    dalvikParamTypes.add(DefineUtils.getDalvikClassName(charSequence.toString()) + (isArray ? "[]" : ""));
                    newParamTypes.add(DefineUtils.getDefineClassName(classProcessor.classProcess(DefineUtils.getDalvikClassName(charSequence.toString())).className, isArray));
                }
                final ImmutableMethodReference immutableReference = new ImmutableMethodReference(DefineUtils.getDefineClassName(classProcessor.classProcess(DefineUtils.getDalvikClassName(methodReference.getDefiningClass())).className, false), classProcessor.methodProcess(DefineUtils.getDalvikClassName(methodReference.getDefiningClass()), methodReference.getName(), isBasic ? basicType.get(methodReference.getReturnType()) : DefineUtils.getDalvikClassName(methodReference.getReturnType()) + (isArray ? "[]" : ""), StringUtils.join(dalvikParamTypes.toArray(), ",")).methodName, newParamTypes, isBasic ? returnType : DefineUtils.getDefineClassName(classProcessor.classProcess(DefineUtils.getDalvikClassName(methodReference.getReturnType())).className, methodReference.getReturnType().startsWith("[")));
                ImmutableMethodEncodedValue immutableMethodEncodedValue = new ImmutableMethodEncodedValue(immutableReference);
                ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableMethodEncodedValue);
                newAnnotationElement.add(immutableAnnotationElement);
            } else if (encodedValue instanceof TypeEncodedValue) {
                String newValueSub = null;
                String value = ((TypeEncodedValue) encodedValue).getValue();
                boolean isArray2 = false;
                if (value.startsWith("[")) {
                    isArray2 = true;
                }
                if (basicValue.contains(value)) {
                    newValueSub = value;
                } else if (value.startsWith("Ljava/util/") || value.startsWith("Ljava/lang/") || !value.endsWith(";")) {
                    newValueSub = value;
                } else {
                    newValueSub = DefineUtils.getDefineClassName(classProcessor.classProcess(DefineUtils.getDalvikClassName(value)).className, isArray2);
                }
                ImmutableTypeEncodedValue immutableTypeEncodedValue = new ImmutableTypeEncodedValue(newValueSub);
                ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableTypeEncodedValue);
                newAnnotationElement.add(immutableAnnotationElement);
            } else {
                newAnnotationElement.add(ImmutableAnnotationElement.of(annotationElement));
            }
        }
        ImmutableAnnotation immutableAnnotation = new ImmutableAnnotation(annotation.getVisibility(), newType, newAnnotationElement);
        newAnnotations.add(immutableAnnotation);
    }
    return newAnnotations;
}
Also used : ImmutableAnnotationElement(org.jf.dexlib2.immutable.ImmutableAnnotationElement) ArrayList(java.util.ArrayList) ImmutableArrayEncodedValue(org.jf.dexlib2.immutable.value.ImmutableArrayEncodedValue) ImmutableAnnotationElement(org.jf.dexlib2.immutable.ImmutableAnnotationElement) AnnotationElement(org.jf.dexlib2.iface.AnnotationElement) ImmutableStringEncodedValue(org.jf.dexlib2.immutable.value.ImmutableStringEncodedValue) ImmutableStringEncodedValue(org.jf.dexlib2.immutable.value.ImmutableStringEncodedValue) ImmutableArrayEncodedValue(org.jf.dexlib2.immutable.value.ImmutableArrayEncodedValue) HashSet(java.util.HashSet) ImmutableTypeEncodedValue(org.jf.dexlib2.immutable.value.ImmutableTypeEncodedValue) ImmutableMethodReference(org.jf.dexlib2.immutable.reference.ImmutableMethodReference) ImmutableMethodEncodedValue(org.jf.dexlib2.immutable.value.ImmutableMethodEncodedValue) ImmutableTypeEncodedValue(org.jf.dexlib2.immutable.value.ImmutableTypeEncodedValue) ImmutableMethodEncodedValue(org.jf.dexlib2.immutable.value.ImmutableMethodEncodedValue) ImmutableAnnotation(org.jf.dexlib2.immutable.ImmutableAnnotation) Annotation(org.jf.dexlib2.iface.Annotation) ImmutableAnnotation(org.jf.dexlib2.immutable.ImmutableAnnotation) ImmutableStringEncodedValue(org.jf.dexlib2.immutable.value.ImmutableStringEncodedValue) ImmutableTypeEncodedValue(org.jf.dexlib2.immutable.value.ImmutableTypeEncodedValue) ImmutableArrayEncodedValue(org.jf.dexlib2.immutable.value.ImmutableArrayEncodedValue) ImmutableMethodEncodedValue(org.jf.dexlib2.immutable.value.ImmutableMethodEncodedValue) MethodReference(org.jf.dexlib2.iface.reference.MethodReference) ImmutableMethodReference(org.jf.dexlib2.immutable.reference.ImmutableMethodReference)

Example 10 with TypeEncodedValue

use of org.jf.dexlib2.iface.value.TypeEncodedValue in project smali by JesusFreke.

the class DexPool method internEncodedValue.

void internEncodedValue(@Nonnull EncodedValue encodedValue) {
    switch(encodedValue.getValueType()) {
        case ValueType.ANNOTATION:
            AnnotationEncodedValue annotationEncodedValue = (AnnotationEncodedValue) encodedValue;
            typeSection.intern(annotationEncodedValue.getType());
            for (AnnotationElement element : annotationEncodedValue.getElements()) {
                stringSection.intern(element.getName());
                internEncodedValue(element.getValue());
            }
            break;
        case ValueType.ARRAY:
            for (EncodedValue element : ((ArrayEncodedValue) encodedValue).getValue()) {
                internEncodedValue(element);
            }
            break;
        case ValueType.STRING:
            stringSection.intern(((StringEncodedValue) encodedValue).getValue());
            break;
        case ValueType.TYPE:
            typeSection.intern(((TypeEncodedValue) encodedValue).getValue());
            break;
        case ValueType.ENUM:
            fieldSection.intern(((EnumEncodedValue) encodedValue).getValue());
            break;
        case ValueType.FIELD:
            fieldSection.intern(((FieldEncodedValue) encodedValue).getValue());
            break;
        case ValueType.METHOD:
            methodSection.intern(((MethodEncodedValue) encodedValue).getValue());
            break;
        case ValueType.METHOD_HANDLE:
            methodHandleSection.intern(((MethodHandleEncodedValue) encodedValue).getValue());
            break;
        case ValueType.METHOD_TYPE:
            protoSection.intern(((MethodTypeEncodedValue) encodedValue).getValue());
            break;
    }
}
Also used : AnnotationElement(org.jf.dexlib2.iface.AnnotationElement)

Aggregations

AnnotationElement (org.jf.dexlib2.iface.AnnotationElement)7 ArrayList (java.util.ArrayList)5 TypeEncodedValue (org.jf.dexlib2.iface.value.TypeEncodedValue)5 Annotation (org.jf.dexlib2.iface.Annotation)4 EncodedValue (org.jf.dexlib2.iface.value.EncodedValue)4 MethodReference (org.jf.dexlib2.iface.reference.MethodReference)3 MethodEncodedValue (org.jf.dexlib2.iface.value.MethodEncodedValue)3 HashSet (java.util.HashSet)2 List (java.util.List)2 DexBackedAnnotation (org.jf.dexlib2.dexbacked.DexBackedAnnotation)2 DexBackedAnnotationElement (org.jf.dexlib2.dexbacked.DexBackedAnnotationElement)2 DexBackedAnnotationEncodedValue (org.jf.dexlib2.dexbacked.value.DexBackedAnnotationEncodedValue)2 DexBackedArrayEncodedValue (org.jf.dexlib2.dexbacked.value.DexBackedArrayEncodedValue)2 DexBackedTypeEncodedValue (org.jf.dexlib2.dexbacked.value.DexBackedTypeEncodedValue)2 ArrayEncodedValue (org.jf.dexlib2.iface.value.ArrayEncodedValue)2 EnumEncodedValue (org.jf.dexlib2.iface.value.EnumEncodedValue)2 FieldEncodedValue (org.jf.dexlib2.iface.value.FieldEncodedValue)2 ImmutableAnnotation (org.jf.dexlib2.immutable.ImmutableAnnotation)2 ImmutableAnnotationElement (org.jf.dexlib2.immutable.ImmutableAnnotationElement)2 ImmutableMethodReference (org.jf.dexlib2.immutable.reference.ImmutableMethodReference)2