Search in sources :

Example 1 with SkipMethodArgsAttr

use of jadx.core.dex.attributes.nodes.SkipMethodArgsAttr in project jadx by skylot.

the class ModVisitor method processAnonymousConstructor.

/**
 * For args in anonymous constructor invoke apply:
 * - forbid inline into constructor call
 * - make variables final (compiler require this implicitly)
 */
private static void processAnonymousConstructor(MethodNode mth, ConstructorInsn co) {
    IMethodDetails callMthDetails = mth.root().getMethodUtils().getMethodDetails(co);
    if (!(callMthDetails instanceof MethodNode)) {
        return;
    }
    MethodNode callMth = (MethodNode) callMthDetails;
    if (!callMth.contains(AFlag.ANONYMOUS_CONSTRUCTOR) || callMth.contains(AFlag.NO_SKIP_ARGS)) {
        return;
    }
    SkipMethodArgsAttr attr = callMth.get(AType.SKIP_MTH_ARGS);
    if (attr != null) {
        int argsCount = Math.min(callMth.getMethodInfo().getArgsCount(), co.getArgsCount());
        for (int i = 0; i < argsCount; i++) {
            if (attr.isSkip(i)) {
                anonymousCallArgMod(co.getArg(i));
            }
        }
    } else {
        // additional info not available apply mods to all args (the safest solution)
        co.getArguments().forEach(ModVisitor::anonymousCallArgMod);
    }
}
Also used : MethodNode(jadx.core.dex.nodes.MethodNode) SkipMethodArgsAttr(jadx.core.dex.attributes.nodes.SkipMethodArgsAttr) IMethodDetails(jadx.core.dex.nodes.IMethodDetails)

Aggregations

SkipMethodArgsAttr (jadx.core.dex.attributes.nodes.SkipMethodArgsAttr)1 IMethodDetails (jadx.core.dex.nodes.IMethodDetails)1 MethodNode (jadx.core.dex.nodes.MethodNode)1