Package org.objectweb.asm

Examples of org.objectweb.asm.MethodVisitor.visitLookupSwitchInsn()


            CachedMethod method = (CachedMethod) methods.get(i);
            method.setMethodIndex(indices[i] = i+1);
        }

        // do switch
        mv.visitLookupSwitchInsn(defaultLabel, indices, labels);
        // create switch cases
        for (int i = 0; i < methodCount; i++) {
            // call helper for invocation
            mv.visitLabel(labels[i]);
            mv.visitMethodInsn(
View Full Code Here


    public void testIllegalLookupSwitchParameters1() {
        MethodVisitor mv = new CheckMethodAdapter(new EmptyVisitor());
        mv.visitCode();
        try {
            mv.visitLookupSwitchInsn(new Label(), null, new Label[0]);
            fail();
        } catch (Exception e) {
        }
    }
View Full Code Here

    public void testIllegalLookupSwitchParameters2() {
        MethodVisitor mv = new CheckMethodAdapter(new EmptyVisitor());
        mv.visitCode();
        try {
            mv.visitLookupSwitchInsn(new Label(), new int[0], null);
            fail();
        } catch (Exception e) {
        }
    }
View Full Code Here

    public void testIllegalLookupSwitchParameters3() {
        MethodVisitor mv = new CheckMethodAdapter(new EmptyVisitor());
        mv.visitCode();
        try {
            mv.visitLookupSwitchInsn(new Label(), new int[0], new Label[1]);
            fail();
        } catch (Exception e) {
        }
    }
View Full Code Here

        // lookupswitch
        Label l4 = new Label();
        Label l5 = new Label();
        Label l6 = new Label();
        mv.visitVarInsn(ILOAD, 1);
        mv.visitLookupSwitchInsn(l6, new int[] { 0, 1, 2 }, new Label[] {
            l4,
            l5,
            l6 });
        mv.visitLabel(l4);
        mv.visitInsn(ICONST_1);
View Full Code Here

            CachedMethod method = (CachedMethod) methods.get(i);
            method.setMethodIndex(indices[i] = i+1);
        }

        // do switch
        mv.visitLookupSwitchInsn(defaultLabel, indices, labels);
        // create switch cases
        for (int i = 0; i < methodCount; i++) {
            // call helper for invocation
            mv.visitLabel(labels[i]);
            mv.visitMethodInsn(
View Full Code Here

                    labels[index] = entry.getValue();
                    index++;
                }

                // Visit the lookup switch instruction.
                mv.visitLookupSwitchInsn(defaultLabel, caseMatches, labels);

            } else {
                // A table switch
                // The cases which aren't given should be set to the default case.
View Full Code Here

    MethodVisitor mv = cv.visitMethod(0, "foo", "()V", null, null);
    mv.visitCode();
    mv.visitInsn(Opcodes.ICONST_0);
    Label l1 = new Label();
    Label l2 = new Label();
    mv.visitLookupSwitchInsn(l1, new int[] { 0 }, new Label[] { l2 });
    mv.visitLabel(l1);
    mv.visitInsn(Opcodes.NOP);
    mv.visitLabel(l2);
    mv.visitInsn(Opcodes.RETURN);
    mv.visitMaxs(1, 1);
View Full Code Here

        }

        // create switch targets
        Label defaultLabel = new Label();
        Label afterSwitch = new Label();
        mv.visitLookupSwitchInsn(defaultLabel, indices, targets);
        for (int i = 0; i < targets.length; i++) {
            mv.visitLabel(targets[i]);
            // to keep the stack height, we need to leave
            // one Object[] on the stack as last element. At the
            // same time, we need the Object[] on top of the stack
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.