[BUG] 对多层嵌套的List进行toJSONString时发生异常:HV000116: getParameterIndex() may only be invoked for nodes of type ElementKind.PARAMETER
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述


这一样一个正常的List进行JSONObject.toJSONString时发生异常:Exception in thread "main" java.lang.IllegalArgumentException: HV000116: getParameterIndex() may only be invoked for nodes of type ElementKind.PARAMETER
### 环境信息
*请填写以下信息:*
- OS信息: windows10
- JDK信息:
-

- 版本信息:
-
com.alibaba.fastjson2
fastjson2
2.0.31
### 重现步骤
*如何操作可以重现该问题:*
1. 使用 `xxx.xxx` 方法
2. 输入 `...` 数据
3. 出现 `...` 错误
```java
//可在此输入示例代码
```
### 期待的正确结果
*对您期望发生的结果进行清晰简洁的描述。*
### 相关日志输出
Exception in thread "main" java.lang.IllegalArgumentException: HV000116: getParameterIndex() may only be invoked for nodes of type ElementKind.PARAMETER.
at org.hibernate.validator.internal.util.Contracts.assertTrue(Contracts.java:67)
at org.hibernate.validator.internal.engine.path.NodeImpl.getParameterIndex(NodeImpl.java:366)
at com.alibaba.fastjson2.writer.OWG_2_12_NodeImpl.write(Unknown Source)
at com.alibaba.fastjson2.writer.OWG_1_3_PathImpl.write(Unknown Source)
at com.alibaba.fastjson2.writer.ObjectWriterImplMap.write(ObjectWriterImplMap.java:550)
at com.alibaba.fastjson2.writer.ObjectWriterImplList.write(ObjectWriterImplList.java:373)
at com.alibaba.fastjson2.writer.ObjectWriterImplMap.write(ObjectWriterImplMap.java:550)
at com.alibaba.fastjson2.writer.ObjectWriterImplList.write(ObjectWriterImplList.java:373)
at com.alibaba.fastjson2.JSON.toJSONString(JSON.java:2453)
at com.alibaba.fastjson2.JSONObject.toJSONString(JSONObject.java:1142)
at com.k1k.wonderland.common.util.ValidUtil.validChecker(ValidUtil.java:37)
at com.k1k.wonderland.ybd.secure_checker.SecureChecker.main(SecureChecker.java:51)
Disconnected from the target VM, address: '127.0.0.1:52957', transport: 'socket'
#### 附加信息
*如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。*
Contributor guide
Research direction
Start at JSON.toJSONString and JSONObject.toJSONString, then trace the stack through ObjectWriterImplList.java, ObjectWriterImplMap.java, and the generated OWG_* writers. Reproduce the nested List failure using fastjson2 2.0.31 and inspect why NodeImpl.getParameterIndex() is called for a non-parameter node. Done means nested-list serialization completes without the exception and a regression test covers it.
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
- 35/100