mirror of
https://github.com/alibaba/fastjson.git
synced 2026-10-28 13:50:47 +08:00
@@ -1162,6 +1162,41 @@ public class TypeUtils {
|
||||
}
|
||||
}
|
||||
|
||||
Class<?> superClass = clazz.getSuperclass();
|
||||
if (superClass == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Modifier.isAbstract(superClass.getModifiers())) {
|
||||
Class<?>[] types = method.getParameterTypes();
|
||||
|
||||
for (Method interfaceMethod : superClass.getMethods()) {
|
||||
Class<?>[] interfaceTypes = interfaceMethod.getParameterTypes();
|
||||
if (interfaceTypes.length != types.length) {
|
||||
continue;
|
||||
}
|
||||
if (!interfaceMethod.getName().equals(method.getName())) {
|
||||
continue;
|
||||
}
|
||||
boolean match = true;
|
||||
for (int i = 0; i < types.length; ++i) {
|
||||
if (!interfaceTypes[i].equals(types[i])) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
continue;
|
||||
}
|
||||
|
||||
JSONField annotation = interfaceMethod.getAnnotation(JSONField.class);
|
||||
if (annotation != null) {
|
||||
return annotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.alibaba.json.bvt.bug;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by wenshao on 2016/11/13.
|
||||
*/
|
||||
public class Issue744 extends TestCase {
|
||||
|
||||
public static class Model {
|
||||
@JSONField(format="yyyy-MM-dd'T'HH:mm:ss")
|
||||
public Date date;
|
||||
}
|
||||
|
||||
public void test() {
|
||||
String text = "{\"date\":\"9999-09-08T00:00:00\"}";
|
||||
Model model =JSON.parseObject(text, Model.class);
|
||||
|
||||
String text2 = JSON.toJSONString(model);
|
||||
System.out.println(text2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.alibaba.json.bvt.bug;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Created by wenshao on 2016/11/13.
|
||||
*/
|
||||
public class Issue744_1 extends TestCase {
|
||||
|
||||
public void test_for_issue() throws Exception {
|
||||
C c = new C();
|
||||
c.setName("name");
|
||||
|
||||
String json = JSON.toJSONString(c);
|
||||
assertEquals("{}", json);
|
||||
}
|
||||
|
||||
public static abstract class B {
|
||||
@JSONField(serialize = false, deserialize = false)
|
||||
public abstract String getName();
|
||||
|
||||
}
|
||||
|
||||
public static class C extends B {
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user