Search in sources :

Example 6 with IMethodRef

use of jadx.api.plugins.input.data.IMethodRef in project jadx by skylot.

the class Smali method writeMethodDef.

private void writeMethodDef(SmaliWriter smali, IMethodData mth, LineInfo lineInfo) {
    smali.add(AccessFlags.format(mth.getAccessFlags(), METHOD));
    IMethodRef methodRef = mth.getMethodRef();
    methodRef.load();
    lineInfo.smaliMthNode.setDefPos(smali.getLength());
    smali.add(methodRef.getName()).add('(');
    methodRef.getArgTypes().forEach(smali::add);
    smali.add(')');
    smali.add(methodRef.getReturnType());
    AnnotationsAttr annotationsAttr = new AttributeStorage(mth.getAttributes()).get(JadxAttrType.ANNOTATION_LIST);
    if (annotationsAttr != null && !annotationsAttr.isEmpty()) {
        smali.incIndent();
        writeAnnotations(smali, annotationsAttr.getList());
        smali.decIndent();
        smali.startLine();
    }
}
Also used : AnnotationsAttr(jadx.api.plugins.input.data.attributes.types.AnnotationsAttr) AttributeStorage(jadx.core.dex.attributes.AttributeStorage) IMethodRef(jadx.api.plugins.input.data.IMethodRef)

Example 7 with IMethodRef

use of jadx.api.plugins.input.data.IMethodRef in project jadx by skylot.

the class Smali method method.

private static String method(InsnData insn) {
    Opcode op = insn.getOpcode();
    if (op == INVOKE_CUSTOM || op == INVOKE_CUSTOM_RANGE) {
        insn.getIndexAsCallSite().load();
        return String.format("%s # call_site@%04x", insn.getIndexAsCallSite().toString(), insn.getIndex());
    }
    IMethodRef mthRef = insn.getIndexAsMethod();
    mthRef.load();
    if (op == INVOKE_POLYMORPHIC || op == INVOKE_POLYMORPHIC_RANGE) {
        return String.format("%s, %s # method@%04x, proto@%04x", mthRef.toString(), insn.getIndexAsProto(insn.getTarget()).toString(), insn.getIndex(), insn.getTarget());
    }
    return String.format("%s # method@%04x", mthRef.toString(), insn.getIndex());
}
Also used : Opcode(jadx.api.plugins.input.insns.Opcode) IMethodRef(jadx.api.plugins.input.data.IMethodRef)

Example 8 with IMethodRef

use of jadx.api.plugins.input.data.IMethodRef in project jadx by skylot.

the class InsnDecoder method invoke.

private InsnNode invoke(InsnData insn, InvokeType type, boolean isRange) {
    IMethodRef mthRef = InsnDataUtils.getMethodRef(insn);
    if (mthRef == null) {
        throw new JadxRuntimeException("Failed to load method reference for insn: " + insn);
    }
    MethodInfo mthInfo = MethodInfo.fromRef(root, mthRef);
    return new InvokeNode(mthInfo, insn, type, isRange);
}
Also used : IMethodRef(jadx.api.plugins.input.data.IMethodRef) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) MethodInfo(jadx.core.dex.info.MethodInfo)

Aggregations

IMethodRef (jadx.api.plugins.input.data.IMethodRef)8 IMethodHandle (jadx.api.plugins.input.data.IMethodHandle)3 ICallSite (jadx.api.plugins.input.data.ICallSite)2 MethodInfo (jadx.core.dex.info.MethodInfo)2 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)2 IMethodProto (jadx.api.plugins.input.data.IMethodProto)1 AnnotationsAttr (jadx.api.plugins.input.data.attributes.types.AnnotationsAttr)1 Opcode (jadx.api.plugins.input.insns.Opcode)1 ICustomPayload (jadx.api.plugins.input.insns.custom.ICustomPayload)1 AttributeStorage (jadx.core.dex.attributes.AttributeStorage)1 ArgType (jadx.core.dex.instructions.args.ArgType)1 FieldNode (jadx.core.dex.nodes.FieldNode)1 MethodNode (jadx.core.dex.nodes.MethodNode)1 DataReader (jadx.plugins.input.java.data.DataReader)1 JavaInsnData (jadx.plugins.input.java.data.code.JavaInsnData)1