Before start describing how I'm getting this error, here is some important information:
Ok, let's take a look about my issue:
First, focus on the VM argument below:
"--add-opens=java.base/java.lang.reflect=com.jfoenix",
If I don't use this argument, the following error pops up when the program runs:
java.lang.reflect.InaccessibleObjectException: Unable to make boolean java.lang.reflect.AccessibleObject.setAccessible0(boolean)
accessible: module java.base does not "opens java.lang.reflect" to module com.jfoenix
IMPORTANT -> This is how my view shows without using the mentioned VM argument (let's call it image 1): https://snipboard.io/QJ5Fdc.jpg
"Ok, so why don't you just use the VM argument?" Great question! Alright, let's add it to my VM arguments and run the program once again.
After doing so, this is how my view looks like right now (let's call it image 2): https://snipboard.io/fbhGxw.jpg
Great! This is exactly how my view should be (note that considering it worked as expected, I've got no errors this time).
So, with everything working, I can finally move on and run my jpackage gradle task. After doing so, things stop making sense, since after executing my program through a .exe (generated by jpackage) my view looks like the "image 1" view, regardless the fact that my project is working properly when I run it with the "run" gradle task.
Let me know whether any code samples will be needed. All assistance will be appreciated. Thanks!
edit: related GitHub issue: enter link description here
The only way I found to properly fix this issue is using BurningWave:
<dependency>
<groupId>org.burningwave</groupId>
<artifactId>core</artifactId>
<version>12.62.6</version>
</dependency>
After adding the dependency, just copy/paste this code into your init()
method (this method can be -and should- override the init method in your class which extends Application
class, which is your JavaFX application entry point)
org.burningwave.core.assembler.StaticComponentContainer.Modules.exportAllToAll();
Class<?> bootClassLoaderClass = Class.forName("jdk.internal.loader.ClassLoaders$BootClassLoader");
Constructor<? extends ClassLoader> constructor = ClassLoader.getPlatformClassLoader().getClass().getDeclaredConstructor(bootClassLoaderClass);
constructor.setAccessible(true);
Class<?> classLoadersClass = Class.forName("jdk.internal.loader.ClassLoaders");
Method bootClassLoaderRetriever = classLoadersClass.getDeclaredMethod("bootLoader");
bootClassLoaderRetriever.setAccessible(true);
EDIT
Answering to @KenobiBastila comment, I don't know about the banner since I didn't had the necessity to remove it, but I did had to remove the BurningWave logs. In order to do so, create a burningwave.static.properties
file under resources
folder. Add these lines in it:
managed-logger.repository=autodetect
managed-logger.repository.enabled=false