Skip to content
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

Getting ...does not export to module exception after changing to non-modular project #1133

Open
jackpeters667 opened this issue Jul 28, 2020 · 10 comments

Comments

@jackpeters667
Copy link

I just switched my project from modular to non modular and i'm getting this exception all of a sudden.

Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: superclass access check failed: class com.jfoenix.controls.behavior.JFXGenericPickerBehavior (in unnamed module @0x449613ed) cannot access class com.sun.javafx.scene.control.behavior.ComboBoxBaseBehavior (in module javafx.controls) because module javafx.controls does not export com.sun.javafx.scene.control.behavior to unnamed module @0x449613ed at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at com.jfoenix.skins.JFXGenericPickerSkin.<init>(JFXGenericPickerSkin.java:62) at com.jfoenix.skins.JFXDatePickerSkin.<init>(JFXDatePickerSkin.java:60) at com.jfoenix.controls.JFXDatePicker.createDefaultSkin(JFXDatePicker.java:100) at javafx.controls/javafx.scene.control.Control.doProcessCSS(Control.java:897) at javafx.controls/javafx.scene.control.Control$1.doProcessCSS(Control.java:89) at javafx.controls/com.sun.javafx.scene.control.ControlHelper.processCSSImpl(ControlHelper.java:67) at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:145) at javafx.graphics/javafx.scene.Parent.doProcessCSS(Parent.java:1400) at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Parent.java:125) at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:98) at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:145) at javafx.graphics/javafx.scene.Parent.doProcessCSS(Parent.java:1400) at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Parent.java:125) at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:98) at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:145) at javafx.graphics/javafx.scene.Parent.doProcessCSS(Parent.java:1400) at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Parent.java:125) at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:98) at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:145) at javafx.graphics/javafx.scene.Parent.doProcessCSS(Parent.java:1400) at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Parent.java:125) at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:98) at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:145) at javafx.graphics/javafx.scene.Node.processCSS(Node.java:9542) at javafx.graphics/javafx.scene.Node.processCSS(Node.java:9535) at javafx.graphics/javafx.scene.Node.processCSS(Node.java:9535) at javafx.graphics/javafx.scene.Node.processCSS(Node.java:9535) at javafx.graphics/javafx.scene.Node.processCSS(Node.java:9535) at javafx.graphics/javafx.scene.Scene.doCSSPass(Scene.java:569) at javafx.graphics/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2505) at javafx.graphics/com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:412) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:411) at javafx.graphics/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:438) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:563) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:543) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:536) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:342) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277) at java.base/java.lang.Thread.run(Thread.java:834)

I'm using gradle and this is how I add my exports in my buld.gradle file
applicationDefaultJvmArgs = ['--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix', '--add-exports=javafx.graphics/com.sun.javafx.scene=com.jfoenix', '--add-opens=java.base/java.lang.reflect=com.jfoenix', '--add-opens=java.base/java.lang.reflect=ALL-UNNAMED', '--add-exports=javafx.controls/com.sun.javafx.scene.control=com.jfoenix', '--add-exports=javafx.base/com.sun.javafx.binding=com.jfoenix', '--add-exports=javafx.graphics/com.sun.javafx.stage=com.jfoenix', '--add-exports=javafx.base/com.sun.javafx.event=com.jfoenix']

Am I missing something else?
It was working just fine as a modular project

@jackpeters667 jackpeters667 changed the title vafx.controls does not export com.sun.javafx.scene.control.behavior to unnamed module @0x449613ed Does not export to module (after changing to non-modular project) Jul 28, 2020
@jackpeters667 jackpeters667 changed the title Does not export to module (after changing to non-modular project) Getting ...does not export to module exception after changing to non-modular project Jul 28, 2020
@askjgafdsdfassflsdjfljdg
Copy link

askjgafdsdfassflsdjfljdg commented Aug 8, 2020

I'm using a modular project but it still does not work and issues same error:

Caused by: java.lang.IllegalAccessError: class com.jfoenix.skins.JFXTabPaneSkin (in module com.jfoenix) cannot access class com.sun.javafx.scene.control.behavior.TabPaneBehavior (in module javafx.controls) because module javafx.controls does not export com.sun.javafx.scene.control.behavior to module com.jfoenix

module-info.java file:

requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires spring.boot.autoconfigure;
requires spring.context;
requires spring.boot;
requires spring.beans;
requires com.jfoenix;
requires spring.core;
    
opens sample to spring.core;
opens sample.controller to javafx.fxml;
exports sample.controller to spring.beans;
exports sample;

@buttonmasher3
Copy link

I'm using a modular project but it still does not work and issues same error:

Caused by: java.lang.IllegalAccessError: class com.jfoenix.skins.JFXTabPaneSkin (in module com.jfoenix) cannot access class com.sun.javafx.scene.control.behavior.TabPaneBehavior (in module javafx.controls) because module javafx.controls does not export com.sun.javafx.scene.control.behavior to module com.jfoenix

module-info.java file:

requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires spring.boot.autoconfigure;
requires spring.context;
requires spring.boot;
requires spring.beans;
requires com.jfoenix;
requires spring.core;
    
opens sample to spring.core;
opens sample.controller to javafx.fxml;
exports sample.controller to spring.beans;
exports sample;

Did you add exports? It was working just fine for me with modular, but I had to switch to non-modular because of conflicting libraries and it wasn't as easy to solve the issue, So I just opted to change, but then my JFXDatePickers dont work all of a sudden.

@askjgafdsdfassflsdjfljdg

I'm using a modular project but it still does not work and issues same error:
Caused by: java.lang.IllegalAccessError: class com.jfoenix.skins.JFXTabPaneSkin (in module com.jfoenix) cannot access class com.sun.javafx.scene.control.behavior.TabPaneBehavior (in module javafx.controls) because module javafx.controls does not export com.sun.javafx.scene.control.behavior to module com.jfoenix
module-info.java file:

requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires spring.boot.autoconfigure;
requires spring.context;
requires spring.boot;
requires spring.beans;
requires com.jfoenix;
requires spring.core;
    
opens sample to spring.core;
opens sample.controller to javafx.fxml;
exports sample.controller to spring.beans;
exports sample;

Did you add exports? It was working just fine for me with modular, but I had to switch to non-modular because of conflicting libraries and it wasn't as easy to solve the issue, So I just opted to change, but then my JFXDatePickers dont work all of a sudden.

I also changed it to a non-modular form then I did add --add-exports commands to the applicationDefaultJvmArgs and it worked for me. But anyway I think this is kind of dirty solution and the JFoenix core libraries should be changed to be compatible with OpenJFX +11 and its modules.

@jackpeters667
Copy link
Author

I'm using a modular project but it still does not work and issues same error:
Caused by: java.lang.IllegalAccessError: class com.jfoenix.skins.JFXTabPaneSkin (in module com.jfoenix) cannot access class com.sun.javafx.scene.control.behavior.TabPaneBehavior (in module javafx.controls) because module javafx.controls does not export com.sun.javafx.scene.control.behavior to module com.jfoenix
module-info.java file:

requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires spring.boot.autoconfigure;
requires spring.context;
requires spring.boot;
requires spring.beans;
requires com.jfoenix;
requires spring.core;
    
opens sample to spring.core;
opens sample.controller to javafx.fxml;
exports sample.controller to spring.beans;
exports sample;

Did you add exports? It was working just fine for me with modular, but I had to switch to non-modular because of conflicting libraries and it wasn't as easy to solve the issue, So I just opted to change, but then my JFXDatePickers dont work all of a sudden.

Glad to hear that someone also has the same issue (I'm sorry XD). If you find a workaround, update me

@jackpeters667
Copy link
Author

@buttonmasher3 @askjgafdsdfassflsdjfljdg Could you guys share your --addexports with me? And which framework are you on? Gradle?

@FelipeAumannRS
Copy link

FelipeAumannRS commented Apr 28, 2021

Exactly same problem here. @jfoenixadmin, it looks like a bug.

Possibly fix: just add the following row to your jvm args:
"--add-opens=java.base/java.lang.reflect=com.jfoenix",

It should look like this:

def args = [
"--add-opens=java.base/java.lang.reflect=com.jfoenix",
]

run {
jvmArgs = args
}

Heres my complete list of VM arguments:

def args = [
"--add-exports=javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED",
"--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED",
"--add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED",
"--illegal-access=warn",
"--add-opens=javafx.controls/javafx.scene.control.skin=com.jfoenix",
"--add-exports=javafx.controls/com.sun.javafx.scene.control=com.jfoenix",
"--add-exports=javafx.base/com.sun.javafx.binding=com.jfoenix",
//the next line changes everything.
"--add-opens=java.base/java.lang.reflect=com.jfoenix",

    "--add-exports=javafx.controls/javafx.scene.control.skin=com.jfoenix",
    "--add-exports=java.base/java.lang.reflect=ALL-UNNAMED",
    "--add-exports=java.base/java.lang.reflect=com.jfoenix",
    "--add-exports=javafx.controls/com.Sun.javafx.scene.control.behavior=com.jfoenix",
    "--add-exports=javafx.graphics/com.sun.javafx.stage=com.jfoenix",
    "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix",

    "--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED",

    "--add-exports=javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED",
    "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior" +
            "=ALL-UNNAMED",
    "--add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED",
    "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior" +
            "=com.jfoenix",
    "--add-exports=javafx.controls/com.sun.javafx.binding=com.jfoenix",
    "--illegal-access=warn",
    "--add-opens=javafx.controls/javafx.scene.control.skin=com.jfoenix",
    "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
    "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior" +
            "=com.jfoenix",
    "--add-exports=javafx.controls/com.sun.javafx.scene.control=com.jfoenix",
    "--add-exports=javafx.base/com.sun.javafx.binding=com.jfoenix",
    "--add-exports=javafx.graphics/com.sun.javafx.stage=com.jfoenix",
    "--add-exports=javafx.base/com.sun.javafx.event=com.jfoenix",

    "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix",
    "--add-exports=javafx.controls/com.sun.javafx.scene.control=com.jfoenix",
    "--add-exports=javafx.base/com.sun.javafx.binding=com.jfoenix",
    "--add-exports=javafx.graphics/com.sun.javafx.stage=com.jfoenix",
    "--add-exports=javafx.base/com.sun.javafx.event=com.jfoenix"

]

run {
jvmArgs = args
}

Like my answer if it helps :-)

@louhy
Copy link

louhy commented Dec 19, 2021

All that junk looked disgusting to me so and I don't like copy-pasting tons of crap without at least knowing it's required, so I was able to narrow down what I needed down to this for a non-modular project (in my case at least):

run {
jvmArgs = [
"--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
"--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED",
"--add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED",
"--add-exports=javafx.base/com.sun.javafx.binding=ALL-UNNAMED",
"--add-exports=javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED",
"--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED"
]
}

It's not hard to check the error output and add what you need one by one once you've got the syntax as demonstrated above. I am a little surprised I didn't need to export anything at all to com.jfoenix, but I can't argue with "works on my machine".

Maybe the list can vary depending on your specific case. But this works for me with Java 17.0.1 (fx-zulu VM) and Gradle 7.3.2.

@JJBRT
Copy link

JJBRT commented Dec 23, 2021

Please take a look at my article that explain how to export all modules to all modules at runtime in Java 16 and later without using any JVM parameter.

@louhy
Copy link

louhy commented Dec 28, 2021

Interesting alternative above. I probably won't go that route in my case but good to know there's other choices.

@Maslow5941
Copy link

module javaFxException {
requires javafx.controls;
requires javafx.fxml;

opens application to javafx.graphics, javafx.fxml;
opens gui to javafx.graphics, javafx.fxml;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants