I got a java.lang.IllegalAccessError
because of using a com.sun.*
class in Java >9. The solution to this is to add --add-exports=javafx.base/com.sun.javafx.event=org.controlsfx.controls
. I'm not sure how to add this to my build.gradle
, but I put
run {
jvmArgs = ['--add-exports=javafx.base/com.sun.javafx.event=org.controlsfx.controls']
}
into it and it didn't help. This is pretty much the issue I have. The error message is:
java.lang.IllegalAccessError: class org.controlsfx.control.textfield.AutoCompletionBinding (in unnamed module @0x2d7444bc) cannot access class com.sun.javafx.event.EventHandlerManager (in module javafx.base) because module javafx.base does not export com.sun.javafx.event to unnamed module @0x2d7444bc
at org.controlsfx.control.textfield.AutoCompletionBinding.<init>(AutoCompletionBinding.java:522) ~[controlsfx-11.0.0.jar:11.0.0]
at impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding.<init>(AutoCompletionTextFieldBinding.java:107) ~[controlsfx-11.0.0.jar:11.0.0]
at org.controlsfx.control.textfield.TextFields.bindAutoCompletion(TextFields.java:151) ~[controlsfx-11.0.0.jar:11.0.0]
[…]
at java.lang.Thread.run(Thread.java:835) [?:?]
It looks like you don't have a modular project. There are two options to solve it:
If you add a module-info descriptor, like:
module hellofx {
requires javafx.controls;
requires org.controlsfx.controls;
exports org.openjfx;
}
(adding your modules there, of course), it will work with:
run {
jvmArgs = ['--add-exports= \
javafx.base/com.sun.javafx.event=org.controlsfx.controls']
}
Since your project is not modular, it is part of the so called unnamed module. Therefore, you should use ALL-UNNAMED
, so the package is exported to all the modules, including ControlsFX:
run {
jvmArgs = ['--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED']
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With