public static void doCast(MethodVisitor mv, ClassNode type) {
   if (type == ClassHelper.OBJECT_TYPE) return;
   if (ClassHelper.isPrimitiveType(type) && type != ClassHelper.VOID_TYPE) {
     unbox(mv, type);
   } else {
     mv.visitTypeInsn(
         CHECKCAST,
         type.isArray()
             ? BytecodeHelper.getTypeDescription(type)
             : BytecodeHelper.getClassInternalName(type.getName()));
   }
 }
 public static void doCast(MethodVisitor mv, Class type) {
   if (type == Object.class) return;
   if (type.isPrimitive() && type != Void.TYPE) {
     unbox(mv, type);
   } else {
     mv.visitTypeInsn(
         CHECKCAST,
         type.isArray()
             ? BytecodeHelper.getTypeDescription(type)
             : BytecodeHelper.getClassInternalName(type.getName()));
   }
 }
 private void unwrapResult(final MethodVisitor mv, final String desc) {
   Type returnType = Type.getReturnType(desc);
   if (returnType == Type.VOID_TYPE) {
     mv.visitInsn(POP);
     mv.visitInsn(RETURN);
   } else {
     if (isPrimitive(returnType)) {
       BytecodeHelper.unbox(mv, ClassHelper.make(returnType.getClassName()));
     } else {
       mv.visitTypeInsn(CHECKCAST, returnType.getInternalName());
     }
     mv.visitInsn(getReturnInsn(returnType));
   }
 }
 public static void unbox(MethodVisitor mv, ClassNode type) {
   if (type.isPrimaryClassNode()) return;
   unbox(mv, type.getTypeClass());
 }