Eahau

Results 6 comments of Eahau

看异常的堆栈,应该是该集合是只读不可写的,所以你可以换成别的可写的集合。

> 感觉和fastjson初始化的方法有关系,如果是直接把填好值的数组给到类的构造器就可以,fastjson貌似是先构造数组然后向数组内填值所以遇到不可以改变的集合就会报错,感觉这种情况有时候会碰到,就是有时候我需要的就是一个初始化时就确定好不变的集合 你的想法是好的。但是我还是建议你先在 getter 方法处返回为不可变集合,先解决眼下的问题。

源码由于用到了数组,所以判断了 index 不能为负数 https://github.com/alibaba/fastjson2/blob/c86bb8082c7ab2d5efbc04cb6063b6726d84c613/core/src/main/java/com/alibaba/fastjson2/reader/ObjectReaderImplEnum.java#L235-L240 你可以自定义枚举的反序列化,代码如下: ```java ParserConfig.getGlobalInstance().putDeserializer(EnumClass.class, new ObjectDeserializer() { @SuppressWarnings("unchecked") @Override public T deserialze(final DefaultJSONParser parser, final Type type, final Object fieldName) { Integer intValue = parser.parseObject(int.class); if (intValue...

> This seems entirely expected, but I didn't see the same error when I tried it with an empty project from start.spring.io. Whether it can be fixed or not I...

> BTW why did you exclude spring-context from the dependencies (shouldn't be necessary)? `spring-boot 3.0.1` need `spring-context 6.0.3`, but `spring-guice 2.0.2` need `spring-context 5.3.16` This should have no impact.