This pull request fixes compatibility with Java 17 by making the SetTargetToNearbyBlockAwayFromInstigatorAction#random field transient. This prevents it from being serialised.
Without this change the game fails to run with this module before with the error:
16:40:49.369 [main] ERROR o.t.engine.core.modes.StateLoading - Error while loading org.terasology.engine.core.modes.loadProcesses.LoadPrefabs@1b949de4
com.google.gson.JsonIOException: Failed making field 'java.util.Random#seed' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type.
at com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:38)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:286)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130)
at com.google.gson.Gson.getAdapter(Gson.java:556)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:160)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:294)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130)
at com.google.gson.Gson.getAdapter(Gson.java:556)
at com.google.gson.Gson.fromJson(Gson.java:1226)
at com.google.gson.Gson.fromJson(Gson.java:1329)
at com.google.gson.Gson.fromJson(Gson.java:1300)
at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:179)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.getPrimitiveNode(BehaviorTreeBuilder.java:200)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:144)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:48)
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:76)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
at com.google.gson.Gson.fromJson(Gson.java:1227)
at com.google.gson.Gson.fromJson(Gson.java:1329)
at com.google.gson.Gson.fromJson(Gson.java:1300)
at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:179)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.getCompositeNode(BehaviorTreeBuilder.java:236)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:146)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:48)
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:76)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
at com.google.gson.Gson.fromJson(Gson.java:1227)
at com.google.gson.Gson.fromJson(Gson.java:1329)
at com.google.gson.Gson.fromJson(Gson.java:1300)
at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:179)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.getCompositeNode(BehaviorTreeBuilder.java:236)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:146)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:48)
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:76)
at com.google.gson.Gson.fromJson(Gson.java:1227)
at com.google.gson.Gson.fromJson(Gson.java:1137)
at com.google.gson.Gson.fromJson(Gson.java:1075)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.fromJson(BehaviorTreeBuilder.java:92)
at org.terasology.engine.logic.behavior.asset.BehaviorTreeFormat.load(BehaviorTreeFormat.java:67)
at org.terasology.engine.logic.behavior.asset.BehaviorTreeFormat.load(BehaviorTreeFormat.java:55)
at org.terasology.engine.logic.behavior.asset.BehaviorTreeFormat.load(BehaviorTreeFormat.java:30)
at org.terasology.gestalt.assets.format.producer.UnloadedAssetData$AssetSourceResolver.load(UnloadedAssetData.java:311)
at org.terasology.gestalt.assets.format.producer.UnloadedAssetData.load(UnloadedAssetData.java:181)
at org.terasology.gestalt.assets.format.producer.AssetFileDataProducer.getAssetData(AssetFileDataProducer.java:227)
at org.terasology.gestalt.assets.AssetType.lambda$reload$2(AssetType.java:360)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
at org.terasology.gestalt.assets.AssetType.reload(AssetType.java:358)
at org.terasology.gestalt.assets.AssetType.getNormalAsset(AssetType.java:387)
at org.terasology.gestalt.assets.AssetType.getAsset(AssetType.java:265)
at org.terasology.gestalt.assets.management.AssetManager.getAsset(AssetManager.java:225)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder$1.read(BehaviorTreeBuilder.java:131)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder$1.read(BehaviorTreeBuilder.java:116)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.readIntoField(ReflectiveTypeAdapterFactory.java:212)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$FieldReflectionAdapter.readField(ReflectiveTypeAdapterFactory.java:433)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:393)
at com.google.gson.Gson.fromJson(Gson.java:1227)
at com.google.gson.Gson.fromJson(Gson.java:1329)
at com.google.gson.Gson.fromJson(Gson.java:1300)
at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:179)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.getCompositeNode(BehaviorTreeBuilder.java:227)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:146)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:48)
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:76)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
at com.google.gson.Gson.fromJson(Gson.java:1227)
at com.google.gson.Gson.fromJson(Gson.java:1329)
at com.google.gson.Gson.fromJson(Gson.java:1300)
at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:179)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.getCompositeNode(BehaviorTreeBuilder.java:236)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:146)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:48)
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:76)
at com.google.gson.Gson.fromJson(Gson.java:1227)
at com.google.gson.Gson.fromJson(Gson.java:1329)
at com.google.gson.Gson.fromJson(Gson.java:1300)
at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:179)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.getCompositeNode(BehaviorTreeBuilder.java:233)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:146)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:48)
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:76)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
at com.google.gson.Gson.fromJson(Gson.java:1227)
at com.google.gson.Gson.fromJson(Gson.java:1329)
at com.google.gson.Gson.fromJson(Gson.java:1300)
at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:179)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.getCompositeNode(BehaviorTreeBuilder.java:236)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:146)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.deserialize(BehaviorTreeBuilder.java:48)
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:76)
at com.google.gson.Gson.fromJson(Gson.java:1227)
at com.google.gson.Gson.fromJson(Gson.java:1137)
at com.google.gson.Gson.fromJson(Gson.java:1075)
at org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder.fromJson(BehaviorTreeBuilder.java:92)
at org.terasology.engine.logic.behavior.asset.BehaviorTreeFormat.load(BehaviorTreeFormat.java:67)
at org.terasology.engine.logic.behavior.asset.BehaviorTreeFormat.load(BehaviorTreeFormat.java:55)
at org.terasology.engine.logic.behavior.asset.BehaviorTreeFormat.load(BehaviorTreeFormat.java:30)
at org.terasology.gestalt.assets.format.producer.UnloadedAssetData$AssetSourceResolver.load(UnloadedAssetData.java:311)
at org.terasology.gestalt.assets.format.producer.UnloadedAssetData.load(UnloadedAssetData.java:181)
at org.terasology.gestalt.assets.format.producer.AssetFileDataProducer.getAssetData(AssetFileDataProducer.java:227)
at org.terasology.gestalt.assets.AssetType.lambda$reload$2(AssetType.java:360)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
at org.terasology.gestalt.assets.AssetType.reload(AssetType.java:358)
at org.terasology.gestalt.assets.AssetType.getNormalAsset(AssetType.java:387)
at org.terasology.gestalt.assets.AssetType.getAsset(AssetType.java:265)
at org.terasology.gestalt.assets.management.AssetManager.getAsset(AssetManager.java:225)
at org.terasology.gestalt.assets.management.AssetManager.getAsset(AssetManager.java:205)
at org.terasology.gestalt.assets.management.AssetManager.getAsset(AssetManager.java:189)
at org.terasology.engine.utilities.Assets.get(Assets.java:68)
at org.terasology.engine.persistence.typeHandling.extensionTypes.AssetTypeHandler.getFromString(AssetTypeHandler.java:33)
at org.terasology.engine.persistence.typeHandling.extensionTypes.AssetTypeHandler.getFromString(AssetTypeHandler.java:13)
at org.terasology.persistence.typeHandling.StringRepresentationTypeHandler.deserialize(StringRepresentationTypeHandler.java:22)
at org.terasology.persistence.typeHandling.TypeHandler.deserializeOrNull(TypeHandler.java:55)
at org.terasology.persistence.typeHandling.Serializer.deserializeOnto(Serializer.java:83)
at org.terasology.persistence.typeHandling.Serializer.deserializeOnto(Serializer.java:140)
at org.terasology.engine.persistence.serializers.ComponentSerializer.deserializeOnto(ComponentSerializer.java:185)
at org.terasology.engine.persistence.serializers.ComponentSerializer.deserialize(ComponentSerializer.java:101)
at org.terasology.engine.persistence.serializers.PrefabSerializer.applyComponentChanges(PrefabSerializer.java:152)
at org.terasology.engine.persistence.serializers.PrefabSerializer.deserialize(PrefabSerializer.java:124)
at org.terasology.engine.persistence.serializers.PrefabSerializer.deserialize(PrefabSerializer.java:104)
at org.terasology.engine.entitySystem.prefab.internal.PrefabFormat.load(PrefabFormat.java:45)
at org.terasology.engine.entitySystem.prefab.internal.PrefabFormat.load(PrefabFormat.java:23)
at org.terasology.gestalt.assets.format.producer.UnloadedAssetData$AssetSourceResolver.load(UnloadedAssetData.java:311)
at org.terasology.gestalt.assets.format.producer.UnloadedAssetData.load(UnloadedAssetData.java:181)
at org.terasology.gestalt.assets.format.producer.AssetFileDataProducer.getAssetData(AssetFileDataProducer.java:227)
at org.terasology.gestalt.assets.AssetType.lambda$reload$2(AssetType.java:360)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
at org.terasology.gestalt.assets.AssetType.reload(AssetType.java:358)
at org.terasology.gestalt.assets.AssetType.getNormalAsset(AssetType.java:387)
at org.terasology.gestalt.assets.AssetType.getAsset(AssetType.java:265)
at org.terasology.gestalt.assets.management.AssetManager.getAsset(AssetManager.java:225)
at org.terasology.engine.core.modes.loadProcesses.LoadPrefabs.step(LoadPrefabs.java:30)
at org.terasology.engine.core.modes.StateLoading.update(StateLoading.java:259)
at org.terasology.engine.core.TerasologyEngine.tick(TerasologyEngine.java:512)
at org.terasology.engine.core.TerasologyEngine.mainLoop(TerasologyEngine.java:472)
at org.terasology.engine.core.TerasologyEngine.runMain(TerasologyEngine.java:448)
at org.terasology.engine.core.TerasologyEngine.run(TerasologyEngine.java:414)
at org.terasology.engine.Terasology.call(Terasology.java:189)
at org.terasology.engine.Terasology.call(Terasology.java:69)
at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
at picocli.CommandLine.access$1200(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
at picocli.CommandLine.execute(CommandLine.java:2058)
at org.terasology.engine.Terasology.main(Terasology.java:138)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.concurrent.atomic.AtomicLong java.util.Random.seed accessible: module java.base does not "opens java.util" to unnamed module @428640fa
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:35)
... 153 common frames omitted
This pull request fixes compatibility with Java 17 by making the
SetTargetToNearbyBlockAwayFromInstigatorAction#random
field transient. This prevents it from being serialised.Without this change the game fails to run with this module before with the error: