當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。