Example usage for org.objectweb.asm MethodVisitor visitLineNumber

List of usage examples for org.objectweb.asm MethodVisitor visitLineNumber

Introduction

In this page you can find the example usage for org.objectweb.asm MethodVisitor visitLineNumber.

Prototype

public void visitLineNumber(final int line, final Label start) 

Source Link

Document

Visits a line number declaration.

Usage

From source file:org.simantics.databoard.tests.testASM.java

License:Open Source License

public static byte[] dump() throws Exception {
    ClassWriter cw = new ClassWriter(0);
    FieldVisitor fv;//from ww w. j a  v  a2s .co m
    MethodVisitor mv;
    AnnotationVisitor av0;

    cw.visit(V1_6, ACC_SUPER, "org/simantics/data/Virhe", null, "java/lang/Object", null);

    cw.visitSource("testASM.java", null);

    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(157, l0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
        mv.visitInsn(RETURN);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLocalVariable("this", "Lorg/simantics/data/Virhe;", null, l0, l1, 0);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    cw.visitEnd();

    return cw.toByteArray();
}

From source file:org.spongepowered.common.event.ClassEventListenerFactory.java

License:MIT License

private static byte[] generateClass(String name, Class<?> handle, Method method, Class<?> eventClass,
        Class<? extends EventFilter> filter) {
    name = name.replace('.', '/');
    final String handleName = Type.getInternalName(handle);
    final String handleDescriptor = Type.getDescriptor(handle);
    final String filterName = Type.getInternalName(filter);
    String eventDescriptor = "(";
    for (int i = 0; i < method.getParameterCount(); i++) {
        eventDescriptor += Type.getDescriptor(method.getParameterTypes()[i]);
    }//from   www  .  j  av  a 2  s. c  om
    eventDescriptor += ")V";

    ClassWriter cw = new ClassWriter(0);
    MethodVisitor mv;
    FieldVisitor fv;

    cw.visit(V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, name, null, BASE_HANDLER, null);
    {
        fv = cw.visitField(ACC_PRIVATE + ACC_STATIC, "FILTER", "L" + filterName + ";", null, null);
        fv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_STATIC, "<clinit>", "()V", null, null);
        mv.visitCode();
        Label l0 = new Label();
        Label l1 = new Label();
        Label l2 = new Label();
        mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Exception");
        mv.visitLabel(l0);
        mv.visitLdcInsn(Type.getType(filter));
        mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Class", "newInstance", "()Ljava/lang/Object;", false);
        mv.visitTypeInsn(CHECKCAST, filterName);
        mv.visitFieldInsn(PUTSTATIC, name, "FILTER", "L" + filterName + ";");
        mv.visitLabel(l1);
        Label l3 = new Label();
        mv.visitJumpInsn(GOTO, l3);
        mv.visitLabel(l2);
        mv.visitFrame(F_SAME1, 0, null, 1, new Object[] { "java/lang/Exception" });
        mv.visitVarInsn(ASTORE, 0);
        mv.visitMethodInsn(INVOKESTATIC, Type.getInternalName(SpongeImpl.class), "getLogger",
                "()" + Type.getDescriptor(Logger.class), false);
        mv.visitLdcInsn("Error initializing event filter");
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Logger.class), "error",
                "(Ljava/lang/String;Ljava/lang/Throwable;)V", true);
        Label l5 = new Label();
        mv.visitLabel(l5);
        mv.visitLineNumber(220, l5);
        mv.visitInsn(ACONST_NULL);
        mv.visitFieldInsn(PUTSTATIC, name, "FILTER", "L" + filterName + ";");
        mv.visitLabel(l3);
        mv.visitFrame(F_SAME, 0, null, 0, null);
        mv.visitInsn(RETURN);
        mv.visitMaxs(3, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", '(' + handleDescriptor + ")V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitVarInsn(ALOAD, 1);
        mv.visitMethodInsn(INVOKESPECIAL, BASE_HANDLER, "<init>", "(Ljava/lang/Object;)V", false);
        mv.visitInsn(RETURN);
        mv.visitMaxs(2, 2);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PUBLIC, "handle", HANDLE_METHOD_DESCRIPTOR, null,
                new String[] { "java/lang/Exception" });
        mv.visitCode();
        mv.visitFieldInsn(GETSTATIC, name, "FILTER", "L" + filterName + ";");
        mv.visitVarInsn(ALOAD, 1);
        mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(EventFilter.class), "filter",
                FILTER_DESCRIPTOR, true);
        mv.visitVarInsn(ASTORE, 2);
        mv.visitVarInsn(ALOAD, 2);
        Label l2 = new Label();
        mv.visitJumpInsn(IFNULL, l2);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitFieldInsn(GETFIELD, name, "handle", "Ljava/lang/Object;");
        mv.visitTypeInsn(CHECKCAST, handleName);
        for (int i = 0; i < method.getParameterCount(); i++) {
            mv.visitVarInsn(ALOAD, 2);
            mv.visitIntInsn(BIPUSH, i);
            mv.visitInsn(AALOAD);
            mv.visitTypeInsn(CHECKCAST, Type.getInternalName(method.getParameterTypes()[i]));
        }
        mv.visitMethodInsn(INVOKEVIRTUAL, handleName, method.getName(), eventDescriptor, false);
        mv.visitLabel(l2);
        mv.visitFrame(F_APPEND, 1, new Object[] { "[Ljava/lang/Object;" }, 0, null);
        mv.visitInsn(RETURN);
        mv.visitMaxs(4, 3);
        mv.visitEnd();
    }
    cw.visitEnd();

    return cw.toByteArray();
}

From source file:org.spongepowered.test.decompile.SwitchTests.java

License:Open Source License

private static void generateSwitchSyntheticEclipse(ClassWriter cw) {

    MethodVisitor mv = cw.visitMethod(ACC_STATIC + ACC_SYNTHETIC,
            "$SWITCH_TABLE$org$spongepowered$test$decompile$SwitchTests$TestEnum", "()[I", null, null);
    mv.visitCode();//  w  w  w.java 2 s. c om
    Label l0 = new Label();
    Label l1 = new Label();
    Label l2 = new Label();
    mv.visitTryCatchBlock(l0, l1, l2, "java/lang/NoSuchFieldError");
    Label l3 = new Label();
    Label l4 = new Label();
    Label l5 = new Label();
    mv.visitTryCatchBlock(l3, l4, l5, "java/lang/NoSuchFieldError");
    Label l6 = new Label();
    Label l7 = new Label();
    Label l8 = new Label();
    mv.visitTryCatchBlock(l6, l7, l8, "java/lang/NoSuchFieldError");
    Label l9 = new Label();
    Label l10 = new Label();
    Label l11 = new Label();
    mv.visitTryCatchBlock(l9, l10, l11, "java/lang/NoSuchFieldError");
    Label l12 = new Label();
    Label l13 = new Label();
    Label l14 = new Label();
    mv.visitTryCatchBlock(l12, l13, l14, "java/lang/NoSuchFieldError");
    Label l15 = new Label();
    Label l16 = new Label();
    Label l17 = new Label();
    mv.visitTryCatchBlock(l15, l16, l17, "java/lang/NoSuchFieldError");
    Label l18 = new Label();
    Label l19 = new Label();
    Label l20 = new Label();
    mv.visitTryCatchBlock(l18, l19, l20, "java/lang/NoSuchFieldError");
    Label l21 = new Label();
    Label l22 = new Label();
    Label l23 = new Label();
    mv.visitTryCatchBlock(l21, l22, l23, "java/lang/NoSuchFieldError");
    Label l24 = new Label();
    Label l25 = new Label();
    Label l26 = new Label();
    mv.visitTryCatchBlock(l24, l25, l26, "java/lang/NoSuchFieldError");
    Label l27 = new Label();
    Label l28 = new Label();
    Label l29 = new Label();
    mv.visitTryCatchBlock(l27, l28, l29, "java/lang/NoSuchFieldError");
    Label l30 = new Label();
    mv.visitLabel(l30);
    mv.visitLineNumber(28, l30);
    mv.visitFieldInsn(GETSTATIC, "org/spongepowered/test/decompile/SwitchTests",
            "$SWITCH_TABLE$org$spongepowered$test$decompile$SwitchTests$TestEnum", "[I");
    Label l31 = new Label();
    mv.visitJumpInsn(IFNULL, l31);
    mv.visitFieldInsn(GETSTATIC, "org/spongepowered/test/decompile/SwitchTests",
            "$SWITCH_TABLE$org$spongepowered$test$decompile$SwitchTests$TestEnum", "[I");
    mv.visitInsn(ARETURN);
    mv.visitLabel(l31);
    mv.visitMethodInsn(INVOKESTATIC, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "values",
            "()[Lorg/spongepowered/test/decompile/SwitchTests$TestEnum;", false);
    mv.visitInsn(ARRAYLENGTH);
    mv.visitIntInsn(NEWARRAY, T_INT);
    mv.visitVarInsn(ASTORE, 0);
    mv.visitLabel(l0);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETSTATIC, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "EIGHT",
            "Lorg/spongepowered/test/decompile/SwitchTests$TestEnum;");
    mv.visitMethodInsn(INVOKEVIRTUAL, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "ordinal", "()I",
            false);
    mv.visitIntInsn(BIPUSH, 8);
    mv.visitInsn(IASTORE);
    mv.visitLabel(l1);
    mv.visitJumpInsn(GOTO, l3);
    mv.visitLabel(l2);
    mv.visitInsn(POP);
    mv.visitLabel(l3);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETSTATIC, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "FIVE",
            "Lorg/spongepowered/test/decompile/SwitchTests$TestEnum;");
    mv.visitMethodInsn(INVOKEVIRTUAL, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "ordinal", "()I",
            false);
    mv.visitInsn(ICONST_5);
    mv.visitInsn(IASTORE);
    mv.visitLabel(l4);
    mv.visitJumpInsn(GOTO, l6);
    mv.visitLabel(l5);
    mv.visitInsn(POP);
    mv.visitLabel(l6);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETSTATIC, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "FOUR",
            "Lorg/spongepowered/test/decompile/SwitchTests$TestEnum;");
    mv.visitMethodInsn(INVOKEVIRTUAL, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "ordinal", "()I",
            false);
    mv.visitInsn(ICONST_4);
    mv.visitInsn(IASTORE);
    mv.visitLabel(l7);
    mv.visitJumpInsn(GOTO, l9);
    mv.visitLabel(l8);
    mv.visitInsn(POP);
    mv.visitLabel(l9);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETSTATIC, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "NINE",
            "Lorg/spongepowered/test/decompile/SwitchTests$TestEnum;");
    mv.visitMethodInsn(INVOKEVIRTUAL, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "ordinal", "()I",
            false);
    mv.visitIntInsn(BIPUSH, 9);
    mv.visitInsn(IASTORE);
    mv.visitLabel(l10);
    mv.visitJumpInsn(GOTO, l12);
    mv.visitLabel(l11);
    mv.visitInsn(POP);
    mv.visitLabel(l12);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETSTATIC, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "ONE",
            "Lorg/spongepowered/test/decompile/SwitchTests$TestEnum;");
    mv.visitMethodInsn(INVOKEVIRTUAL, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "ordinal", "()I",
            false);
    mv.visitInsn(ICONST_1);
    mv.visitInsn(IASTORE);
    mv.visitLabel(l13);
    mv.visitJumpInsn(GOTO, l15);
    mv.visitLabel(l14);
    mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] { "java/lang/NoSuchFieldError" });
    mv.visitInsn(POP);
    mv.visitLabel(l15);
    mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETSTATIC, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "SEVEN",
            "Lorg/spongepowered/test/decompile/SwitchTests$TestEnum;");
    mv.visitMethodInsn(INVOKEVIRTUAL, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "ordinal", "()I",
            false);
    mv.visitIntInsn(BIPUSH, 7);
    mv.visitInsn(IASTORE);
    mv.visitLabel(l16);
    mv.visitJumpInsn(GOTO, l18);
    mv.visitLabel(l17);
    mv.visitInsn(POP);
    mv.visitLabel(l18);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETSTATIC, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "SIX",
            "Lorg/spongepowered/test/decompile/SwitchTests$TestEnum;");
    mv.visitMethodInsn(INVOKEVIRTUAL, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "ordinal", "()I",
            false);
    mv.visitIntInsn(BIPUSH, 6);
    mv.visitInsn(IASTORE);
    mv.visitLabel(l19);
    mv.visitJumpInsn(GOTO, l21);
    mv.visitLabel(l20);
    mv.visitInsn(POP);
    mv.visitLabel(l21);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETSTATIC, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "TEN",
            "Lorg/spongepowered/test/decompile/SwitchTests$TestEnum;");
    mv.visitMethodInsn(INVOKEVIRTUAL, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "ordinal", "()I",
            false);
    mv.visitIntInsn(BIPUSH, 10);
    mv.visitInsn(IASTORE);
    mv.visitLabel(l22);
    mv.visitJumpInsn(GOTO, l24);
    mv.visitLabel(l23);
    mv.visitInsn(POP);
    mv.visitLabel(l24);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETSTATIC, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "THREE",
            "Lorg/spongepowered/test/decompile/SwitchTests$TestEnum;");
    mv.visitMethodInsn(INVOKEVIRTUAL, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "ordinal", "()I",
            false);
    mv.visitInsn(ICONST_3);
    mv.visitInsn(IASTORE);
    mv.visitLabel(l25);
    mv.visitJumpInsn(GOTO, l27);
    mv.visitLabel(l26);
    mv.visitInsn(POP);
    mv.visitLabel(l27);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETSTATIC, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "TWO",
            "Lorg/spongepowered/test/decompile/SwitchTests$TestEnum;");
    mv.visitMethodInsn(INVOKEVIRTUAL, "org/spongepowered/test/decompile/SwitchTests$TestEnum", "ordinal", "()I",
            false);
    mv.visitInsn(ICONST_2);
    mv.visitInsn(IASTORE);
    mv.visitLabel(l28);
    Label l32 = new Label();
    mv.visitJumpInsn(GOTO, l32);
    mv.visitLabel(l29);
    mv.visitInsn(POP);
    mv.visitLabel(l32);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitInsn(DUP);
    mv.visitFieldInsn(PUTSTATIC, "org/spongepowered/test/decompile/SwitchTests",
            "$SWITCH_TABLE$org$spongepowered$test$decompile$SwitchTests$TestEnum", "[I");
    mv.visitInsn(ARETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}

From source file:org.springframework.migrationanalyzer.contributions.bytecode.DelegatingMethodVisitor.java

License:Apache License

@Override
public void visitLineNumber(int line, Label start) {
    for (MethodVisitor delegate : this.delegates) {
        delegate.visitLineNumber(line, start);
    }/*from w ww . java2 s. c  o m*/
}

From source file:org.wildfly.swarm.jaxrs.internal.ApplicationFactory.java

License:Apache License

public static byte[] create(String name, String context) {

    ClassWriter cw = new ClassWriter(0);
    MethodVisitor mv;
    AnnotationVisitor av0;//from ww w  .  j  ava2 s . c o m

    cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, name.replace('.', '/'), null, "javax/ws/rs/core/Application", null);

    int lastDot = name.lastIndexOf('.');
    String simpleName = name.substring(lastDot + 1);
    cw.visitSource(simpleName + ".java", null);

    {
        av0 = cw.visitAnnotation("Ljavax/ws/rs/ApplicationPath;", true);
        av0.visit("value", "/");
        av0.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(10, l0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, "javax/ws/rs/core/Application", "<init>", "()V", false);
        mv.visitInsn(RETURN);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLocalVariable("this", "L" + name.replace('.', '/') + ";", null, l0, l1, 0);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    cw.visitEnd();

    return cw.toByteArray();
}

From source file:org.wildfly.swarm.jaxrs.runtime.DefaultApplicationFactory.java

License:Apache License

static byte[] basicClassBytes() {
    ClassWriter cw = new ClassWriter(0);
    MethodVisitor mv;

    cw.visit(52, ACC_PUBLIC + ACC_SUPER, "org/wildfly/swarm/jaxrs/runtime/DefaultApplication", null,
            "javax/ws/rs/core/Application", null);

    cw.visitSource("DefaultApplication.java", null);
    {/*from  w ww.  j  a va2  s  .  c  o  m*/
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(23, l0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, "javax/ws/rs/core/Application", "<init>", "()V", false);
        mv.visitInsn(RETURN);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLocalVariable("this", "Lorg/wildfly/swarm/jaxrs/runtime/DefaultApplication;", null, l0, l1, 0);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    cw.visitEnd();

    return cw.toByteArray();

}

From source file:st.redline.compiler.ByteCodeEmitter.java

License:Open Source License

private void makeJavaClassInitializer() {
    MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    mv.visitCode();/*from  w ww. ja  v  a2s.  c o m*/

    Label l0 = new Label();
    mv.visitLabel(l0);
    mv.visitLineNumber(1, l0);

    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKESPECIAL, superclassName(), "<init>", "()V", false);

    mv.visitInsn(RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}

From source file:st.redline.compiler.ByteCodeEmitter.java

License:Open Source License

private void visitLine(MethodVisitor mv, int line) {
    // We adjust the line number as the pre-processor may have prepended source lines.
    int adjustedSourceLine = line - source.countOfLinesAddedByPreprocessor();
    Label l0 = new Label();
    mv.visitLabel(l0);//www. j  a v  a2s.c o  m
    mv.visitLineNumber(adjustedSourceLine, l0);
}

From source file:st.redline.compiler.SmalltalkGeneratingVisitor.java

License:Open Source License

public void visitLine(MethodVisitor mv, int line) {
    Label l0 = new Label();
    mv.visitLabel(l0);//from w ww  . j  a v a  2s.c o m
    mv.visitLineNumber(line, l0);
}

From source file:vanilla.java.collections.impl.GenerateHugeArrays.java

License:Apache License

public static byte[] dumpArrayList(TypeModel tm) {
    ClassWriter cw = new ClassWriter(0);
    FieldVisitor fv;// www  .  j  a v  a 2 s  . c  o m
    MethodVisitor mv;

    Class interfaceClass = tm.type();
    String name = interfaceClass.getName().replace('.', '/');

    cw.visit(
            V1_5, ACC_PUBLIC + ACC_SUPER, name + "ArrayList", "L" + collections + "impl/AbstractHugeArrayList<L"
                    + name + ";L" + name + "Allocation;L" + name + "Element;>;",
            collections + "impl/AbstractHugeArrayList", null);

    cw.visitSource(tm.type().getSimpleName() + "ArrayList.java", null);

    for (FieldModel fm : tm.fields()) {
        if (fm instanceof Enum8FieldModel) {
            fv = cw.visitField(ACC_FINAL, fm.fieldName() + "FieldModel",
                    "L" + collections + "model/Enum8FieldModel;",
                    "L" + collections + "model/Enum8FieldModel<Ljava/lang/annotation/ElementType;>;", null);
            fv.visitEnd();
        } else if (fm instanceof Enumerated16FieldModel) {
            fv = cw.visitField(ACC_FINAL, fm.fieldName() + "FieldModel",
                    "L" + collections + "model/Enumerated16FieldModel;",
                    "L" + collections + "model/Enumerated16FieldModel<Ljava/lang/String;>;", null);
            fv.visitEnd();
        }
    }
    List<FieldModel> fields = new ArrayList<FieldModel>();
    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(L" + collections + "HugeArrayBuilder;)V", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(35, l0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitVarInsn(ALOAD, 1);
        mv.visitMethodInsn(INVOKESPECIAL, collections + "impl/AbstractHugeArrayList", "<init>",
                "(L" + collections + "HugeArrayBuilder;)V");
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLineNumber(29, l1);

        for (FieldModel fm : tm.fields()) {
            if (fm instanceof Enum8FieldModel) {
                mv.visitVarInsn(ALOAD, 0);
                mv.visitTypeInsn(NEW, fm.bcModelType());
                mv.visitInsn(DUP);
                mv.visitLdcInsn(fm.fieldName());
                mv.visitIntInsn(BIPUSH, fm.fieldNumber());
                mv.visitLdcInsn(Type.getType(fm.bcLFieldType()));
                mv.visitMethodInsn(INVOKESTATIC, fm.bcFieldType(), "values", "()[" + fm.bcLFieldType());
                mv.visitMethodInsn(INVOKESPECIAL, fm.bcModelType(), "<init>",
                        "(Ljava/lang/String;ILjava/lang/Class;[Ljava/lang/Enum;)V");
                mv.visitFieldInsn(PUTFIELD, name + "ArrayList", fm.fieldName() + "FieldModel",
                        fm.bcLModelType());
                mv.visitVarInsn(ALOAD, 0);
                mv.visitFieldInsn(GETFIELD, name + "ArrayList", fm.fieldName() + "FieldModel",
                        fm.bcLModelType());
                mv.visitVarInsn(ALOAD, 1);
                mv.visitMethodInsn(INVOKEVIRTUAL, collections + "HugeArrayBuilder", "baseDirectory",
                        "()Ljava/lang/String;");
                mv.visitMethodInsn(INVOKEVIRTUAL, fm.bcModelType(), "baseDirectory", "(Ljava/lang/String;)V");
                fields.add(fm);

            } else if (fm instanceof Enumerated16FieldModel) {
                mv.visitVarInsn(ALOAD, 0);
                mv.visitTypeInsn(NEW, fm.bcModelType());
                mv.visitInsn(DUP);
                mv.visitLdcInsn(fm.fieldName());
                mv.visitIntInsn(BIPUSH, fm.fieldNumber());
                mv.visitLdcInsn(Type.getType(fm.bcLFieldType()));
                mv.visitMethodInsn(INVOKESPECIAL, fm.bcModelType(), "<init>",
                        "(Ljava/lang/String;ILjava/lang/Class;)V");
                mv.visitFieldInsn(PUTFIELD, name + "ArrayList", fm.fieldName() + "FieldModel",
                        fm.bcLModelType());
                mv.visitVarInsn(ALOAD, 0);
                mv.visitFieldInsn(GETFIELD, name + "ArrayList", fm.fieldName() + "FieldModel",
                        fm.bcLModelType());
                mv.visitVarInsn(ALOAD, 1);
                mv.visitMethodInsn(INVOKEVIRTUAL, collections + "HugeArrayBuilder", "baseDirectory",
                        "()Ljava/lang/String;");
                mv.visitMethodInsn(INVOKEVIRTUAL, fm.bcModelType(), "baseDirectory", "(Ljava/lang/String;)V");
                fields.add(fm);
            }
        }

        mv.visitInsn(RETURN);
        Label l4 = new Label();
        mv.visitLabel(l4);
        mv.visitLocalVariable("this", "L" + name + "ArrayList;", null, l0, l4, 0);
        mv.visitLocalVariable("hab", "L" + collections + "HugeArrayBuilder;", null, l0, l4, 1);
        mv.visitMaxs(7, 2);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PROTECTED, "createAllocation",
                "(L" + collections + "impl/MappedFileChannel;)L" + name + "Allocation;", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(43, l0);
        mv.visitTypeInsn(NEW, name + "Allocation");
        mv.visitInsn(DUP);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitFieldInsn(GETFIELD, name + "ArrayList", "allocationSize", "I");
        mv.visitVarInsn(ALOAD, 1);
        mv.visitMethodInsn(INVOKESPECIAL, name + "Allocation", "<init>",
                "(IL" + collections + "impl/MappedFileChannel;)V");
        mv.visitInsn(ARETURN);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLocalVariable("this", "L" + name + "ArrayList;", null, l0, l1, 0);
        mv.visitLocalVariable("mfc", "L" + collections + "impl/MappedFileChannel;", null, l0, l1, 1);
        mv.visitMaxs(4, 2);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PROTECTED, "createElement", "(J)L" + name + "Element;", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(48, l0);
        mv.visitTypeInsn(NEW, name + "Element");
        mv.visitInsn(DUP);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitVarInsn(LLOAD, 1);
        mv.visitMethodInsn(INVOKESPECIAL, name + "Element", "<init>",
                "(L" + collections + "impl/AbstractHugeArrayList;J)V");
        mv.visitInsn(ARETURN);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLocalVariable("this", "L" + name + "ArrayList;", null, l0, l1, 0);
        mv.visitLocalVariable("n", "J", null, l0, l1, 1);
        mv.visitMaxs(5, 3);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PROTECTED, "createImpl", "()L" + name + ";", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(53, l0);
        mv.visitTypeInsn(NEW, name + "Impl");
        mv.visitInsn(DUP);
        mv.visitMethodInsn(INVOKESPECIAL, name + "Impl", "<init>", "()V");
        mv.visitInsn(ARETURN);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLocalVariable("this", "L" + name + "ArrayList;", null, l0, l1, 0);
        mv.visitMaxs(2, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PROTECTED, "compactStart", "()V", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(57, l0);
        for (FieldModel fm : fields) {
            mv.visitVarInsn(ALOAD, 0);
            mv.visitFieldInsn(GETFIELD, name + "ArrayList", fm.fieldName() + "FieldModel", fm.bcLModelType());
            mv.visitMethodInsn(INVOKEVIRTUAL, fm.bcModelType(), "compactStart", "()V");
        }
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLineNumber(58, l1);
        mv.visitInsn(RETURN);
        Label l2 = new Label();
        mv.visitLabel(l2);
        mv.visitLocalVariable("this", "L" + name + "ArrayList;", null, l0, l2, 0);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PROTECTED, "compactOnAllocation", "(L" + name + "Allocation;J)V", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(65, l0);
        for (FieldModel fm : fields) {
            mv.visitVarInsn(ALOAD, 0);
            mv.visitFieldInsn(GETFIELD, name + "ArrayList", fm.fieldName() + "FieldModel", fm.bcLModelType());
            mv.visitVarInsn(ALOAD, 1);
            mv.visitFieldInsn(GETFIELD, name + "Allocation", "m_string", fm.bcLStoreType());
            mv.visitVarInsn(LLOAD, 2);
            mv.visitMethodInsn(INVOKEVIRTUAL, fm.bcModelType(), "compactScan", "(" + fm.bcLStoreType() + "J)V");
        }
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLineNumber(66, l1);
        mv.visitInsn(RETURN);
        Label l2 = new Label();
        mv.visitLabel(l2);
        mv.visitLocalVariable("this", "L" + name + "ArrayList;", null, l0, l2, 0);
        mv.visitLocalVariable("allocation", "L" + name + "Allocation;", null, l0, l2, 1);
        mv.visitLocalVariable("thisSize", "J", null, l0, l2, 2);
        mv.visitMaxs(4, 4);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PROTECTED, "compactEnd", "()V", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(69, l0);
        for (FieldModel fm : fields) {
            mv.visitVarInsn(ALOAD, 0);
            mv.visitFieldInsn(GETFIELD, name + "ArrayList", fm.fieldName() + "FieldModel", fm.bcLModelType());
            mv.visitMethodInsn(INVOKEVIRTUAL, fm.bcModelType(), "compactEnd", "()V");
        }
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLineNumber(70, l1);
        mv.visitInsn(RETURN);
        Label l2 = new Label();
        mv.visitLabel(l2);
        mv.visitLocalVariable("this", "L" + name + "ArrayList;", null, l0, l2, 0);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PUBLIC, "clear", "()V", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(74, l0);
        for (FieldModel fm : fields) {
            mv.visitVarInsn(ALOAD, 0);
            mv.visitFieldInsn(GETFIELD, name + "ArrayList", fm.fieldName() + "FieldModel", fm.bcLModelType());
            mv.visitMethodInsn(INVOKEVIRTUAL, fm.bcModelType(), "clear", "()V");
        }
        Label l3 = new Label();
        mv.visitLabel(l3);
        mv.visitLineNumber(77, l3);
        mv.visitInsn(RETURN);
        Label l4 = new Label();
        mv.visitLabel(l4);
        mv.visitLocalVariable("this", "L" + name + "ArrayList;", null, l0, l4, 0);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PROTECTED + ACC_BRIDGE + ACC_SYNTHETIC, "createImpl", "()Ljava/lang/Object;",
                null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(29, l0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKEVIRTUAL, name + "ArrayList", "createImpl", "()L" + name + ";");
        mv.visitInsn(ARETURN);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLocalVariable("this", "L" + name + "ArrayList;", null, l0, l1, 0);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PROTECTED + ACC_BRIDGE + ACC_SYNTHETIC, "createElement",
                "(J)L" + collections + "impl/AbstractHugeElement;", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(29, l0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitVarInsn(LLOAD, 1);
        mv.visitMethodInsn(INVOKEVIRTUAL, name + "ArrayList", "createElement", "(J)L" + name + "Element;");
        mv.visitInsn(ARETURN);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLocalVariable("this", "L" + name + "ArrayList;", null, l0, l1, 0);
        mv.visitLocalVariable("x0", "J", null, l0, l1, 1);
        mv.visitMaxs(3, 3);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PROTECTED + ACC_BRIDGE + ACC_SYNTHETIC, "compactOnAllocation",
                "(L" + collections + "api/HugeAllocation;J)V", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(29, l0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitVarInsn(ALOAD, 1);
        mv.visitTypeInsn(CHECKCAST, name + "Allocation");
        mv.visitVarInsn(LLOAD, 2);
        mv.visitMethodInsn(INVOKEVIRTUAL, name + "ArrayList", "compactOnAllocation",
                "(L" + name + "Allocation;J)V");
        mv.visitInsn(RETURN);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLocalVariable("this", "L" + name + "ArrayList;", null, l0, l1, 0);
        mv.visitLocalVariable("x0", "L" + collections + "api/HugeAllocation;", null, l0, l1, 1);
        mv.visitLocalVariable("x1", "J", null, l0, l1, 2);
        mv.visitMaxs(4, 4);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PROTECTED + ACC_BRIDGE + ACC_SYNTHETIC, "createAllocation",
                "(L" + collections + "impl/MappedFileChannel;)L" + collections + "api/HugeAllocation;", null,
                null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(29, l0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitVarInsn(ALOAD, 1);
        mv.visitMethodInsn(INVOKEVIRTUAL, name + "ArrayList", "createAllocation",
                "(L" + collections + "impl/MappedFileChannel;)L" + name + "Allocation;");
        mv.visitInsn(ARETURN);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLocalVariable("this", "L" + name + "ArrayList;", null, l0, l1, 0);
        mv.visitLocalVariable("x0", "L" + collections + "impl/MappedFileChannel;", null, l0, l1, 1);
        mv.visitMaxs(2, 2);
        mv.visitEnd();
    }
    cw.visitEnd();
    final byte[] bytes = cw.toByteArray();
    //        ClassReader cr = new ClassReader(bytes);
    //        cr.accept(new ASMifierClassVisitor(new PrintWriter(System.out)), 0);
    return bytes;
}