Search in sources :

Example 1 with MethodHandleEncodedValue

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

the class DexBackedCallSiteReference method getMethodHandle.

@Nonnull
@Override
public MethodHandleReference getMethodHandle() {
    EncodedArrayItemIterator iter = getCallSiteIterator();
    if (iter.getItemCount() < 3) {
        throw new ExceptionWithContext("Invalid call site item: must contain at least 3 entries.");
    }
    EncodedValue encodedValue = getCallSiteIterator().getNextOrNull();
    assert encodedValue != null;
    if (encodedValue.getValueType() != ValueType.METHOD_HANDLE) {
        throw new ExceptionWithContext("Invalid encoded value type (%d) for the first item in call site %d", encodedValue.getValueType(), callSiteIndex);
    }
    return ((MethodHandleEncodedValue) encodedValue).getValue();
}
Also used : MethodHandleEncodedValue(org.jf.dexlib2.iface.value.MethodHandleEncodedValue) EncodedValue(org.jf.dexlib2.iface.value.EncodedValue) MethodTypeEncodedValue(org.jf.dexlib2.iface.value.MethodTypeEncodedValue) StringEncodedValue(org.jf.dexlib2.iface.value.StringEncodedValue) MethodHandleEncodedValue(org.jf.dexlib2.iface.value.MethodHandleEncodedValue) ExceptionWithContext(org.jf.util.ExceptionWithContext) EncodedArrayItemIterator(org.jf.dexlib2.dexbacked.util.EncodedArrayItemIterator) Nonnull(javax.annotation.Nonnull)

Example 2 with MethodHandleEncodedValue

use of org.jf.dexlib2.iface.value.MethodHandleEncodedValue 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

Nonnull (javax.annotation.Nonnull)1 EncodedArrayItemIterator (org.jf.dexlib2.dexbacked.util.EncodedArrayItemIterator)1 AnnotationElement (org.jf.dexlib2.iface.AnnotationElement)1 EncodedValue (org.jf.dexlib2.iface.value.EncodedValue)1 MethodHandleEncodedValue (org.jf.dexlib2.iface.value.MethodHandleEncodedValue)1 MethodTypeEncodedValue (org.jf.dexlib2.iface.value.MethodTypeEncodedValue)1 StringEncodedValue (org.jf.dexlib2.iface.value.StringEncodedValue)1 ExceptionWithContext (org.jf.util.ExceptionWithContext)1