https://kotlinlang.org logo
Title
a

Alexander Maryanovsky

06/02/2022, 12:38 PM
So, now that we’re using compose on the desktop (JVM), we have the usual Java problem of first-time class loading taking a long time, which looks bad in a desktop app. Is there a good solution for this? So far my best is to load all the classes given by Guava’s
ClassPath.allClasses
, but that seems a bit much.
a

Aaron Yoder

06/02/2022, 12:39 PM
This isn't necessarily something with an instant turnaround time, but Project Leyden is relevant to what you are saying: https://openjdk.java.net/projects/leyden/
a

Alexander Maryanovsky

06/02/2022, 12:44 PM
Until then, is there way to do a “dry-run” of a
@Composable
function, so it loads all the classes it needs?
m

mikehearn

06/02/2022, 1:01 PM
Sort of. Look at AppCDS.
It pre-caches loaded class metadata in the JVM. It won't make startup time instant, but it can help.
Usually between a 20% and 40% win, depending on how much your startup time is actually dominated by classloading.
a

Alexander Maryanovsky

06/02/2022, 1:12 PM
Hmm, interesting
m

Michael Paus

06/02/2022, 2:27 PM
You might be interested in

Java on CRaC

of even GraalVM/Native-image .