Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
bug fixed for public_field & getter diff type
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed May 20, 2016
1 parent 736e45b commit ed9758d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/com/alibaba/fastjson/util/FieldInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public FieldInfo(String name, //

if (field != null) {
int modifiers = field.getModifiers();
fieldAccess = method == null || (modifiers & Modifier.PUBLIC) != 0;
fieldAccess = method == null || ((modifiers & Modifier.PUBLIC) != 0 && method.getReturnType() == field.getType());
fieldTransient = (modifiers & Modifier.TRANSIENT) != 0;
} else {
fieldAccess = false;
Expand Down
26 changes: 26 additions & 0 deletions src/test/java/com/alibaba/json/bvt/bug/Bug_for_DiffType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.alibaba.json.bvt.bug;

import com.alibaba.fastjson.JSON;

import junit.framework.TestCase;

public class Bug_for_DiffType extends TestCase {
public void test_for_diff_type() throws Exception {
Model model = new Model();
model.setValue(1001);

JSON.toJSONString(model);
}

public static class Model {
public String value;

public long getValue() {
return Long.parseLong(value);
}

public void setValue(long value) {
this.value = Long.toString(value);
}
}
}

0 comments on commit ed9758d

Please sign in to comment.