Last Updated: February 25, 2016
·
800
· ajermakovics

Generate default constructor using ASM 5 bytecode manipulation

MethodVisitor 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();