类org.objectweb.asm.commons.MethodRemapper源码实例Demo

下面列出了怎么用org.objectweb.asm.commons.MethodRemapper的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: glowroot   文件: WeavingClassVisitor.java
@RequiresNonNull("type")
private void addMixin(ClassNode mixinClassNode) {
    List<FieldNode> fieldNodes = mixinClassNode.fields;
    for (FieldNode fieldNode : fieldNodes) {
        if (!Modifier.isTransient(fieldNode.access)) {
            // this is needed to avoid serialization issues (even if the new field is
            // serializable, this can still cause issues in a cluster if glowroot is not
            // deployed on all nodes)
            throw new IllegalStateException(
                    "@Mixin fields must be marked transient: " + mixinClassNode.name);
        }
        fieldNode.accept(this);
    }
    List<MethodNode> methodNodes = mixinClassNode.methods;
    for (MethodNode mn : methodNodes) {
        if (mn.name.equals("<init>")) {
            continue;
        }
        String[] exceptions = Iterables.toArray(mn.exceptions, String.class);
        MethodVisitor mv =
                cw.visitMethod(mn.access, mn.name, mn.desc, mn.signature, exceptions);
        mn.accept(new MethodRemapper(mv,
                new SimpleRemapper(mixinClassNode.name, type.getInternalName())));
    }
}
 
 类所在包
 类方法
 同包方法