static initialisation of javafx.stage.Screen causing problems with clojure

Răzvan Rotaru razvan.rotaru at
Sun Mar 24 14:16:29 UTC 2019


I am trying to use OpenJFX 11.0.2 (for Linux) with Clojure and, and stumbled upon a problem for which I
would like to ask for advice here. The Problem occurs during compilation of
some clojure code, which triggers class loading for javafx.stage.Screen,
which fails with following stack trace (only the relevant part):

java.lang.IllegalStateException: This operation is permitted on the event
thread only; currentThread = main
    at javafx.stage.Screen.<clinit>(
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(
    at clojure.lang.RT.classForName(
    at clojure.lang.RT.classForName(
    at clojure.lang.Compiler.resolveIn(
    at clojure.lang.Compiler.resolve(
    at clojure.lang.Compiler.analyzeSymbol(
    at clojure.lang.Compiler.analyze(
    at clojure.lang.Compiler.analyze(
    at clojure.lang.Compiler$InvokeExpr.parse(

Being only compilation, there should be no Toolkit initialisation, hence no
event thread. Looking at the code it seems that the Screen class can only
be loaded from the event thread. Is this a bug or the intended behaviour?
Is there a way around this for my use case? How does OpenJFX ensure that
Screen is always loaded on the correct thread?

Related bug in fn-fx:



More information about the openjfx-dev mailing list