Skip to content

java.lang.reflect.InaccessibleObjectException in 1.4.1 #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
InFerYes opened this issue Oct 12, 2021 · 6 comments
Closed

java.lang.reflect.InaccessibleObjectException in 1.4.1 #33

InFerYes opened this issue Oct 12, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@InFerYes
Copy link

InFerYes commented Oct 12, 2021

I have downloaded the jar file from releases and tried to run it. I get the following error:

[info] Amidst for Minetest v1.4-1
[info] Current system time: 2021-10-12 08:46:10.848
[info] System.getProperty("os.name") == 'Linux'
[info] System.getProperty("os.version") == '5.14.6-arch1-1'
[info] System.getProperty("os.arch") == 'amd64'
[info] System.getProperty("java.version") == '16.0.2'
[info] System.getProperty("java.vendor") == 'N/A'
[info] System.getProperty("sun.arch.data.model") == '64'
[info] Not using OpenGL.
[info] Biome profile activated: default
[info] using '.minecraft' directory at: '/home/user/.minecraft'
[info] Minetest directory not found, using default mapgen v7 profile
[info] using biome profiles at: 'biome'
[info] Starting to download remote version list.
[info] Found biome profile directory.
[info] Found default biome profile "Minetest Game v5"
[info] Found default biome profile "Minetest Game v.4"
[info] Found default biome profile "v6"
[info] Found default biome profile "30-biomes"
[info] Found default biome profile "Ethereal"
[info] Found default biome profile "Voxelgarden"
[info] Found default biome profile "Australia v0.4"
[info] Found default biome profile "MineClone 2"
[info] Found default biome profile "Aotearoa (New Zealand) v0.1"
[info] Biome profile activated: Minetest Game v5
[info] Checking for additional biome profiles.
[info] Found biome profile directory.
[info] Found default biome profile "Minetest Game v5"
[info] Found default biome profile "Minetest Game v.4"
[info] Found default biome profile "v6"
[info] Found default biome profile "30-biomes"
[info] Found default biome profile "Ethereal"
[info] Found default biome profile "Voxelgarden"
[info] Found default biome profile "Australia v0.4"
[info] Found default biome profile "MineClone 2"
[info] Found default biome profile "Aotearoa (New Zealand) v0.1"
[crash] Amidst has encounted an uncaught exception on the thread Thread[AWT-EventQueue-0,6,main]
[crash] java.lang.reflect.InaccessibleObjectException: Unable to make field int java.awt.Color.value accessible: module java.desktop does not "opens java.awt" to unnamed module @1500955a
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
	at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:154)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
	at com.google.gson.Gson.getAdapter(Gson.java:407)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:106)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
	at com.google.gson.Gson.getAdapter(Gson.java:407)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:106)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
	at com.google.gson.Gson.getAdapter(Gson.java:407)
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53)
	at com.google.gson.Gson.getAdapter(Gson.java:407)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:106)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
	at com.google.gson.Gson.getAdapter(Gson.java:407)
	at com.google.gson.Gson.fromJson(Gson.java:860)
	at com.google.gson.Gson.fromJson(Gson.java:799)
	at amidst.parsing.json.JsonReader.readReader(JsonReader.java:41)
	at amidst.parsing.json.JsonReader.readLocation(JsonReader.java:25)
	at amidst.settings.biomeprofile.BiomeProfileDirectory.createFromFile(BiomeProfileDirectory.java:298)
	at amidst.settings.biomeprofile.BiomeProfileDirectory.visitProfiles(BiomeProfileDirectory.java:245)
	at amidst.settings.biomeprofile.BiomeProfileDirectory.visitProfiles(BiomeProfileDirectory.java:237)
	at amidst.gui.main.menu.BiomeProfileMenuFactory.initParentMenu(BiomeProfileMenuFactory.java:169)
	at amidst.gui.main.menu.BiomeProfileMenuFactory.<init>(BiomeProfileMenuFactory.java:161)
	at amidst.gui.main.menu.AmidstMenuBuilder.create_Settings_BiomeProfile(AmidstMenuBuilder.java:162)
	at amidst.gui.main.menu.AmidstMenuBuilder.create_Settings(AmidstMenuBuilder.java:129)
	at amidst.gui.main.menu.AmidstMenuBuilder.createMenuBar(AmidstMenuBuilder.java:54)
	at amidst.gui.main.menu.AmidstMenuBuilder.<init>(AmidstMenuBuilder.java:36)
	at amidst.gui.main.PerMainWindowInjector.<init>(PerMainWindowInjector.java:118)
	at amidst.PerApplicationInjector.createMainWindow(PerApplicationInjector.java:122)
	at amidst.Application.displayMainWindow(Application.java:73)
	at amidst.Application.run(Application.java:55)
	at amidst.Amidst.doStartApplication(Amidst.java:171)
	at amidst.Amidst.lambda$startApplication$0(Amidst.java:162)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:316)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)


OS: Arch Linux
Kernel: x86_64 Linux 5.14.6-arch1-1
DE: GNOME 40.0
CPU: Intel Core i5-7600K @ 4x 4.2GHz [39.0°C]
GPU: NVIDIA GeForce GTX 1060 3GB
RAM: 15963MiB
openjdk version "16.0.2" 2021-07-20
OpenJDK Runtime Environment (build 16.0.2+7)
OpenJDK 64-Bit Server VM (build 16.0.2+7, mixed mode)

@Treer
Copy link
Owner

Treer commented Oct 13, 2021

It sounds like there's a new restriction in the latest JDK and they've added an --add-opens runtime option to relax it, so

--add-opens java.desktop/java.awt=ALL-UNNAMED

might be a workaround.

Long term, code using Gson will have to be examined

@Treer Treer added the bug Something isn't working label Oct 13, 2021
@InFerYes
Copy link
Author

How do I apply this option?

java -jar --add-opens=java.desktop/java.awt=ALL-UNNAMED amidst-minetest-v1-4-1.jar yields the same error.

I also just noticed the output says it couldn't find the minetest folder, which is /home/user/.minetest, however it does find .minecraft. I'm intending to use this tool on my Minetest world.

@Treer
Copy link
Owner

Treer commented Oct 13, 2021

Don't worry about the minecraft stuff, or the minetest folder not found.

It shouldn't go between the jar settings, so either:
java --add-opens java.desktop/java.awt=ALL-UNNAMED -jar amidst-minetest-v1-4-1.jar
or
java -jar amidst-minetest-v1-4-1.jar --add-opens java.desktop/java.awt=ALL-UNNAMED

if it still crashes, check if these bolded parts of the error have changed:
[crash] java.lang.reflect.InaccessibleObjectException: Unable to make field int java.awt.Color.value accessible: module java.desktop does not "opens java.awt" to unnamed module @1500955a

as those are what I put in the --add-opens command, and perhaps the command worked and got it further until hitting a new InaccessibleObject.

@Treer
Copy link
Owner

Treer commented Oct 13, 2021

whoops, it should be --add-opens java.desktop/java.awt=ALL-UNNAMED

i.e. no equals after --add-opens, so try:
java -jar amidst-minetest-v1-4-1.jar --add-opens java.desktop/java.awt=ALL-UNNAMED

(I've just edited my comments because I'm pretty sure there's supposed to be a space after the --add-opens)

@InFerYes
Copy link
Author

InFerYes commented Oct 13, 2021

the --add-opens needs to come before the jar it seems, otherwise amidst tries to use it as parameter:

java -jar amidst-minetest-v1-4-1.jar --add-opens java.desktop/java.awt=ALL-UNNAMED
Amidst for Minetest v1.4-1
"--add-opens" is not a valid option
 -mtpath <directory>         : location of the minetest directory.
 -mcpath <directory>         : location of the '.minecraft' directory.
 -mcjar <file>               : location of the minecraft jar file
 -mcjson <file>              : location of the minecraft json file
 -biome-profiles <directory> : location of the biome profile directory
 -history <file>             : location of the seed history file
 -log <file>                 : location of the log file
 -help                       : print usage information
 -version                    : print version

The result is:

[info] Amidst for Minetest v1.4-1
[info] Current system time: 2021-10-13 12:06:42.609
[info] System.getProperty("os.name") == 'Linux'
[info] System.getProperty("os.version") == '5.14.6-arch1-1'
[info] System.getProperty("os.arch") == 'amd64'
[info] System.getProperty("java.version") == '16.0.2'
[info] System.getProperty("java.vendor") == 'N/A'
[info] System.getProperty("sun.arch.data.model") == '64'
[info] Not using OpenGL.
[info] Biome profile activated: default
[info] using '.minecraft' directory at: '/home/user/.minecraft'
[info] Minetest directory not found, using default mapgen v7 profile
[info] using biome profiles at: 'biome'
[info] Starting to download remote version list.
[info] Found biome profile directory.
[info] Found default biome profile "Minetest Game v5"
[info] Found default biome profile "Minetest Game v.4"
[info] Found default biome profile "v6"
[info] Found default biome profile "30-biomes"
[info] Found default biome profile "Ethereal"
[info] Found default biome profile "Voxelgarden"
[info] Found default biome profile "Australia v0.4"
[info] Found default biome profile "MineClone 2"
[info] Found default biome profile "Aotearoa (New Zealand) v0.1"
[info] Biome profile activated: Minetest Game v5
[info] Checking for additional biome profiles.
[info] Found biome profile directory.
[info] Found default biome profile "Minetest Game v5"
[info] Found default biome profile "Minetest Game v.4"
[info] Found default biome profile "v6"
[info] Found default biome profile "30-biomes"
[info] Found default biome profile "Ethereal"
[info] Found default biome profile "Voxelgarden"
[info] Found default biome profile "Australia v0.4"
[info] Found default biome profile "MineClone 2"
[info] Found default biome profile "Aotearoa (New Zealand) v0.1"
[crash] Amidst has encounted an uncaught exception on the thread Thread[AWT-EventQueue-0,6,main]
[crash] java.lang.reflect.InaccessibleObjectException: Unable to make field private final int java.awt.color.ColorSpace.type accessible: module java.desktop does not "opens java.awt.color" to unnamed module @60285225
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
	at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:154)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
	at com.google.gson.Gson.getAdapter(Gson.java:407)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:106)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
	at com.google.gson.Gson.getAdapter(Gson.java:407)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:106)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
	at com.google.gson.Gson.getAdapter(Gson.java:407)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:106)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
	at com.google.gson.Gson.getAdapter(Gson.java:407)
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53)
	at com.google.gson.Gson.getAdapter(Gson.java:407)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:106)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
	at com.google.gson.Gson.getAdapter(Gson.java:407)
	at com.google.gson.Gson.fromJson(Gson.java:860)
	at com.google.gson.Gson.fromJson(Gson.java:799)
	at amidst.parsing.json.JsonReader.readReader(JsonReader.java:41)
	at amidst.parsing.json.JsonReader.readLocation(JsonReader.java:25)
	at amidst.settings.biomeprofile.BiomeProfileDirectory.createFromFile(BiomeProfileDirectory.java:298)
	at amidst.settings.biomeprofile.BiomeProfileDirectory.visitProfiles(BiomeProfileDirectory.java:245)
	at amidst.settings.biomeprofile.BiomeProfileDirectory.visitProfiles(BiomeProfileDirectory.java:237)
	at amidst.gui.main.menu.BiomeProfileMenuFactory.initParentMenu(BiomeProfileMenuFactory.java:169)
	at amidst.gui.main.menu.BiomeProfileMenuFactory.<init>(BiomeProfileMenuFactory.java:161)
	at amidst.gui.main.menu.AmidstMenuBuilder.create_Settings_BiomeProfile(AmidstMenuBuilder.java:162)
	at amidst.gui.main.menu.AmidstMenuBuilder.create_Settings(AmidstMenuBuilder.java:129)
	at amidst.gui.main.menu.AmidstMenuBuilder.createMenuBar(AmidstMenuBuilder.java:54)
	at amidst.gui.main.menu.AmidstMenuBuilder.<init>(AmidstMenuBuilder.java:36)
	at amidst.gui.main.PerMainWindowInjector.<init>(PerMainWindowInjector.java:118)
	at amidst.PerApplicationInjector.createMainWindow(PerApplicationInjector.java:122)
	at amidst.Application.displayMainWindow(Application.java:73)
	at amidst.Application.run(Application.java:55)
	at amidst.Amidst.doStartApplication(Amidst.java:171)
	at amidst.Amidst.lambda$startApplication$0(Amidst.java:162)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:316)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

java --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.color=ALL-UNNAMED -jar amidst-minetest-v1-4-1.jar appears to be right, at least, it opens the application.

@Treer
Copy link
Owner

Treer commented Oct 13, 2021

java --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.color=ALL-UNNAMED -jar amidst-minetest-v1-4-1.jar appears to be right, at least, it opens the application.

Thanks for working that out and posting back

Treer added a commit that referenced this issue Apr 13, 2023
Upgrade Gson to avoid
[crash] Amidst has encounted an uncaught exception on the thread Thread[AWT-EventQueue-0,6,main]
[crash] java.lang.reflect.InaccessibleObjectException: Unable to make field int java.awt.Color.value accessible: module java.desktop does not "opens java.awt" to unnamed module @3bf44630
@Treer Treer closed this as completed in b4f0af9 Apr 14, 2023
Treer added a commit that referenced this issue Apr 14, 2023
Try to fix #33 InaccessibleObjectException
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants