Permalink
Browse files

support javassist proxy object

  • Loading branch information...
1 parent af96dfa commit 89f7096410b8e6113a8db6ac6664e0f471378a79 wenshao committed Jul 22, 2012
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/main/java/com/alibaba/fastjson/serializer/JSONSerializer.java
@@ -349,7 +349,7 @@ public final void write(Object object) {
Class<?> clazz = object.getClass();
ObjectSerializer writer = getObjectWriter(clazz);
-
+
try {
writer.write(this, object, null, null);
} catch (IOException e) {
@@ -440,21 +440,25 @@ public ObjectSerializer getObjectWriter(Class<?> clazz) {
config.put(clazz, ClobSeriliazer.instance);
} else {
boolean isCglibProxy = false;
+ boolean isJavassistProxy = false;
for (Class<?> item : clazz.getInterfaces()) {
if (item.getName().equals("net.sf.cglib.proxy.Factory")) {
isCglibProxy = true;
break;
+ } else if (item.getName().equals("javassist.util.proxy.ProxyObject")) {
+ isJavassistProxy = true;
+ break;
}
}
-
- if (isCglibProxy) {
+
+ if (isCglibProxy || isJavassistProxy) {
Class<?> superClazz = clazz.getSuperclass();
-
+
ObjectSerializer superWriter = getObjectWriter(superClazz);
config.put(clazz, superWriter);
return superWriter;
}
-
+
if (Proxy.isProxyClass(clazz)) {
config.put(clazz, config.createJavaBeanSerializer(clazz));
} else {

0 comments on commit 89f7096

Please sign in to comment.