alibaba / alibaba/fastjson2

不兼容历史代码 : java.lang.NoSuchFieldError: SupportClassForName

Open
#2,921 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

### 问题描述
*简要描述您碰到的问题。*
不兼容历史写法

### 环境信息
*请填写以下信息:*

- OS信息: [e.g.:CentOS 8.4.2105 4Core 3.10GHz 16 GB] windows
- JDK信息: [e.g.:Openjdk 1.8.0_312] jdk8
- 版本信息:[e.g.:Fastjson2 2.x.x] 2.0.49

### 重现步骤
*如何操作可以重现该问题:*
String json = "{\"sid\":\"416778900513344\",\"id\":\"AthenaQCTestW\",\"name\":\"AthenaQCTestW\",\"customerId\":\"01042\",\"enterpriseType\":1,\"potentialCustomerId\":\"\",\"defaultLanguage\":\"zh_CN\",\"isv\":false,\"teamId\":\"3\",\"teamName\":\"第三方开发团队\",\"experience\":false,\"testTenant\":false,\"confirm\":1}";

IamTenantDto iamTenantDto = JSON.parseObject(json, IamTenantDto.class);

@Setter
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class IamTenantDto {
private String sid;
private String id;
private String name;
private String customerId;
/**
* 0表示外部租户 其实代表内部租户
*/
private Integer enterpriseType;
private String potentialCustomerId;
private String defaultLanguage;
private boolean isv;
private String teamId;
private String teamName;
private boolean experience;
private boolean testTenant;
private Integer confirm;
}

### 期待的正确结果
*对您期望发生的结果进行清晰简洁的描述。*
能兼容历史代码

### 相关日志输出
*请复制并粘贴任何相关的日志输出。*
Exception in thread "main" java.lang.NoSuchFieldError: SupportClassForName
at com.alibaba.fastjson.JSON.createReadContext(JSON.java:123)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:507)

#### 附加信息
*如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。*

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the JDK 8 failure with fastjson2 2.0.49 and the supplied IamTenantDto example, then read the JSON.createReadContext and JSON.parseObject entry points named in the stack trace. Trace the missing SupportClassForName compatibility path; done means the historical usage parses successfully without NoSuchFieldError.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.