alibaba / alibaba/fastjson2

[BUG] 在agent包里使用JSON.toJSONString()报异常

Open
#3,555 1 comment 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

### 问题描述

在agent包里使用JSON.toJSONString()报异常 :
Could not initialize class com.alibaba.fastjson2.JSONFactory

### 环境信息
- JDK信息:openjdk21
- 版本信息:fastjson2-2.0.53

### 重现步骤
写一个agent项目, 依赖加入fastjson2-2.0.53, 然后打包(使用maven-shade-plugin重命名或者不重命令都一样的问题).
在其他工程使用`-javaagent:`此包启动, 然后在JSON.toJSONString()方法报上面的异常.
使用gson或者jackson正常.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure in a Java agent project using fastjson2-2.0.53 on OpenJDK 21, with and without maven-shade-plugin renaming. Start from JSON.toJSONString() and the reported com.alibaba.fastjson2.JSONFactory initialization failure. Done means the agent can call JSON.toJSONString() without the exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.