當前位置: 首頁>>代碼示例>>Java>>正文


Java AsmUtils類代碼示例

本文整理匯總了Java中com.android.utils.AsmUtils的典型用法代碼示例。如果您正苦於以下問題:Java AsmUtils類的具體用法?Java AsmUtils怎麽用?Java AsmUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AsmUtils類屬於com.android.utils包,在下文中一共展示了AsmUtils類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addAllNewConstructors

import com.android.utils.AsmUtils; //導入依賴的package包/類
/**
 * Add all constructors from the passed ClassNode's methods. {@see ClassNode#methods}
 *
 * @param methods                 the constructors already encountered in the ClassNode hierarchy
 * @param classNode               the class to save all new methods from.
 * @param keepPrivateConstructors whether to keep the private constructors.
 */
private void addAllNewConstructors(Map<String, MethodNode> methods, ClassNode classNode,
                                   boolean keepPrivateConstructors) {
    //noinspection unchecked
    for (MethodNode method : (List<MethodNode>) classNode.methods) {
        if (!method.name.equals(AsmUtils.CONSTRUCTOR)) {
            continue;
        }

        if (!isAccessCompatibleWithInstantRun(method.access)) {
            continue;
        }

        if (!keepPrivateConstructors && (method.access & Opcodes.ACC_PRIVATE) != 0) {
            continue;
        }
        if (!classNode.name.equals(visitedClassName)
                && !classNode.name.equals(visitedSuperName)) {
            continue;
        }
        String key = classNode.name + "." + method.desc;
        if (methods.containsKey(key)) {
            continue;
        }
        methods.put(key, method);
    }
}
 
開發者ID:dodola,項目名稱:AnoleFix,代碼行數:34,代碼來源:IncrementalSupportVisitor.java

示例2: visitMethod

import com.android.utils.AsmUtils; //導入依賴的package包/類
/**
 * Insert Constructor specific logic({@link ConstructorArgsRedirection} and
 * {@link ConstructorDelegationDetector}) for constructor redirecting or
 * normal method redirecting ({@link MethodRedirection}) for other methods.
 */
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature,
                                 String[] exceptions) {

    access = transformAccessForInstantRun(access);

    MethodVisitor defaultVisitor = super.visitMethod(access, name, desc, signature, exceptions);
    MethodNode method = getMethodByNameInClass(name, desc, classNode);
    // does the method use blacklisted APIs.
    boolean hasIncompatibleChange = InstantRunMethodVerifier.verifyMethod(method)
            != InstantRunVerifierStatus.COMPATIBLE;

    if (hasIncompatibleChange || disableRedirectionForClass
            || !isAccessCompatibleWithInstantRun(access)
            || name.equals(AsmUtils.CLASS_INITIALIZER)) {
        return defaultVisitor;
    } else {
        ISMethodVisitor mv = new ISMethodVisitor(defaultVisitor, access, name, desc);
        if (name.equals(AsmUtils.CONSTRUCTOR)) {

            ConstructorDelegationDetector.Constructor constructor =
                    ConstructorDelegationDetector.deconstruct(visitedClassName, method);
            LabelNode start = new LabelNode();
            LabelNode after = new LabelNode();
            method.instructions.insert(constructor.loadThis, start);
            if (constructor.lineForLoad != -1) {
                // Record the line number from the start of LOAD_0 for uninitialized 'this'.
                // This allows a breakpoint to be set at the line with this(...) or super(...)
                // call in the constructor.
                method.instructions.insert(constructor.loadThis,
                        new LineNumberNode(constructor.lineForLoad, start));
            }
            method.instructions.insert(constructor.delegation, after);
            mv.addRedirection(
                    new ConstructorArgsRedirection(
                            start,
                            visitedClassName,
                            constructor.args.name + "." + constructor.args.desc,
                            after,
                            Type.getArgumentTypes(constructor.delegation.desc)));

            mv.addRedirection(new MethodRedirection(after, constructor.body.name + "."
                    + constructor.body.desc, Type.getReturnType(desc)));
        } else {
            mv.addRedirection(new MethodRedirection(
                    new LabelNode(mv.getStartLabel()),
                    name + "." + desc,
                    Type.getReturnType(desc)));
        }
        method.accept(mv);
        return null;
    }
}
 
開發者ID:dodola,項目名稱:AnoleFix,代碼行數:59,代碼來源:IncrementalSupportVisitor.java


注:本文中的com.android.utils.AsmUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。