|
|
|
|
|
by cromwellian
1961 days ago
|
|
Kotlin methods are final by default unless marked open, and thus nonpolymorphic dispatch unless through an interface. It sounds to me like the problem isn’t the VM it’s the insane amount of framework code you have to be initialized. This can be optimized with Java via class data sharing and snapshotting but if your code is all written in Kotlin and you toss Spring into the trash can In favor of say, Dagger or hand crafted DI, most of your problems would go away. Besides, Kotlin/Native can compile and run without a VM. See https://august.nagro.us/jvm-startup.html for examples of how to optimize startup without Prewarming JIT. |
|
This is a language construct and not enforced within the byte code. There have historically been reasons to allow final to be ignored, such as serialization. Instead the JIT will optimize and deoptimize based on runtime behavior, allowing it to cover cases where overriding is designed for but not done so in the actual runtime environment. There was a nice presentation on "truly final fields" at the 2018 language summit [1].
[1] https://www.youtube.com/watch?v=2HfnaXND7-M