当前位置: 首页>>代码示例>>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;未经允许,请勿转载。