@@ -0,0 +1,1176 @@
+import org.objectweb.asm.ClassWriter;%0Aimport org.objectweb.asm.Opcodes;%0Aimport org.objectweb.asm.Type;%0Aimport org.objectweb.asm.commons.GeneratorAdapter;%0Aimport org.objectweb.asm.commons.Method;%0A%0Apublic class Gen %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);%0A        cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, %22GenBCode%22, null, %22java/lang/Object%22, null);%0A%0A        Method init = Method.getMethod(%22void %3Cinit%3E()%22);%0A        GeneratorAdapter gaInit = new GeneratorAdapter(Opcodes.ACC_PUBLIC, init, null, null, cw);%0A        gaInit.visitCode();%0A        gaInit.loadThis();%0A        gaInit.invokeConstructor(Type.getType(Object.class), init);%0A        gaInit.returnValue();%0A        gaInit.endMethod();%0A%0A        Method run = Method.getMethod(%22int run()%22);%0A        GeneratorAdapter ga = new GeneratorAdapter((Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC), run, null, null, cw);%0A        ga.visitCode();%0A        // BEGIN important part%0A        ga.push(42);%0A        // END important part%0A        ga.returnValue();%0A        ga.endMethod();%0A%0A        cw.visitEnd();%0A%0A        byte%5B%5D generatedByteCode = cw.toByteArray();%0A    %7D%0A%7D%0A

Add a prototype for writing bytecode directly