当前位置: 首页>>代码示例>>Java>>正文


Java MethodVisitor.visitLookupSwitchInsn方法代码示例

本文整理汇总了Java中org.objectweb.asm.MethodVisitor.visitLookupSwitchInsn方法的典型用法代码示例。如果您正苦于以下问题:Java MethodVisitor.visitLookupSwitchInsn方法的具体用法?Java MethodVisitor.visitLookupSwitchInsn怎么用?Java MethodVisitor.visitLookupSwitchInsn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.objectweb.asm.MethodVisitor的用法示例。


在下文中一共展示了MethodVisitor.visitLookupSwitchInsn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: accept

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void accept(final MethodVisitor mv) {
    int[] keys = new int[this.keys.size()];
    for (int i = 0; i < keys.length; ++i) {
        keys[i] = this.keys.get(i).intValue();
    }
    Label[] labels = new Label[this.labels.size()];
    for (int i = 0; i < labels.length; ++i) {
        labels[i] = this.labels.get(i).getLabel();
    }
    mv.visitLookupSwitchInsn(dflt.getLabel(), keys, labels);
    acceptAnnotations(mv);
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:14,代码来源:LookupSwitchInsnNode.java

示例2: findClass

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
    if (name.equals(NAME)) {
        ClassWriter cw = new ClassWriter(0);
        MethodVisitor mv;
        cw.visit(52, ACC_PUBLIC + ACC_SUPER, NAME, null, "java/lang/Object", null);

        mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, "run", "(I)J", null, null);
        mv.visitCode();
        Label begin = new Label();
        mv.visitLabel(begin);
        mv.visitVarInsn(ILOAD, 0);
        Label[] labels = new Label[numberBlocks];
        int[] keys = new int[numberBlocks];
        for (int i = 0; i < labels.length; i++) {
            labels[i] = new Label();
            keys[i] = i;
        }
        Label defaultLabel = new Label();
        mv.visitLookupSwitchInsn(defaultLabel, keys, labels);
        for (int i = 0; i < labels.length; i++) {
            mv.visitLabel(labels[i]);
            mv.visitFrame(Opcodes.F_NEW, 1, new Object[]{Opcodes.INTEGER}, 0, new Object[]{});
            mv.visitLdcInsn(new Long(LARGE_CONSTANT + i));
            mv.visitInsn(LRETURN);
        }
        mv.visitLabel(defaultLabel);
        mv.visitFrame(Opcodes.F_NEW, 1, new Object[]{Opcodes.INTEGER}, 0, new Object[]{});
        mv.visitLdcInsn(new Long(3L));
        mv.visitInsn(LRETURN);
        Label end = new Label();
        mv.visitLabel(end);
        mv.visitLocalVariable("a", "I", null, begin, end, 0);
        mv.visitMaxs(2, 1);
        mv.visitEnd();
        byte[] bytes = cw.toByteArray();
        return defineClass(name, bytes, 0, bytes.length);
    } else {
        return super.findClass(name);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:42,代码来源:LargeConstantSectionTest.java


注:本文中的org.objectweb.asm.MethodVisitor.visitLookupSwitchInsn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。