private void addGetter(String methodName, String methodDescriptor, MethodCodeBody body)
     throws Exception {
   MethodVisitor methodVisitor =
       visitor.visitMethod(
           Opcodes.ACC_PUBLIC, methodName, methodDescriptor, null, new String[0]);
   methodVisitor.visitCode();
   body.add(methodVisitor);
   methodVisitor.visitInsn(Opcodes.ARETURN);
   methodVisitor.visitMaxs(0, 0);
   methodVisitor.visitEnd();
 }
 private void addSetter(Method method, MethodCodeBody body) throws Exception {
   String methodDescriptor = Type.getMethodDescriptor(method);
   MethodVisitor methodVisitor =
       visitor.visitMethod(
           Opcodes.ACC_PUBLIC, method.getName(), methodDescriptor, null, new String[0]);
   methodVisitor.visitCode();
   body.add(methodVisitor);
   methodVisitor.visitInsn(Opcodes.RETURN);
   methodVisitor.visitMaxs(0, 0);
   methodVisitor.visitEnd();
 }
    public void addConstructor(Constructor<?> constructor) throws Exception {
      List<Type> paramTypes = new ArrayList<Type>();
      for (Class<?> paramType : constructor.getParameterTypes()) {
        paramTypes.add(Type.getType(paramType));
      }
      String methodDescriptor =
          Type.getMethodDescriptor(Type.VOID_TYPE, paramTypes.toArray(new Type[paramTypes.size()]));

      String signature = signature(constructor);

      MethodVisitor methodVisitor =
          visitor.visitMethod(
              Opcodes.ACC_PUBLIC, "<init>", methodDescriptor, signature, new String[0]);
      methodVisitor.visitCode();

      // this.super(p0 .. pn)
      methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
      for (int i = 0; i < constructor.getParameterTypes().length; i++) {
        methodVisitor.visitVarInsn(
            Type.getType(constructor.getParameterTypes()[i]).getOpcode(Opcodes.ILOAD), i + 1);
      }
      methodVisitor.visitMethodInsn(
          Opcodes.INVOKESPECIAL, superclassType.getInternalName(), "<init>", methodDescriptor);

      if (initDynamicObjectHelper != null) {
        initDynamicObjectHelper.add(methodVisitor);
      }
      if (initConventionAwareHelper != null) {
        initConventionAwareHelper.add(methodVisitor);
      }
      if (initMetaClass != null) {
        initMetaClass.add(methodVisitor);
      }

      methodVisitor.visitInsn(Opcodes.RETURN);
      methodVisitor.visitMaxs(0, 0);
      methodVisitor.visitEnd();
    }