错误尝试将其序列化为 Json,但如果我不添加笼子,错误就不会发生。

huangapple go评论63阅读模式
英文:

Error trying to serialize to Json but error does not happen if I don't add cages

问题

[19:44:33 ERROR]: Could not pass event InventoryClickEvent to LuckyWars v1.0.0
org.bukkit.event.EventException: null
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:564) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:549) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1681) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(PacketPlayInWindowClick.java:17) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(PacketPlayInWindowClick.java:5) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(PlayerConnectionUtils.java:9) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
at net.minecraft.server.v1_8_R3.SystemUtils.a(SystemUtils.java:11) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:880) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:412) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:814) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:647) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.MinecraftServer.lambda$spin$0(MinecraftServer.java:133) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.TaskQueue java.util.Timer.queue accessible: module java.base does not "opens java.util" to unnamed module @6cf0e0ba
at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) ~[?:?]
at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) ~[?:?]
at java.lang.reflect.Field.checkCanSetAccessible(Field.java:178) ~[?:?]
at java.lang.reflect.Field.setAccessible(Field.java:172) ~[?:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:140) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:83) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.Gson.getAdapter(Gson.java:359) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:122) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:46) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:92) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:91) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:142) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:83) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.Gson.getAdapter(Gson.java:359) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:122) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:46) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:92) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:91) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:142) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveType

英文:
[19:44:33 ERROR]: Could not pass event InventoryClickEvent to LuckyWars v1.0.0
org.bukkit.event.EventException: null
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:564) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:549) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1681) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(PacketPlayInWindowClick.java:17) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(PacketPlayInWindowClick.java:5) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(PlayerConnectionUtils.java:9) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
at net.minecraft.server.v1_8_R3.SystemUtils.a(SystemUtils.java:11) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:880) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:412) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:814) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:647) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at net.minecraft.server.v1_8_R3.MinecraftServer.lambda$spin$0(MinecraftServer.java:133) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.TaskQueue java.util.Timer.queue accessible: module java.base does not &quot;opens java.util&quot; to unnamed module @6cf0e0ba
at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) ~[?:?]
at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) ~[?:?]
at java.lang.reflect.Field.checkCanSetAccessible(Field.java:178) ~[?:?]
at java.lang.reflect.Field.setAccessible(Field.java:172) ~[?:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:140) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:83) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.Gson.getAdapter(Gson.java:359) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:122) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:46) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.&lt;init&gt;(ReflectiveTypeAdapterFactory.java:92) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:91) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:142) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:83) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.Gson.getAdapter(Gson.java:359) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:122) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:46) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.&lt;init&gt;(ReflectiveTypeAdapterFactory.java:92) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:91) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:142) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:83) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.Gson.getAdapter(Gson.java:359) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:122) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:46) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.&lt;init&gt;(ReflectiveTypeAdapterFactory.java:92) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:91) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:142) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:83) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.Gson.getAdapter(Gson.java:359) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:122) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:46) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.&lt;init&gt;(ReflectiveTypeAdapterFactory.java:92) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:91) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:142) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:83) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.Gson.getAdapter(Gson.java:359) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:55) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:99) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:219) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:68) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:99) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:219) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:68) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:96) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:60) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:68) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:99) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:219) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.Gson.toJson(Gson.java:600) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.Gson.toJson(Gson.java:579) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.Gson.toJson(Gson.java:534) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.google.gson.Gson.toJson(Gson.java:514) ~[patched_1.8.8.jar:git-PandaSpigot-82]
at com.luckywars.game.utils.MapDataSerializer.serialize(MapDataSerializer.java:12) ~[?:?]
at com.luckywars.game.database.dbs.MapDB.saveMapData(MapDB.java:40) ~[?:?]
at com.luckywars.game.setupwizard.Session.delete(Session.java:117) ~[?:?]
at com.luckywars.game.setupwizard.WizardManager.endSession(WizardManager.java:22) ~[?:?]
at com.luckywars.game.setupwizard.gui.ConfirmExitGui.handleClick(ConfirmExitGui.java:31) ~[?:?]
at com.luckywars.game.setupwizard.WizardListeners.onClick(WizardListeners.java:35) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) ~[patched_1.8.8.jar:git-PandaSpigot-82]
... 17 more

I tried printing the cuboid before the error happened and it printed fine.

I was expecting the cuboid to be null but it wasn't.

My MapData class:

`public class MapData {

public String name;
public List&lt;String&gt; authors;
public long lastEdit;
public List&lt;Pos&gt; luckyBlocks;
public List&lt;Pos&gt; spawnPoints;
public List&lt;Cuboid&gt; cages;
public Pos spectatorSpawn;
public MapData(String name, List&lt;String&gt; authors, long lastEdit, List&lt;Pos&gt; luckyBlocks, List&lt;Pos&gt; spawnPoints, List&lt;Cuboid&gt; cages, Pos spectatorSpawn) {
this.name = name;
this.authors = authors;
this.lastEdit = lastEdit;
this.luckyBlocks = luckyBlocks;
this.spawnPoints = spawnPoints;
this.cages = cages;
this.spectatorSpawn = spectatorSpawn;
}
public String getName() {
return name;
}
public List&lt;Pos&gt; getSpawnPoints() {
return spawnPoints;
}
public List&lt;Cuboid&gt; getCages() {
return cages;
}
public List&lt;Pos&gt; getLuckyBlocks() {
return luckyBlocks;
}
public List&lt;String&gt; getAuthors() {
return authors;
}
public long getLastEdit() {
return lastEdit;
}
public void setLastEdit(long lastEdit) {
this.lastEdit = lastEdit;
}
public Pos getSpectatorSpawn() {
return spectatorSpawn;
}
public void setSpectatorSpawn(Pos spectatorSpawn) {
this.spectatorSpawn = spectatorSpawn;
}

}

My Session class:

addCage method:

public void addCage() {
SelectionManager selectionManager = LuckyWars.getInstance().getSelectionManager();
Selection selection = selectionManager.getSelection(player.getUniqueId());

    if (selection == null) {
player.sendMessage(MessageUtils.format(&quot;&amp;cYou have not even made any selections at all! make one by using the loc wand!&quot;));
return;
}
Location location1 = selection.getFirstPos();
Location location2 = selection.getSecondPos();
if (location1 == null) {
player.sendMessage(MessageUtils.format(&quot;&amp;cYour first pos selection is null!&quot;));
return;
}
if (location2 == null){
player.sendMessage(MessageUtils.format(&quot;&amp;cYour second pos selection is null!&quot;));
return;
}
if (data.cages.size() == GameMode.SOLO.getMaxPlayers()) {
player.sendMessage(MessageUtils.format(&quot;&amp;cYou cant add more than &quot; + GameMode.SOLO.getMaxPlayers() + &quot; cages!&quot;));
return;
}
Cuboid cuboid = new Cuboid(location1, location2, false);
this.data.getCages().add(cuboid);
player.sendMessage(MessageUtils.format(&quot;&amp;aSuccessfully added a cage!&quot;));
if (LuckyWars.getInstance().isDebugMessages()) {
System.out.println(cuboid);
}
}`

session line from error:

if(save){
data.setLastEdit(System.currentTimeMillis());
LuckyWars.getInstance().getMapDB().saveMapData(data.getName(), data);
}

答案1

得分: 1

这里的关键问题是:
java.lang.reflect.InaccessibleObjectException: 无法将字段 private final java.util.TaskQueue java.util.Timer.queue 设为可访问:模块 java.base 未“opens java.util”给未命名模块

可能是你的某个类(可能是Cuboid)传递性地具有一个java.util.Timer的值,你(不小心?)试图使用Gson进行序列化。因为Gson没有Timer的内置适配器,它尝试使用反射,在最新的JDK版本中,这对于JDK类来说会失败。一般来说,你应该避免依赖于基于反射的Gson适配器来处理第三方类,因为这会使你依赖于这些类的实现细节,而这些细节随时可能发生变化。

为了解决这个问题,你要么需要编写一个自定义的Gson TypeAdapter来序列化Timer的值,要么将其排除在序列化之外(例如将字段设为transient)。更多信息请参阅故障排除指南

英文:

The important line here is:

java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.TaskQueue java.util.Timer.queue accessible: module java.base does not &quot;opens java.util&quot; to unnamed module

Probably one of your classes (maybe Cuboid) has transitively a java.util.Timer value which you are (accidentally?) trying to serialize with Gson. Because Gson has no built-in adapter for Timer it tries to use reflection which fails for JDK classes in the latest JDK versions. In general you should avoid relying on the reflection-based Gson adapter for third-party classes because it makes you dependent on the implementation details of those classes, which could change at any time.

To solve this, you either have to write a custom Gson TypeAdapter which serializes the Timer value, or exclude it from serialization (e.g. making the field transient). See the troubleshooting guide for more information.

huangapple
  • 本文由 发表于 2023年3月12日 15:24:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75711623.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定