Java Code Examples for jdk.internal.org.objectweb.asm.MethodVisitor#visitMaxs()

The following examples show how to use jdk.internal.org.objectweb.asm.MethodVisitor#visitMaxs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScriptClassInstrumentor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void emitStaticInitializer() {
    final String className = scriptClassInfo.getJavaName();
    if (! staticInitFound) {
        // no user written <clinit> and so create one
        final MethodVisitor mv = ClassGenerator.makeStaticInitializer(this);
        mv.visitCode();
        mv.visitInsn(RETURN);
        mv.visitMaxs(Short.MAX_VALUE, 0);
        mv.visitEnd();
    }
    // Now generate $clinit$
    final MethodGenerator mi = ClassGenerator.makeStaticInitializer(this, $CLINIT$);
    ClassGenerator.emitStaticInitPrefix(mi, className, memberCount);
    if (memberCount > 0) {
        for (final MemberInfo memInfo : scriptClassInfo.getMembers()) {
            if (memInfo.isInstanceProperty() || memInfo.isInstanceFunction()) {
                ClassGenerator.linkerAddGetterSetter(mi, className, memInfo);
            } else if (memInfo.isInstanceGetter()) {
                final MemberInfo setter = scriptClassInfo.findSetter(memInfo);
                ClassGenerator.linkerAddGetterSetter(mi, className, memInfo, setter);
            }
        }
    }
    ClassGenerator.emitStaticInitSuffix(mi, className);
}
 
Example 2
Source File: ScriptClassInstrumentor.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
private void emitStaticInitializer() {
    final String className = scriptClassInfo.getJavaName();
    if (! staticInitFound) {
        // no user written <clinit> and so create one
        final MethodVisitor mv = ClassGenerator.makeStaticInitializer(this);
        mv.visitCode();
        mv.visitInsn(RETURN);
        mv.visitMaxs(Short.MAX_VALUE, 0);
        mv.visitEnd();
    }
    // Now generate $clinit$
    final MethodGenerator mi = ClassGenerator.makeStaticInitializer(this, $CLINIT$);
    ClassGenerator.emitStaticInitPrefix(mi, className, memberCount);
    if (memberCount > 0) {
        for (final MemberInfo memInfo : scriptClassInfo.getMembers()) {
            if (memInfo.isInstanceProperty() || memInfo.isInstanceFunction()) {
                ClassGenerator.linkerAddGetterSetter(mi, className, memInfo);
            } else if (memInfo.isInstanceGetter()) {
                final MemberInfo setter = scriptClassInfo.findSetter(memInfo);
                ClassGenerator.linkerAddGetterSetter(mi, className, memInfo, setter);
            }
        }
    }
    ClassGenerator.emitStaticInitSuffix(mi, className);
}
 
Example 3
Source File: UnsupportedClassFileVersion.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void writeClassFile() throws Exception {
    ClassWriter cw = new ClassWriter(0);
    MethodVisitor mv;

    cw.visit(99, ACC_PUBLIC + ACC_SUPER, "ClassFile", null, "java/lang/Object", null);
    mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
    mv.visitInsn(RETURN);
    mv.visitMaxs(1, 1);
    mv.visitEnd();
    cw.visitEnd();

    try (FileOutputStream fos = new FileOutputStream(new File("ClassFile.class"))) {
         fos.write(cw.toByteArray());
    }
}
 
Example 4
Source File: LambdaAsm.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void verifyASM() throws Exception {
    ClassWriter cw = new ClassWriter(0);
    cw.visit(V1_8, ACC_PUBLIC, "X", null, "java/lang/Object", null);
    MethodVisitor mv = cw.visitMethod(ACC_STATIC, "foo",
            "()V", null, null);
    mv.visitMaxs(2, 1);
    mv.visitMethodInsn(INVOKESTATIC,
            "java/util/function/Function.class",
            "identity", "()Ljava/util/function/Function;", true);
    mv.visitInsn(RETURN);
    cw.visitEnd();
    byte[] carray = cw.toByteArray();
    // for debugging
    // write((new File("X.class")).toPath(), carray, CREATE, TRUNCATE_EXISTING);

    // verify using javap/classfile reader
    ClassFile cf = ClassFile.read(new ByteArrayInputStream(carray));
    int mcount = checkMethod(cf, "foo");
    if (mcount < 1) {
        throw new RuntimeException("unexpected method count, expected 1" +
                "but got " + mcount);
    }
}
 
Example 5
Source File: CallSiteDepContextTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static byte[] getClassFile(String suffix) {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
    MethodVisitor mv;
    cw.visit(52, ACC_PUBLIC | ACC_SUPER, CLASS_NAME + suffix, null, "java/lang/Object", null);
    {
        mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, METHOD_NAME, TYPE.toMethodDescriptorString(), null, null);
        mv.visitCode();
        Handle bsm = new Handle(H_INVOKESTATIC,
                CallSiteDepContextTest.class.getName().replace(".", "/"),
                "bootstrap",
                bsmMH.type().toMethodDescriptorString());
        mv.visitInvokeDynamicInsn("methodName", TYPE.toMethodDescriptorString(), bsm);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
    cw.visitEnd();
    return cw.toByteArray();
}
 
Example 6
Source File: LambdaAsm.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static void verifyASM() throws Exception {
    ClassWriter cw = new ClassWriter(0);
    cw.visit(V1_8, ACC_PUBLIC, "X", null, "java/lang/Object", null);
    MethodVisitor mv = cw.visitMethod(ACC_STATIC, "foo",
            "()V", null, null);
    mv.visitMaxs(2, 1);
    mv.visitMethodInsn(INVOKESTATIC,
            "java/util/function/Function.class",
            "identity", "()Ljava/util/function/Function;", true);
    mv.visitInsn(RETURN);
    cw.visitEnd();
    byte[] carray = cw.toByteArray();
    // for debugging
    // write((new File("X.class")).toPath(), carray, CREATE, TRUNCATE_EXISTING);

    // verify using javap/classfile reader
    ClassFile cf = ClassFile.read(new ByteArrayInputStream(carray));
    int mcount = checkMethod(cf, "foo");
    if (mcount < 1) {
        throw new RuntimeException("unexpected method count, expected 1" +
                "but got " + mcount);
    }
}
 
Example 7
Source File: DefineClassTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generates a class file with the given class name
 */
byte[] generateClass(String className) {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
                                     + ClassWriter.COMPUTE_FRAMES);
    cw.visit(V1_9,
            ACC_PUBLIC + ACC_SUPER,
            className.replace(".", "/"),
            null,
            "java/lang/Object",
            null);

    // <init>
    MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
    mv.visitInsn(RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();

    cw.visitEnd();
    return cw.toByteArray();
}
 
Example 8
Source File: TestAMEnotNPE.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The bytes for D, a NOT abstract class extending abstract class C without
 * supplying an implementation for abstract method m. There is a default
 * method in the interface I, but it should lose to the abstract class.
 *
 * @return
 * @throws Exception
 */
public static byte[] bytesForD() throws Exception {

    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES
            | ClassWriter.COMPUTE_MAXS);
    MethodVisitor mv;

    cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, "p/D", null, "p/C", null);

    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, "p/C", "<init>", "()V");
        mv.visitInsn(RETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
    cw.visitEnd();

    return cw.toByteArray();
}
 
Example 9
Source File: EventClassBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void buildConstructor() {
    MethodVisitor mv = classWriter.visitMethod(Opcodes.ACC_PUBLIC, DEFAULT_CONSTRUCTOR.getName(), DEFAULT_CONSTRUCTOR.getDescriptor(), null, null);
    mv.visitIntInsn(Opcodes.ALOAD, 0);
    ASMToolkit.invokeSpecial(mv, TYPE_EVENT.getInternalName(), DEFAULT_CONSTRUCTOR);
    mv.visitInsn(Opcodes.RETURN);
    mv.visitMaxs(0, 0);
}
 
Example 10
Source File: EventHandlerProxyCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void buildTimestampMethod() {
    MethodVisitor mv = classWriter.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), null, null);
    mv.visitCode();
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(EventHandler.class), METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), false);
    mv.visitInsn(Opcodes.LRETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
 
Example 11
Source File: EventHandlerProxyCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void buildConstructor() {
    MethodVisitor mv = classWriter.visitMethod(0x0, METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), makeConstructorDescriptor(), null, null);
    mv.visitVarInsn(Opcodes.ALOAD, 0); // this
    mv.visitVarInsn(Opcodes.ILOAD, 1); // registered
    mv.visitVarInsn(Opcodes.ALOAD, 2); // event type
    mv.visitVarInsn(Opcodes.ALOAD, 3); // event control
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(EventHandler.class), METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), METHOD_EVENT_HANDLER_CONSTRUCTOR.getDescriptor(), false);
    mv.visitInsn(Opcodes.RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
 
Example 12
Source File: TransitiveOverrideCFV50.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static byte[] dumpP1B() {

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

        cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, "P1/B", null, "P1/A", null);

        {
            mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
            mv.visitCode();
            mv.visitVarInsn(ALOAD, 0);
            mv.visitMethodInsn(INVOKESPECIAL, "P1/A", "<init>", "()V", false);
            mv.visitInsn(RETURN);
            mv.visitMaxs(1, 1);
            mv.visitEnd();
        }
        {
            mv = cw.visitMethod(0, "m", "()I", null, null);
            mv.visitCode();
            mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
            mv.visitLdcInsn("B.m");
            mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false);
            mv.visitIntInsn(BIPUSH, 2);
            mv.visitInsn(IRETURN);
            mv.visitMaxs(2, 1);
            mv.visitEnd();
        }
        cw.visitEnd();

        return cw.toByteArray();
    }
 
Example 13
Source File: TestMultiANewArray.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void writeClassFile(int cfv) throws Exception {
    ClassWriter cw = new ClassWriter(0);
    MethodVisitor mv;

    cw.visit(cfv, ACC_PUBLIC + ACC_SUPER, "ClassFile", null, "java/lang/Object", null);
    mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
    mv.visitInsn(RETURN);
    mv.visitMaxs(1, 1);
    mv.visitEnd();

    mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null);
    mv.visitCode();
    mv.visitInsn(ICONST_1);
    mv.visitInsn(ICONST_2);
    mv.visitMultiANewArrayInsn("[I", 2);
    mv.visitVarInsn(ASTORE, 1);
    mv.visitInsn(RETURN);
    mv.visitMaxs(2, 2);
    mv.visitEnd();

    cw.visitEnd();

    try (FileOutputStream fos = new FileOutputStream(new File("ClassFile.class"))) {
         fos.write(cw.toByteArray());
    }
}
 
Example 14
Source File: BootstrapMethodErrorTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private byte[] loadClassData(String name) throws Exception {
  ClassWriter cw = new ClassWriter(0);
  MethodVisitor mv;

  if (name.equals("C")) {
    cw.visit(52, ACC_SUPER | ACC_PUBLIC, "C", null, "java/lang/Object", null);
    {
      mv = cw.visitMethod(ACC_PRIVATE | ACC_STATIC, "m", "()V", null, null);
      mv.visitCode();
      mv.visitInsn(RETURN);
      mv.visitMaxs(0, 1);
      mv.visitEnd();
    }
    cw.visitEnd();
    return cw.toByteArray();
  } else if (name.equals("Exec")) {
    cw.visit(52, ACC_SUPER | ACC_PUBLIC, "Exec", null, "java/lang/Object", null);
    {
      mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "invokeRef", "()V", null, null);
      mv.visitCode();
      Handle h = new Handle(H_INVOKESTATIC, "C", "m", "()V");
      mv.visitInvokeDynamicInsn("C", "()V", h);
      mv.visitInsn(RETURN);
      mv.visitMaxs(0, 0);
      mv.visitEnd();
    }
    cw.visitEnd();
    return cw.toByteArray();
  }
  return null;
}
 
Example 15
Source File: BootstrapMethodErrorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void defineIndyBootstrapMethodClass(ClassWriter cw) {
    cw.visit(52, ACC_SUPER | ACC_PUBLIC,
             BOOTSTRAP_METHOD_CLASS_NAME, null, "java/lang/Object", null);
    // Bootstrap method is declared to be private
    MethodVisitor mv = cw.visitMethod(ACC_PRIVATE | ACC_STATIC,
                                      BOOTSTRAP_METHOD_NAME, BOOTSTRAP_METHOD_DESC, null, null);
    mv.visitCode();
    defineIndyBootstrapMethodBody(mv);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
 
Example 16
Source File: OverriderMsg.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void dump_Overrider () throws Exception {

        ClassWriter cw = new ClassWriter(0);
        MethodVisitor mv;
        cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, "Overrider", null, "HasFinal", null);

        {
            mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
            mv.visitCode();
            mv.visitVarInsn(ALOAD, 0);
            mv.visitMethodInsn(INVOKESPECIAL, "HasFinal", "<init>", "()V");
            mv.visitInsn(RETURN);
            mv.visitMaxs(1, 1);
            mv.visitEnd();
        }
        {
            mv = cw.visitMethod(ACC_PUBLIC, "m", "(Ljava/lang/String;)V", null, null);
            mv.visitCode();
            mv.visitInsn(RETURN);
            mv.visitMaxs(0, 2);
            mv.visitEnd();
        }
        {
            mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null);
            mv.visitCode();
            mv.visitInsn(RETURN);
            mv.visitMaxs(0, 1);
            mv.visitEnd();
        }
        cw.visitEnd();

        try (FileOutputStream fos = new FileOutputStream(new File("Overrider.class"))) {
             fos.write(cw.toByteArray());
        }
    }
 
Example 17
Source File: BootstrapMethodErrorTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private byte[] loadClassData(String name) throws Exception {
  ClassWriter cw = new ClassWriter(0);
  MethodVisitor mv;

  if (name.equals("C")) {
    cw.visit(52, ACC_SUPER | ACC_PUBLIC, "C", null, "java/lang/Object", null);
    {
      mv = cw.visitMethod(ACC_PRIVATE | ACC_STATIC, "m", "()V", null, null);
      mv.visitCode();
      mv.visitInsn(RETURN);
      mv.visitMaxs(0, 1);
      mv.visitEnd();
    }
    cw.visitEnd();
    return cw.toByteArray();
  } else if (name.equals("Exec")) {
    cw.visit(52, ACC_SUPER | ACC_PUBLIC, "Exec", null, "java/lang/Object", null);
    {
      mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "invokeRef", "()V", null, null);
      mv.visitCode();
      Handle h = new Handle(H_INVOKESTATIC, "C", "m", "()V");
      mv.visitInvokeDynamicInsn("C", "()V", h);
      mv.visitInsn(RETURN);
      mv.visitMaxs(0, 0);
      mv.visitEnd();
    }
    cw.visitEnd();
    return cw.toByteArray();
  }
  return null;
}
 
Example 18
Source File: TestConcreteClassWithAbstractMethod.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static byte[] dumpT3() {
    ClassWriter cw = new ClassWriter(0);
    MethodVisitor mv;

    cw.visit(52, ACC_PUBLIC + ACC_SUPER, "p1/T3", null, "p1/T2", null);

    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, "p1/T2", "<init>", "()V", false);
        mv.visitInsn(RETURN);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PUBLIC, "m", "()I", null, null);
        mv.visitCode();
        mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
        mv.visitLdcInsn("p1/T3.m()");
        mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "print", "(Ljava/lang/String;)V", false);
        mv.visitIntInsn(BIPUSH, 2);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(2, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "test", "()I", null, null);
        mv.visitCode();
        mv.visitTypeInsn(NEW, "p1/T3");
        mv.visitInsn(DUP);
        mv.visitMethodInsn(INVOKESPECIAL, "p1/T3", "<init>", "()V", false);
        mv.visitMethodInsn(INVOKEVIRTUAL, "p1/T2", "m", "()I", false);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(3, 2);
        mv.visitEnd();
    }
    cw.visitEnd();

    return cw.toByteArray();
}
 
Example 19
Source File: TestAMEnotNPE.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the bytes for a class with name d_name (presumably "D" in some
 * package), extending some class with name sub_what, implementing p.I,
 * and defining two methods m() and m(11args) with access method_acc.
 *
 * @param d_name      Name of class that is defined
 * @param sub_what    Name of class that it extends
 * @param method_acc  Accessibility of method(s) m in defined class.
 * @return
 * @throws Exception
 */
public static byte[] bytesForSomeDsubSomethingSomeAccess
        (String d_name, String sub_what, int method_acc)
        throws Exception {

    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES
            | ClassWriter.COMPUTE_MAXS);
    MethodVisitor mv;
    String[] interfaces = {"p/I"};

    cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, d_name, null, sub_what, interfaces);
    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, sub_what, "<init>", "()V");
        mv.visitInsn(RETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
    // int m() {return 3;}
    {
        mv = cw.visitMethod(method_acc, "m", "()I", null, null);
        mv.visitCode();
        mv.visitLdcInsn(new Integer(3));
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
    // int m(11args) {return 3;}
    {
        mv = cw.visitMethod(method_acc, "m", "(BCSIJ"
                + "Ljava/lang/Object;"
                + "Ljava/lang/Object;"
                + "Ljava/lang/Object;"
                + "Ljava/lang/Object;"
                + "Ljava/lang/Object;"
                + "Ljava/lang/Object;"
                + ")I", null, null);
        mv.visitCode();
        mv.visitLdcInsn(new Integer(3));
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
    cw.visitEnd();
    return cw.toByteArray();
}
 
Example 20
Source File: TestAMEnotNPE.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the bytes for a class with name d_name (presumably "D" in some
 * package), extending some class with name sub_what, implementing p.I,
 * and defining two methods m() and m(11args) with access method_acc.
 *
 * @param d_name      Name of class that is defined
 * @param sub_what    Name of class that it extends
 * @param method_acc  Accessibility of method(s) m in defined class.
 * @return
 * @throws Exception
 */
public static byte[] bytesForSomeDsubSomethingSomeAccess
        (String d_name, String sub_what, int method_acc)
        throws Exception {

    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES
            | ClassWriter.COMPUTE_MAXS);
    MethodVisitor mv;
    String[] interfaces = {"p/I"};

    cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, d_name, null, sub_what, interfaces);
    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, sub_what, "<init>", "()V");
        mv.visitInsn(RETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
    // int m() {return 3;}
    {
        mv = cw.visitMethod(method_acc, "m", "()I", null, null);
        mv.visitCode();
        mv.visitLdcInsn(new Integer(3));
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
    // int m(11args) {return 3;}
    {
        mv = cw.visitMethod(method_acc, "m", "(BCSIJ"
                + "Ljava/lang/Object;"
                + "Ljava/lang/Object;"
                + "Ljava/lang/Object;"
                + "Ljava/lang/Object;"
                + "Ljava/lang/Object;"
                + "Ljava/lang/Object;"
                + ")I", null, null);
        mv.visitCode();
        mv.visitLdcInsn(new Integer(3));
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
    cw.visitEnd();
    return cw.toByteArray();
}