use of jdk.internal.org.objectweb.asm.ClassWriter in project jdk8u_jdk by JetBrains.
the class LambdaStackTrace method generateMaker.
private static byte[] generateMaker() {
// interface Maker {
// Object make();
// }
ClassWriter cw = new ClassWriter(0);
cw.visit(V1_7, ACC_INTERFACE | ACC_ABSTRACT, "Maker", null, "java/lang/Object", null);
cw.visitMethod(ACC_PUBLIC | ACC_ABSTRACT, "make", "()Ljava/lang/Object;", null, null);
cw.visitEnd();
return cw.toByteArray();
}
use of jdk.internal.org.objectweb.asm.ClassWriter in project jdk8u_jdk by JetBrains.
the class LambdaAsm method verifyASM.
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);
}
}
use of jdk.internal.org.objectweb.asm.ClassWriter in project jdk8u_jdk by JetBrains.
the class LambdaStackTrace method generateStringMaker.
private static byte[] generateStringMaker() {
// interface StringMaker extends Maker {
// String make();
// }
ClassWriter cw = new ClassWriter(0);
cw.visit(V1_7, ACC_INTERFACE | ACC_ABSTRACT, "StringMaker", null, "java/lang/Object", new String[] { "Maker" });
cw.visitMethod(ACC_PUBLIC | ACC_ABSTRACT, "make", "()Ljava/lang/String;", null, null);
cw.visitEnd();
return cw.toByteArray();
}
Aggregations