You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*com.truckerpath.vip.utils.SubscriptionGoodsUtil$GoodUpdatedCheck
Exception in thread "main" java.lang.UnsupportedOperationException: can't get field offset on a record class: private final boolean *.SubscriptionGoodsUtil$GoodUpdatedCheck.isChangeSubscriptionGood
at jdk.unsupported/sun.misc.Unsafe.objectFieldOffset(Unsafe.java:655)
at com.alibaba.fastjson2.writer.FieldWriter.(FieldWriter.java:118)
at com.alibaba.fastjson2.writer.FieldWriterBoolean.(FieldWriterBoolean.java:32)
at com.alibaba.fastjson2.writer.FieldWriterBoolMethod.(FieldWriterBoolMethod.java:21)
at com.alibaba.fastjson2.writer.ObjectWriterCreator.createFieldWriter(ObjectWriterCreator.java:933)
at com.alibaba.fastjson2.writer.ObjectWriterCreatorASM.lambda$createObjectWriter$1(ObjectWriterCreatorASM.java:330)
at com.alibaba.fastjson2.util.BeanUtils.getters(BeanUtils.java:1040)
at com.alibaba.fastjson2.writer.ObjectWriterCreatorASM.createObjectWriter(ObjectWriterCreatorASM.java:237)
at com.alibaba.fastjson2.writer.ObjectWriterProvider.getObjectWriterInternal(ObjectWriterProvider.java:462)
at com.alibaba.fastjson2.writer.ObjectWriterProvider.getObjectWriter(ObjectWriterProvider.java:340)
at com.alibaba.fastjson2.JSON.toJSONString(JSON.java:3021)
at com.truckerpath.vip.utils.SubscriptionGoodsUtil$GoodUpdatedCheck.main(SubscriptionGoodsUtil.java:101)
*
问题描述
针对Record类,boolean类型,JSON.toJSONString()报错
环境信息
请填写以下信息:
重现步骤
期待的正确结果
正确JSON格式化
相关日志输出
*com.truckerpath.vip.utils.SubscriptionGoodsUtil$GoodUpdatedCheck
Exception in thread "main" java.lang.UnsupportedOperationException: can't get field offset on a record class: private final boolean *.SubscriptionGoodsUtil$GoodUpdatedCheck.isChangeSubscriptionGood
at jdk.unsupported/sun.misc.Unsafe.objectFieldOffset(Unsafe.java:655)
at com.alibaba.fastjson2.writer.FieldWriter.(FieldWriter.java:118)
at com.alibaba.fastjson2.writer.FieldWriterBoolean.(FieldWriterBoolean.java:32)
at com.alibaba.fastjson2.writer.FieldWriterBoolMethod.(FieldWriterBoolMethod.java:21)
at com.alibaba.fastjson2.writer.ObjectWriterCreator.createFieldWriter(ObjectWriterCreator.java:933)
at com.alibaba.fastjson2.writer.ObjectWriterCreatorASM.lambda$createObjectWriter$1(ObjectWriterCreatorASM.java:330)
at com.alibaba.fastjson2.util.BeanUtils.getters(BeanUtils.java:1040)
at com.alibaba.fastjson2.writer.ObjectWriterCreatorASM.createObjectWriter(ObjectWriterCreatorASM.java:237)
at com.alibaba.fastjson2.writer.ObjectWriterProvider.getObjectWriterInternal(ObjectWriterProvider.java:462)
at com.alibaba.fastjson2.writer.ObjectWriterProvider.getObjectWriter(ObjectWriterProvider.java:340)
at com.alibaba.fastjson2.JSON.toJSONString(JSON.java:3021)
at com.truckerpath.vip.utils.SubscriptionGoodsUtil$GoodUpdatedCheck.main(SubscriptionGoodsUtil.java:101)
*
附加信息
报错位置:当boolean类型时,field != null, 所以会进行UNSAFE.objectFieldOffset(field); 由于class为record类,所以导致报错
而Boolean类型,field == null,不会使用UNSAFE.objectFieldOffset(field);所以可以正常进行格式化,具体feild入值,针对boolean类型有特殊的判断,不知道为了解决什么问题
The text was updated successfully, but these errors were encountered: