diff --git a/src/main/java/com/alibaba/fastjson/serializer/ASMSerializerFactory.java b/src/main/java/com/alibaba/fastjson/serializer/ASMSerializerFactory.java index 646fca22d9..41c6f669ad 100755 --- a/src/main/java/com/alibaba/fastjson/serializer/ASMSerializerFactory.java +++ b/src/main/java/com/alibaba/fastjson/serializer/ASMSerializerFactory.java @@ -1155,7 +1155,7 @@ private void _get(MethodVisitor mw, Context context, FieldInfo fieldInfo) { mw.visitVarInsn(ALOAD, context.var("entity")); Class declaringClass = method.getDeclaringClass(); mw.visitMethodInsn(INVOKEVIRTUAL, type(declaringClass), method.getName(), desc(method)); - if (!declaringClass.equals(fieldInfo.fieldClass)) { + if (!method.getReturnType().equals(fieldInfo.fieldClass)) { mw.visitTypeInsn(CHECKCAST, type(fieldInfo.fieldClass)); // cast } } else {