openjfx / javafx-gradle-plugin

Gradle plugin that makes it easy to work with JavaFX 11+
https://openjfx.io/
BSD 3-Clause "New" or "Revised" License
361 stars 62 forks source link

IntelliJ can't start app when using the IDE build system #67

Open mikehearn opened 5 years ago

mikehearn commented 5 years ago

Gradle is rather slow. So it can be preferable to use the IntelliJ build and run system when possible, which is better integrated and less visually noisy. Unfortunately this doesn't work when using the Gradle build system - I get this exception which suggests some module system problem:

Caused by: java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.scene.control.ControlHelper (in unnamed module @0x182efd96) cannot access class com.sun.javafx.scene.layout.RegionHelper (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.scene.layout to unnamed module @0x182efd96
    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:802)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at javafx.scene.control.Control.<clinit>(Control.java:86)

The command used to start the app is

/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/bin/java --add-modules javafx.base,javafx.graphics --add-reads javafx.base=ALL-UNNAMED --add-reads javafx.graphics=ALL-UNNAMED "-javaagent:/Users/mike/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-1/193.5233.12/IntelliJ IDEA 2019.3 EAP.app/Contents/lib/idea_rt.jar=53771:/Users/mike/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-1/193.5233.12/IntelliJ IDEA 2019.3 EAP.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath /Users/mike/Source/Interruptions/build/classes/kotlin/main:/Users/mike/Source/Interruptions/build/resources/main:/Users/mike/.gradle/caches/modules-2/files-2.1/com.sandec.jpro/jpro-webapi/2019.1.2/69a3efb9531949d325e385bb0867ae4d576b2824/jpro-webapi-2019.1.2.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/no.tornado/tornadofx/1.7.19/fdd74beea0e573461c6657f5937eb3f47a739c52/tornadofx-1.7.19.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.3.50/bf65725d4ae2cf00010d84e945fcbc201f590e11/kotlin-stdlib-jdk8-1.3.50.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/io.permazen/permazen-main/4.1.5/104398bde5f53046c2f46b9ca5188a49001a0670/permazen-main-4.1.5.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/io.permazen/permazen-kv-array/4.1.5/75a38a92956610a2c04f41f76dacd72b141d3935/permazen-kv-array-4.1.5.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-fxml/12.0.1/975a83878e6687dbf3fdb35592baa2586b658c8b/javafx-fxml-12.0.1-mac.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-controls/12.0.1/af23299415c0d594ea9f84b3dd3baf9b54618594/javafx-controls-12.0.1-mac.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-controls/12.0.1/a6502999bdb947885c8d121a47d745d52a06577a/javafx-controls-12.0.1.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-graphics/12.0.1/ed0b71c64a58482f659194ab087b7eeda0fc562d/javafx-graphics-12.0.1-mac.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-graphics/12.0.1/19ec56a15d7dd9c49112912547425b718485d7db/javafx-graphics-12.0.1.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-base/12.0.1/b995ca9beeb01fcddd062c54a24ff4f6aa3b2a37/javafx-base-12.0.1-mac.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-base/12.0.1/6abae81d00e0c6f4fde02e2666f9c0b989ff47e4/javafx-base-12.0.1.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.50/50ad05ea1c2595fb31b800e76db464d08d599af3/kotlin-stdlib-jdk7-1.3.50.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.3.20/cd49eec32cf964333faf59e04b4085eac7008477/kotlin-reflect-1.3.20.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.50/b529d1738c7e98bbfa36a4134039528f2ce78ebf/kotlin-stdlib-1.3.50.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.glassfish/javax.json/1.1.2/a507518970d55e9de24665af06d70aae91b4aaa1/javax.json-1.1.2.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/io.permazen/permazen-coreapi/4.1.5/10ec9e6430cc882c714b68073c89d1d05d10bc8a/permazen-coreapi-4.1.5.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/io.permazen/permazen-kv-simple/4.1.5/4118955d530796a0dc7b9b3aabbe5fe90a858321/permazen-kv-simple-4.1.5.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/io.permazen/permazen-kv/4.1.5/a1ead8b1282f68e4cd3f2f4add0fcf56b839f2dc/permazen-kv-4.1.5.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/io.permazen/permazen-util/4.1.5/464b9ca98b60a63690d822c0f0866583665edaad/permazen-util-4.1.5.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.dellroad/dellroad-stuff-main/2.2.2/e67634b710df0babff10a293beab63294b40ad84/dellroad-stuff-main-2.2.2.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/24.0-jre/41ac1e74d6b4e1ea1f027139cffeb536c732a81/guava-24.0-jre.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.hibernate.validator/hibernate-validator/6.0.7.Final/8b9d9c7ec8c73963ea0fe81912fc67711a4ef76/hibernate-validator-6.0.7.Final.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/javax.validation/validation-api/2.0.1.Final/cb855558e6271b1b32e716d24cb85c7f583ce09e/validation-api-2.0.1.Final.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.glassfish/javax.el/3.0.1-b09/2b59f1809e193aa942b8ed20efc673d9063e6a50/javax.el-3.0.1-b09.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.25/da76ca59f6a57ee3102f8f9bd9cee742973efa8a/slf4j-api-1.7.25.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.50/3d9cd3e1bc7b92e95f43d45be3bfbcf38e36ab87/kotlin-stdlib-common-1.3.50.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/javax.json/javax.json-api/1.1.2/b38c52a6e180359108bd5e35dbeec7d1be45c535/javax.json-api-1.1.2.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-log4j12/1.7.25/110cefe2df103412849d72ef7a67e4e91e4266b4/slf4j-log4j12-1.7.25.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.11/3acb4705652e16236558f0f4f2192cc33c3bd189/commons-codec-1.11.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/1.3.9/40719ea6961c0cb6afaeb6a921eaa1f6afd4cfdf/jsr305-1.3.9.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/log4j/log4j/1.2.17/5af35056b4d257e4b64b9e8069c0746e8b08629f/log4j-1.2.17.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.checkerframework/checker-compat-qual/2.0.0/fc89b03860d11d6213d0154a62bcd1c2f69b9efa/checker-compat-qual-2.0.0.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/com.google.errorprone/error_prone_annotations/2.1.3/39b109f2cd352b2d71b52a3b5a1a9850e1dc304b/error_prone_annotations-2.1.3.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/com.google.j2objc/j2objc-annotations/1.1/ed28ded51a8b1c6b112568def5f4b455e6809019/j2objc-annotations-1.1.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.codehaus.mojo/animal-sniffer-annotations/1.14/775b7e22fb10026eed3f86e8dc556dfafe35f2d5/animal-sniffer-annotations-1.14.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.jboss.logging/jboss-logging/3.3.0.Final/3616bb87707910296e2c195dc016287080bba5af/jboss-logging-3.3.0.Final.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/com.fasterxml/classmate/1.3.1/2ad2fd09dcf5607ca96f8ef432096a96986c40a/classmate-1.3.1.jar -p /Users/mike/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-base/12.0.1/b995ca9beeb01fcddd062c54a24ff4f6aa3b2a37/javafx-base-12.0.1-mac.jar:/Users/mike/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-graphics/12.0.1/ed0b71c64a58482f659194ab087b7eeda0fc562d/javafx-graphics-12.0.1-mac.jar net.plan99.interruptions.Interruptions

It does work when started with Gradle so I'd understand if you considered this not a bug, but still ... it used to all be so easy :(

mikaelgrev commented 4 years ago

I have exactly(!) the same problem now, after converting my IDEA project to Java 11. Did you find an answer?

mikehearn commented 4 years ago

I just make my own JDK that has JavaFX modules built in, like the old days. It only takes a few lines of shell script to produce that, and it avoids a whole lot of weirdness as long as you can dictate the JDK the resulting JARs are run with. For desktop apps you often can.

https://gist.github.com/mikehearn/b18842d45181ac150ec9e6d0b2bb1e24

For other cases, back to Gradle I go ...