[BUG] 使用fastjson2 中的Autotype,无法自动执行getter setter
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
*简要描述您碰到的问题。*
在正常使用@type的过程中,无法自动执行getter and setter
### 环境信息
*请填写以下信息:*
- OS信息: win10
- JDK信息: 1.8
- 版本信息:fastjson 2.0.37
### 重现步骤
*如何操作可以重现该问题:*
使用java 代码后,测试执行,只执行setter
JSON.parse(body, new Feature[]{Feature.SupportAutoType});
开启 AutoType
使用
{
"@type": "com.example.demos.web.User",
"name":"test"
}
输出
setName() is called
```java
public class User {
private String name;
public User() {
}
public User(String name) {
this.name = name;
}
public String getName() {
System.out.println("getName() is called");
return name;
}
public void setName(String name) {
System.out.println("setName() is called");
this.name = name;
}
}
```
### 期待的正确结果
*对您期望发生的结果进行清晰简洁的描述。*
自动执行 getter and setter
### 相关日志输出
*请复制并粘贴任何相关的日志输出。*
#### 附加信息
*如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。*
Contributor guide
Research direction
Start with the Java reproduction using JSON.parse(body, new Feature[]{Feature.SupportAutoType}) and the provided User class, then inspect fastjson2's AutoType deserialization behavior. The issue does not name source files or tests; completion requires clarifying whether getter invocation during deserialization is intended and defining a regression case for the expected getter/setter calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100