java类com.alibaba.fastjson.util.FieldInfo的实例源码

ASMDeserializerFactory.java 文件源码 项目:GitHub 阅读 35 收藏 0 点赞 0 评论 0
private void _batchSet(Context context, MethodVisitor mw, boolean flag) {
    for (int i = 0, size = context.fieldInfoList.length; i < size; ++i) {
        Label notSet_ = new Label();

        if (flag) {
            _isFlag(mw, context, i, notSet_);
        }

        FieldInfo fieldInfo = context.fieldInfoList[i];
        _loadAndSet(context, mw, fieldInfo);

        if (flag) {
            mw.visitLabel(notSet_);
        }
    }
}
ASMDeserializerFactory.java 文件源码 项目:GitHub 阅读 39 收藏 0 点赞 0 评论 0
private void _getCollectionFieldItemDeser(Context context, MethodVisitor mw, FieldInfo fieldInfo,
                                          Class<?> itemType) {
    Label notNull_ = new Label();
    mw.visitVarInsn(ALOAD, 0);
    mw.visitFieldInsn(GETFIELD, context.className, fieldInfo.name + "_asm_list_item_deser__",
                      desc(ObjectDeserializer.class));
    mw.visitJumpInsn(IFNONNULL, notNull_);

    mw.visitVarInsn(ALOAD, 0);

    mw.visitVarInsn(ALOAD, 1);
    mw.visitMethodInsn(INVOKEVIRTUAL, DefaultJSONParser, "getConfig", "()" + desc(ParserConfig.class));
    mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(desc(itemType)));
    mw.visitMethodInsn(INVOKEVIRTUAL, type(ParserConfig.class), "getDeserializer",
                       "(Ljava/lang/reflect/Type;)" + desc(ObjectDeserializer.class));

    mw.visitFieldInsn(PUTFIELD, context.className, fieldInfo.name + "_asm_list_item_deser__",
                      desc(ObjectDeserializer.class));

    mw.visitLabel(notNull_);
    mw.visitVarInsn(ALOAD, 0);
    mw.visitFieldInsn(GETFIELD, context.className, fieldInfo.name + "_asm_list_item_deser__",
                      desc(ObjectDeserializer.class));
}
ASMDeserializerFactory.java 文件源码 项目:GitHub 阅读 41 收藏 0 点赞 0 评论 0
private void _getFieldDeser(Context context, MethodVisitor mw, FieldInfo fieldInfo) {
    Label notNull_ = new Label();
    mw.visitVarInsn(ALOAD, 0);
    mw.visitFieldInsn(GETFIELD, context.className, fieldInfo.name + "_asm_deser__", desc(ObjectDeserializer.class));
    mw.visitJumpInsn(IFNONNULL, notNull_);

    mw.visitVarInsn(ALOAD, 0);

    mw.visitVarInsn(ALOAD, 1);
    mw.visitMethodInsn(INVOKEVIRTUAL, DefaultJSONParser, "getConfig", "()" + desc(ParserConfig.class));
    mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(desc(fieldInfo.fieldClass)));
    mw.visitMethodInsn(INVOKEVIRTUAL, type(ParserConfig.class), "getDeserializer",
                       "(Ljava/lang/reflect/Type;)" + desc(ObjectDeserializer.class));

    mw.visitFieldInsn(PUTFIELD, context.className, fieldInfo.name + "_asm_deser__", desc(ObjectDeserializer.class));

    mw.visitLabel(notNull_);

    mw.visitVarInsn(ALOAD, 0);
    mw.visitFieldInsn(GETFIELD, context.className, fieldInfo.name + "_asm_deser__", desc(ObjectDeserializer.class));
}
ASMSerializerFactory.java 文件源码 项目:uavstack 阅读 38 收藏 0 点赞 0 评论 0
private void _double(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) {
    Label _end = new Label();

    _nameApply(mw, property, context, _end);
    _get(mw, context, property);
    mw.visitVarInsn(DSTORE, context.var("double", 2));

    _filters(mw, property, context, _end);

    mw.visitVarInsn(ALOAD, context.var("out"));
    mw.visitVarInsn(ILOAD, context.var("seperator"));
    mw.visitVarInsn(ALOAD, context.fieldName());
    mw.visitVarInsn(DLOAD, context.var("double", 2));
    mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;D)V");

    _seperator(mw, context);

    mw.visitLabel(_end);
}
ASMSerializerFactory.java 文件源码 项目:uavstack 阅读 32 收藏 0 点赞 0 评论 0
private void _int(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) {
    Label _end = new Label();

    _nameApply(mw, property, context, _end);
    _get(mw, context, property);
    mw.visitVarInsn(ISTORE, context.var("int"));

    _filters(mw, property, context, _end);

    mw.visitVarInsn(ALOAD, context.var("out"));
    mw.visitVarInsn(ILOAD, context.var("seperator"));
    mw.visitVarInsn(ALOAD, context.fieldName());
    mw.visitVarInsn(ILOAD, context.var("int"));

    mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;I)V");

    _seperator(mw, context);

    mw.visitLabel(_end);
}
FieldSerializer.java 文件源码 项目:uavstack 阅读 34 收藏 0 点赞 0 评论 0
public FieldSerializer(FieldInfo fieldInfo){
    super();
    this.fieldInfo = fieldInfo;
    fieldInfo.setAccessible(true);

    this.double_quoted_fieldPrefix = '"' + fieldInfo.getName() + "\":";

    this.single_quoted_fieldPrefix = '\'' + fieldInfo.getName() + "\':";

    this.un_quoted_fieldPrefix = fieldInfo.getName() + ":";

    JSONField annotation = fieldInfo.getAnnotation(JSONField.class);
    if (annotation != null) {
        for (SerializerFeature feature : annotation.serialzeFeatures()) {
            if (feature == SerializerFeature.WriteMapNullValue) {
                writeNull = true;
            }
        }
    }
}
ASMSerializerFactory.java 文件源码 项目:GitHub 阅读 33 收藏 0 点赞 0 评论 0
private void _long(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) {
    Label end_ = new Label();

    _nameApply(mw, property, context, end_);
    _get(mw, context, property);
    mw.visitVarInsn(LSTORE, context.var("long", 2));

    _filters(mw, property, context, end_);

    mw.visitVarInsn(ALOAD, context.var("out"));
    mw.visitVarInsn(ILOAD, context.var("seperator"));
    mw.visitVarInsn(ALOAD, Context.fieldName);
    mw.visitVarInsn(LLOAD, context.var("long", 2));
    mw.visitMethodInsn(INVOKEVIRTUAL, SerializeWriter, "writeFieldValue", "(CLjava/lang/String;J)V");

    _seperator(mw, context);

    mw.visitLabel(end_);
}
ASMSerializerFactory.java 文件源码 项目:GitHub 阅读 36 收藏 0 点赞 0 评论 0
private void _float(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) {
    Label end_ = new Label();

    _nameApply(mw, property, context, end_);
    _get(mw, context, property);
    mw.visitVarInsn(FSTORE, context.var("float"));

    _filters(mw, property, context, end_);

    mw.visitVarInsn(ALOAD, context.var("out"));
    mw.visitVarInsn(ILOAD, context.var("seperator"));
    mw.visitVarInsn(ALOAD, Context.fieldName);
    mw.visitVarInsn(FLOAD, context.var("float"));
    mw.visitMethodInsn(INVOKEVIRTUAL, SerializeWriter, "writeFieldValue", "(CLjava/lang/String;F)V");

    _seperator(mw, context);

    mw.visitLabel(end_);
}
ASMSerializerFactory.java 文件源码 项目:GitHub 阅读 33 收藏 0 点赞 0 评论 0
private void _double(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) {
    Label end_ = new Label();

    _nameApply(mw, property, context, end_);
    _get(mw, context, property);
    mw.visitVarInsn(DSTORE, context.var("double", 2));

    _filters(mw, property, context, end_);

    mw.visitVarInsn(ALOAD, context.var("out"));
    mw.visitVarInsn(ILOAD, context.var("seperator"));
    mw.visitVarInsn(ALOAD, Context.fieldName);
    mw.visitVarInsn(DLOAD, context.var("double", 2));
    mw.visitMethodInsn(INVOKEVIRTUAL, SerializeWriter, "writeFieldValue", "(CLjava/lang/String;D)V");

    _seperator(mw, context);

    mw.visitLabel(end_);
}
ASMSerializerFactory.java 文件源码 项目:uavstack 阅读 33 收藏 0 点赞 0 评论 0
private void _byte(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) {
    Label _end = new Label();

    _nameApply(mw, property, context, _end);
    _get(mw, context, property);
    mw.visitVarInsn(ISTORE, context.var("byte"));

    _filters(mw, property, context, _end);

    mw.visitVarInsn(ALOAD, context.var("out"));
    mw.visitVarInsn(ILOAD, context.var("seperator"));
    mw.visitVarInsn(ALOAD, context.fieldName());
    mw.visitVarInsn(ILOAD, context.var("byte"));

    mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;I)V");

    _seperator(mw, context);

    mw.visitLabel(_end);
}
ASMSerializerFactory.java 文件源码 项目:GitHub 阅读 37 收藏 0 点赞 0 评论 0
private void _filters(MethodVisitor mw, FieldInfo property, Context context, Label _end) {
    if (property.fieldTransient) {
        mw.visitVarInsn(ALOAD, context.var("out"));
        mw.visitLdcInsn(SerializerFeature.SkipTransientField.mask);
        mw.visitMethodInsn(INVOKEVIRTUAL, SerializeWriter, "isEnabled", "(I)Z");
        mw.visitJumpInsn(IFNE, _end);
    }

    _notWriteDefault(mw, property, context, _end);

    if (context.writeDirect) {
        return;
    }

    _apply(mw, property, context);
    mw.visitJumpInsn(IFEQ, _end);

    _processKey(mw, property, context);

    _processValue(mw, property, context, _end);
}
ASMSerializerFactory.java 文件源码 项目:GitHub 阅读 33 收藏 0 点赞 0 评论 0
private void _nameApply(MethodVisitor mw, FieldInfo property, Context context, Label _end) {
    if (!context.writeDirect) {
        mw.visitVarInsn(ALOAD, 0);
        mw.visitVarInsn(ALOAD, Context.serializer);
        mw.visitVarInsn(ALOAD, Context.obj);
        mw.visitVarInsn(ALOAD, Context.fieldName);
        mw.visitMethodInsn(INVOKEVIRTUAL, JavaBeanSerializer, "applyName",
                           "(L" + JSONSerializer + ";Ljava/lang/Object;Ljava/lang/String;)Z");
        mw.visitJumpInsn(IFEQ, _end);

        _labelApply(mw, property, context, _end);
    }

    if (property.field == null) {
        mw.visitVarInsn(ALOAD, context.var("out"));
        mw.visitLdcInsn(SerializerFeature.IgnoreNonFieldGetter.mask);
        mw.visitMethodInsn(INVOKEVIRTUAL, SerializeWriter, "isEnabled", "(I)Z");

        // if true
        mw.visitJumpInsn(IFNE, _end);
    }
}
ASMDeserializerFactory.java 文件源码 项目:uavstack 阅读 35 收藏 0 点赞 0 评论 0
private void _getCollectionFieldItemDeser(Context context, MethodVisitor mw, FieldInfo fieldInfo, Class<?> itemType) {
    Label notNull_ = new Label();
    mw.visitVarInsn(ALOAD, 0);
    mw.visitFieldInsn(GETFIELD, context.getClassName(), fieldInfo.getName() + "_asm_list_item_deser__",
                      "Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;");
    mw.visitJumpInsn(IFNONNULL, notNull_);

    mw.visitVarInsn(ALOAD, 0);

    mw.visitVarInsn(ALOAD, 1);
    mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/parser/DefaultJSONParser", "getConfig", "()"
                                                                                     + "Lcom/alibaba/fastjson/parser/ParserConfig;");
    mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(getDesc(itemType)));
    mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/parser/ParserConfig", "getDeserializer",
                       "(Ljava/lang/reflect/Type;)Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;");

    mw.visitFieldInsn(PUTFIELD, context.getClassName(), fieldInfo.getName() + "_asm_list_item_deser__",
                      "Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;");

    mw.visitLabel(notNull_);
    mw.visitVarInsn(ALOAD, 0);
    mw.visitFieldInsn(GETFIELD, context.getClassName(), fieldInfo.getName() + "_asm_list_item_deser__",
                      "Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;");
}
ASMSerializerFactory.java 文件源码 项目:GitHub 阅读 39 收藏 0 点赞 0 评论 0
private void _getListFieldItemSer(Context context, MethodVisitor mw, FieldInfo fieldInfo, Class<?> itemType) {
    Label notNull_ = new Label();
    mw.visitVarInsn(ALOAD, 0);
    mw.visitFieldInsn(GETFIELD, context.className, fieldInfo.name + "_asm_list_item_ser_",
                      ObjectSerializer_desc);
    mw.visitJumpInsn(IFNONNULL, notNull_);

    mw.visitVarInsn(ALOAD, 0); // this
    mw.visitVarInsn(ALOAD, Context.serializer);
    mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(desc(itemType)));
    mw.visitMethodInsn(INVOKEVIRTUAL, JSONSerializer, "getObjectWriter",
                       "(Ljava/lang/Class;)" + ObjectSerializer_desc);

    mw.visitFieldInsn(PUTFIELD, context.className, fieldInfo.name + "_asm_list_item_ser_",
                      ObjectSerializer_desc);

    mw.visitLabel(notNull_);

    mw.visitVarInsn(ALOAD, 0);
    mw.visitFieldInsn(GETFIELD, context.className, fieldInfo.name + "_asm_list_item_ser_",
                      ObjectSerializer_desc);
}
ASMSerializerFactory.java 文件源码 项目:GitHub 阅读 35 收藏 0 点赞 0 评论 0
private void _getFieldSer(Context context, MethodVisitor mw, FieldInfo fieldInfo) {
    Label notNull_ = new Label();
    mw.visitVarInsn(ALOAD, 0);
    mw.visitFieldInsn(GETFIELD, context.className, fieldInfo.name + "_asm_ser_", ObjectSerializer_desc);
    mw.visitJumpInsn(IFNONNULL, notNull_);

    mw.visitVarInsn(ALOAD, 0); // this
    mw.visitVarInsn(ALOAD, Context.serializer);
    mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(desc(fieldInfo.fieldClass)));
    mw.visitMethodInsn(INVOKEVIRTUAL, JSONSerializer, "getObjectWriter",
                       "(Ljava/lang/Class;)" + ObjectSerializer_desc);

    mw.visitFieldInsn(PUTFIELD, context.className, fieldInfo.name + "_asm_ser_", ObjectSerializer_desc);

    mw.visitLabel(notNull_);

    mw.visitVarInsn(ALOAD, 0);
    mw.visitFieldInsn(GETFIELD, context.className, fieldInfo.name + "_asm_ser_", ObjectSerializer_desc);
}
SerializeBeanInfo.java 文件源码 项目:GitHub 阅读 29 收藏 0 点赞 0 评论 0
public SerializeBeanInfo(Class<?> beanType, //
                         JSONType jsonType, //
                         String typeName, //
                         String typeKey,
                         int features,
                         FieldInfo[] fields, //
                         FieldInfo[] sortedFields
                         ){
    this.beanType = beanType;
    this.jsonType = jsonType;
    this.typeName = typeName;
    this.typeKey = typeKey;
    this.features = features;
    this.fields = fields;
    this.sortedFields = sortedFields;
}
ASMSerializerFactory.java 文件源码 项目:uavstack 阅读 31 收藏 0 点赞 0 评论 0
private void _long(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) {
    Label _end = new Label();

    _nameApply(mw, property, context, _end);
    _get(mw, context, property);
    mw.visitVarInsn(LSTORE, context.var("long", 2));

    _filters(mw, property, context, _end);

    mw.visitVarInsn(ALOAD, context.var("out"));
    mw.visitVarInsn(ILOAD, context.var("seperator"));
    mw.visitVarInsn(ALOAD, context.fieldName());
    mw.visitVarInsn(LLOAD, context.var("long", 2));
    mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;J)V");

    _seperator(mw, context);

    mw.visitLabel(_end);
}
ASMSerializerFactory.java 文件源码 项目:uavstack 阅读 31 收藏 0 点赞 0 评论 0
private void _char(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) {
    Label _end = new Label();

    _nameApply(mw, property, context, _end);
    _get(mw, context, property);
    mw.visitVarInsn(ISTORE, context.var("char"));

    _filters(mw, property, context, _end);

    mw.visitVarInsn(ALOAD, context.var("out"));
    mw.visitVarInsn(ILOAD, context.var("seperator"));
    mw.visitVarInsn(ALOAD, context.fieldName());
    mw.visitVarInsn(ILOAD, context.var("char"));

    mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;C)V");

    _seperator(mw, context);

    mw.visitLabel(_end);
}
ParserConfig.java 文件源码 项目:uavstack 阅读 32 收藏 0 点赞 0 评论 0
public FieldDeserializer createFieldDeserializerWithoutASM(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo) {
    Class<?> fieldClass = fieldInfo.getFieldClass();

    if (fieldClass == boolean.class || fieldClass == Boolean.class) {
        return new BooleanFieldDeserializer(mapping, clazz, fieldInfo);
    }

    if (fieldClass == int.class || fieldClass == Integer.class) {
        return new IntegerFieldDeserializer(mapping, clazz, fieldInfo);
    }

    if (fieldClass == long.class || fieldClass == Long.class) {
        return new LongFieldDeserializer(mapping, clazz, fieldInfo);
    }

    if (fieldClass == String.class) {
        return new StringFieldDeserializer(mapping, clazz, fieldInfo);
    }

    if (fieldClass == List.class || fieldClass == ArrayList.class) {
        return new ArrayListTypeFieldDeserializer(mapping, clazz, fieldInfo);
    }

    return new DefaultFieldDeserializer(mapping, clazz, fieldInfo);
}
ParserConfig.java 文件源码 项目:boohee_v5.6 阅读 28 收藏 0 点赞 0 评论 0
public FieldDeserializer createFieldDeserializerWithoutASM(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo) {
    Class<?> fieldClass = fieldInfo.getFieldClass();
    if (fieldClass == Boolean.TYPE || fieldClass == Boolean.class) {
        return new BooleanFieldDeserializer(mapping, clazz, fieldInfo);
    }
    if (fieldClass == Integer.TYPE || fieldClass == Integer.class) {
        return new IntegerFieldDeserializer(mapping, clazz, fieldInfo);
    }
    if (fieldClass == Long.TYPE || fieldClass == Long.class) {
        return new LongFieldDeserializer(mapping, clazz, fieldInfo);
    }
    if (fieldClass == String.class) {
        return new StringFieldDeserializer(mapping, clazz, fieldInfo);
    }
    if (fieldClass == List.class || fieldClass == ArrayList.class) {
        return new ArrayListTypeFieldDeserializer(mapping, clazz, fieldInfo);
    }
    return new DefaultFieldDeserializer(mapping, clazz, fieldInfo);
}
ASMSerializerFactory.java 文件源码 项目:uavstack 阅读 30 收藏 0 点赞 0 评论 0
private void _short(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) {
    Label _end = new Label();

    _nameApply(mw, property, context, _end);
    _get(mw, context, property);
    mw.visitVarInsn(ISTORE, context.var("short"));

    _filters(mw, property, context, _end);

    mw.visitVarInsn(ALOAD, context.var("out"));
    mw.visitVarInsn(ILOAD, context.var("seperator"));
    mw.visitVarInsn(ALOAD, context.fieldName());
    mw.visitVarInsn(ILOAD, context.var("short"));

    mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;I)V");

    _seperator(mw, context);

    mw.visitLabel(_end);
}
ASMSerializerFactory.java 文件源码 项目:boohee_v5.6 阅读 51 收藏 0 点赞 0 评论 0
private void _decimal(Class<?> cls, MethodVisitor mw, FieldInfo property, Context context) {
    Label _end = new Label();
    _nameApply(mw, property, context, _end);
    _get(mw, context, property);
    mw.visitVarInsn(58, context.var("decimal"));
    _filters(mw, property, context, _end);
    Label _if = new Label();
    Label _else = new Label();
    Label _end_if = new Label();
    mw.visitLabel(_if);
    mw.visitVarInsn(25, context.var("decimal"));
    mw.visitJumpInsn(199, _else);
    _if_write_null(mw, property, context);
    mw.visitJumpInsn(167, _end_if);
    mw.visitLabel(_else);
    mw.visitVarInsn(25, context.var("out"));
    mw.visitVarInsn(21, context.var("seperator"));
    mw.visitVarInsn(25, context.fieldName());
    mw.visitVarInsn(25, context.var("decimal"));
    mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;Ljava/math/BigDecimal;)V");
    _seperator(mw, context);
    mw.visitJumpInsn(167, _end_if);
    mw.visitLabel(_end_if);
    mw.visitLabel(_end);
}
ASMSerializerFactory.java 文件源码 项目:boohee_v5.6 阅读 45 收藏 0 点赞 0 评论 0
private void _string(Class<?> cls, MethodVisitor mw, FieldInfo property, Context context) {
    Label _end = new Label();
    _nameApply(mw, property, context, _end);
    _get(mw, context, property);
    mw.visitVarInsn(58, context.var("string"));
    _filters(mw, property, context, _end);
    Label _else = new Label();
    Label _end_if = new Label();
    mw.visitVarInsn(25, context.var("string"));
    mw.visitJumpInsn(199, _else);
    _if_write_null(mw, property, context);
    mw.visitJumpInsn(167, _end_if);
    mw.visitLabel(_else);
    mw.visitVarInsn(25, context.var("out"));
    mw.visitVarInsn(21, context.var("seperator"));
    mw.visitVarInsn(25, context.fieldName());
    mw.visitVarInsn(25, context.var("string"));
    mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;Ljava/lang/String;)V");
    _seperator(mw, context);
    mw.visitLabel(_end_if);
    mw.visitLabel(_end);
}
ASMSerializerFactory.java 文件源码 项目:boohee_v5.6 阅读 30 收藏 0 点赞 0 评论 0
private void _filters(MethodVisitor mw, FieldInfo property, Context context, Label _end) {
    if (property.getField() != null && Modifier.isTransient(property.getField().getModifiers())) {
        mw.visitVarInsn(25, context.var("out"));
        mw.visitFieldInsn(178, "com/alibaba/fastjson/serializer/SerializerFeature", "SkipTransientField", "Lcom/alibaba/fastjson/serializer/SerializerFeature;");
        mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "isEnabled", "(Lcom/alibaba/fastjson/serializer/SerializerFeature;)Z");
        mw.visitJumpInsn(154, _end);
    }
    _notWriteDefault(mw, property, context, _end);
    _apply(mw, property, context);
    mw.visitJumpInsn(153, _end);
    _processKey(mw, property, context);
    Label _else_processKey = new Label();
    _processValue(mw, property, context);
    mw.visitVarInsn(25, context.original());
    mw.visitVarInsn(25, context.processValue());
    mw.visitJumpInsn(165, _else_processKey);
    _writeObject(mw, property, context, _end);
    mw.visitJumpInsn(167, _end);
    mw.visitLabel(_else_processKey);
}
ASMDeserializerFactory.java 文件源码 项目:uavstack 阅读 38 收藏 0 点赞 0 评论 0
private void _batchSet(Context context, MethodVisitor mw, boolean flag) {
    for (int i = 0, size = context.getFieldInfoList().size(); i < size; ++i) {
        Label notSet_ = new Label();

        if (flag) {
            _isFlag(mw, context, i, notSet_);
        }

        FieldInfo fieldInfo = context.getFieldInfoList().get(i);
        _loadAndSet(context, mw, fieldInfo);

        if (flag) {
            mw.visitLabel(notSet_);
        }
    }
}
FieldSerializer.java 文件源码 项目:boohee_v5.6 阅读 31 收藏 0 点赞 0 评论 0
public FieldSerializer(FieldInfo fieldInfo) {
    int i = 0;
    this.fieldInfo = fieldInfo;
    fieldInfo.setAccessible(true);
    this.double_quoted_fieldPrefix = '\"' + fieldInfo.getName() + "\":";
    this.single_quoted_fieldPrefix = '\'' + fieldInfo.getName() + "':";
    this.un_quoted_fieldPrefix = fieldInfo.getName() + ":";
    JSONField annotation = (JSONField) fieldInfo.getAnnotation(JSONField.class);
    if (annotation != null) {
        SerializerFeature[] serialzeFeatures = annotation.serialzeFeatures();
        int length = serialzeFeatures.length;
        while (i < length) {
            if (serialzeFeatures[i] == SerializerFeature.WriteMapNullValue) {
                this.writeNull = true;
            }
            i++;
        }
    }
}
ArrayListTypeFieldDeserializer.java 文件源码 项目:GitHub 阅读 31 收藏 0 点赞 0 评论 0
public ArrayListTypeFieldDeserializer(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo){
    super(clazz, fieldInfo);

    Type fieldType = fieldInfo.fieldType;
    if (fieldType instanceof ParameterizedType) {
        Type argType = ((ParameterizedType) fieldInfo.fieldType).getActualTypeArguments()[0];
        if (argType instanceof WildcardType) {
            WildcardType wildcardType = (WildcardType) argType;
            Type[] upperBounds = wildcardType.getUpperBounds();
            if (upperBounds.length == 1) {
                argType = upperBounds[0];
            }
        }
        this.itemType = argType;
    } else {
        this.itemType = Object.class;
    }
}
ASMSerializerFactory.java 文件源码 项目:GitHub 阅读 31 收藏 0 点赞 0 评论 0
public Context(FieldInfo[] getters, //
               SerializeBeanInfo beanInfo, //
               String className, //
               boolean writeDirect, //
               boolean nonContext){
    this.getters = getters;
    this.className = className;
    this.beanInfo = beanInfo;
    this.writeDirect = writeDirect;
    this.nonContext = nonContext || beanInfo.beanType.isEnum();
}
DeserializerGen.java 文件源码 项目:uavstack 阅读 33 收藏 0 点赞 0 评论 0
private void genBatchSet(List<FieldInfo> fieldList, boolean flag) throws IOException {
    for (int i = 0, size = fieldList.size(); i < size; ++i) {
        FieldInfo fieldInfo = fieldList.get(i);

        String varName = "_asm_flag_" + (i / 32);
        if (flag) {
            print("if ((");
            print(varName);
            print(" & ");
            print(Integer.toString(1 << i));
            print(") != 0) {");
            println();
            incrementIndent();
        }

        if (fieldInfo.getMethod() != null) {
            print("\tinstance.");
            print(fieldInfo.getMethod().getName());
            print("(");
            printFieldVarName(fieldInfo);
            println(");");
        } else {
            print("\tinstance.");
            print(fieldInfo.getField().getName());
            print(" = ");
            printFieldVarName(fieldInfo);
            println(";");
        }

        if (flag) {
            decrementIndent();
            println();
            println("}");
        }
    }
}
DeserializerGen.java 文件源码 项目:GitHub 阅读 30 收藏 0 点赞 0 评论 0
private void genBatchSet(FieldInfo[] fieldList, boolean flag) throws IOException {
    for (int i = 0, size = fieldList.length; i < size; ++i) {
        FieldInfo fieldInfo = fieldList[i];

        String varName = "_asm_flag_" + (i / 32);
        if (flag) {
            print("if ((");
            print(varName);
            print(" & ");
            print(Integer.toString(1 << i));
            print(") != 0) {");
            println();
            incrementIndent();
        }

        if (fieldInfo.method != null) {
            print("\tinstance.");
            print(fieldInfo.method.getName());
            print("(");
            printFieldVarName(fieldInfo);
            println(");");
        } else {
            print("\tinstance.");
            print(fieldInfo.field.getName());
            print(" = ");
            printFieldVarName(fieldInfo);
            println(";");
        }

        if (flag) {
            decrementIndent();
            println();
            println("}");
        }
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号