This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-10
Channels
- # aleph (4)
- # beginners (32)
- # cider (12)
- # cljs-dev (56)
- # cljsrn (7)
- # clojars (3)
- # clojure (165)
- # clojure-dev (33)
- # clojure-germany (1)
- # clojure-italy (27)
- # clojure-russia (7)
- # clojure-spec (24)
- # clojure-uk (62)
- # clojurescript (37)
- # core-async (7)
- # core-matrix (1)
- # cursive (9)
- # data-science (8)
- # datomic (8)
- # duct (4)
- # events (1)
- # figwheel (7)
- # flambo (3)
- # fulcro (43)
- # hoplon (25)
- # jobs-discuss (8)
- # lein-figwheel (4)
- # luminus (2)
- # off-topic (35)
- # om (8)
- # om-next (3)
- # onyx (30)
- # pedestal (62)
- # portkey (2)
- # protorepl (2)
- # re-frame (40)
- # reagent (9)
- # shadow-cljs (123)
- # specter (30)
- # sql (22)
- # testing (1)
- # uncomplicate (40)
- # unrepl (3)
- # vim (13)
- # yada (5)
I have a question regarding class loading and static initializers, related to https://dev.clojure.org/jira/browse/CLJ-1743
Cell
here is a JavaFX class that has a static initializer that requires the JavaFX platform to be initialized before it is executed
so requiring or compiling this namespace fails with a CompilerException java.lang.ExceptionInInitializerError
It seems like the bytecode for the static initialization of the f
function does the following:
0: ldc #21 // String javafx.scene.control.Cell
2: invokestatic #27 // Method clojure/lang/RT.classForName:(Ljava/lang/String;)Ljava/lang/Class;
5: putstatic #15 // Field const__0:Ljava/lang/Object;
8: return
Java would instead use a Class
entry in the constant pool, and just use that in the implementation of f
:
My question is, is there a reason clojure could not do the same here, avoiding the RT.classForName
call?
ok. in the snippet i showed, would it be reasonable to emit a RT.classForNameNonLoading
for Cell
?
I would be more inclined to attempt to use reflection to work around jfx loading issues than anything else
It's ok to workaround now, with JDK9 you can simply do a (Platform/startup #(compile 'javafx))
in this case
not sure I follow, we AOT compile our app, so need to be able to compile the parts that use JavaFX classes too
but I guess it depends how as part of your build you are running (Platform/startup #(compile 'javafx))
, e.g. if you just have it in the middle of a source file that is being compiled (in which case the compile will also attempt to run at runtime) or if you have it part of some build script that isn't being compiled