use of javassist.bytecode.Bytecode in project hibernate-orm by hibernate.
the class BulkAccessorFactory method addDefaultConstructor.
/**
* Declares a constructor that takes no parameter.
*
* @param classfile The class descriptor
*
* @throws CannotCompileException Indicates trouble with the underlying Javassist calls
*/
private void addDefaultConstructor(ClassFile classfile) throws CannotCompileException {
final ConstPool constPool = classfile.getConstPool();
final String constructorSignature = "()V";
final MethodInfo constructorMethodInfo = new MethodInfo(constPool, MethodInfo.nameInit, constructorSignature);
final Bytecode code = new Bytecode(constPool, 0, 1);
// aload_0
code.addAload(0);
// invokespecial
code.addInvokespecial(BulkAccessor.class.getName(), MethodInfo.nameInit, constructorSignature);
// return
code.addOpcode(Opcode.RETURN);
constructorMethodInfo.setCodeAttribute(code.toCodeAttribute());
constructorMethodInfo.setAccessFlags(AccessFlag.PUBLIC);
classfile.addMethod(constructorMethodInfo);
}
Aggregations