1

My case is unusual. Is there any chance to compile code without kotlin-runtime? Flags -Xno-param-assertions and -Xno-call-assertions doesn’t help much, I still got:

java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
   at lt.neworld.yyy.<init>(Unknown Source:2)
   at lt.neworld.yyy.<init>(yyy.kt:13)
neworld
  • 7,757
  • 3
  • 39
  • 61

1 Answers1

2

Kotlin runtime is required for running, as explained here - so I see no reason it will not be required for compilation as well. I guess there is no free lunch :-)

You should either:

  • Have Kotlin runtime in the classpath.
  • Point to the runtime location when running the app, as described on this answer
  • Embed the runtime within the .jar file of the app:

$ kotlinc <class name> -include-runtime -d <jar name> $ java -jar <jar name>

Lior Bar-On
  • 10,784
  • 5
  • 34
  • 46
  • Actually, I am not using as backend app, and don't have the luxury for additional 1k methods. Still, I love syntax of kotlin and would like to use it anyway. – neworld Aug 07 '17 at 18:32
  • @neworld - can you elaborate what is the unique use-case, then? – Lior Bar-On Aug 07 '17 at 18:33
  • 3
    @neworld You definitely need at least the [runtime library](https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-runtime/1.1.3-2), although not necessarily the [standard library](https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib/1.1.3-2). There's no way around AFAIK. Perhaps [ProGuard](https://www.guardsquare.com/en/proguard) can help reducing the method count after integrating the runtime. – Christian Brüggemann Aug 07 '17 at 18:35
  • I want to write a very small library (max 30 methods), fully tested and with my beloved language. +1000 methods are a huge overhead for not-kotlin projects. – neworld Aug 07 '17 at 18:41