[BUG] IBM JRE 下Object序列化的结果不正确,包含多余的\u0000
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
在IBM JRE下面对Object进行序列化时结果不正确,包含有多余的\u0000,在Oracle JRE下无此问题。
### 环境信息
- OS信息: Windows 10
- JDK信息: IBM JRE 1.8.0(IBM J9 VM (build 2.8, JRE 1.8.0 Windows 10 amd64-64 Compressed References 20161013_322271 (JIT enabled, AOT enabled))
- 版本信息:FastJson 2.0.40
### 重现步骤
按下面的代码在IBM JRE 下面运行百分之百重现。
```java
SessionData sessionData = new SessionData();
sessionData.setRefNo(UUID.randomUUID().toString());
long now = System.currentTimeMillis();
SimpleDateFormat yyyy_MM_dd_HH_mm_ss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String systemTime = yyyy_MM_dd_HH_mm_ss.format(now);
sessionData.setTime(systemTime);
String str = JSON.toJSONString(sessionData);
System.out.println(str);
```
### 期待的正确结果
序列化结果不应该包含 \u0000
### 相关日志输出
序列化的结果如下:
`{"refNo":"90da07bb-d144-479c-bea1-e8127ab100b3\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000","time":"2023-10-10 13:29:05\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"}`
#### 附加信息
期待尽快解决,谢谢
Contributor guide
Research direction
Start with the reported JSON.toJSONString(sessionData) reproduction and compare its behavior on IBM JRE 1.8.0 and Oracle JRE. Trace the object serialization path used by that entry point; done means the IBM JRE output matches the expected JSON and contains no \u0000 characters.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100