question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kotlin rules cannot be compiled against abi jars

See original GitHub issue

f43e2d20913443d7047fd4219e7559d9108a802a introduced a regression that puts abi jars on the kotlinc classpath instead of full jars. kotlinc does not like this and errors out on compilation when using methods from the kotlin standard library with the following stacktrace

Caused by: java.lang.IllegalStateException: Couldn't obtain compiled function body for public inline fun <T> mutableListOf(): kotlin.collections.MutableList<T> defined in kotlin.collections[DeserializedSimpleFunctionDescriptor@727380c2]
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen$1.invoke(InlineCodegen.java:280)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen$1.invoke(InlineCodegen.java:275)
	at org.jetbrains.kotlin.codegen.inline.InlineCacheKt.getOrPut(InlineCache.kt:34)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.createMethodNode(InlineCodegen.java:274)
	at org.jetbrains.kotlin.codegen.inline.InlineCodegen.genCallInner(InlineCodegen.java:180)
	... 69 more

    val words = mutableListOf<String>()
                ^

A repro case is available here: https://github.com/uber/okbuck/tree/gk_kotlin_abi Command to run: ./buckw build //libraries/kotlinlibrary/... After removing the compile_against_abis = true change in .buckconfig in the repro, everything works as expected

Seems like this option is not safe for kotlin modules yet. The kotlin compiler is actually introspecting the classes to extract out and inline the method into the compiled code. If we compile against the abi jars, the compiled method body will not be found. I think as part of refactoring and reusing base jvm descriptions etc for f43e2d20913443d7047fd4219e7559d9108a802a , it inadvertently introduced kotlinc to be able to pickup abi jars for compilation

cc @dsyang @runningcode @brettwooldridge

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
IanChildscommented, Aug 28, 2019

For those still following along, I am trying to add this capability now. I have class ABIs half way there - we use the KotlinMetadataReader to retain inline functions and inline property getter/setters, but there also seem to be some inner classes that we need to retain that I haven’t quite figured out yet.

For source ABIs we’ll use the Kotlin Compiler Plugin jvm-abi-gen that will generate the ABIs for us. This will work on sources but for prebuilt jars we still need the class ABI generation.

0reactions
IanChildscommented, Oct 21, 2019

Kotlin should now be able to compile against class ABIs. The one known case that it doesn’t handle is the expect and actual keywords, which are currently experimental. The hacky workaround here is to just set generate_abi = False for the prebuilt jars where they are found (seems to be coroutines for now, perhaps there are other uses too).

Read more comments on GitHub >

github_iconTop Results From Across the Web

ABI jar generation in the CLI compiler for Bazel like build ...
I maintain the public Bazel Kotlin Rules. An ABI jar captures the interface of some jar and if the interface doesn't change between...
Read more >
"Module was compiled with an incompatible version of Kotlin ...
Issue occurred when I changed jar version multiple times and click on debug button to run the application. Issue fixed when i used...
Read more >
Java ABIs - Buck
Buck generates source-only ABI JARs using only the text of the source code for a rule, without first compiling (most of) the rule's...
Read more >
Creating ABI Jars for bazel / buck and other next gen build ...
I'm working on bazel rules for Kotlin. Bazel (and buck) creates interface jars for Java code representing the ABI of a Jar.
Read more >
bazel/kotlin.bzl - platform/tools/base - Git at Google
experimental support for it in the 'official' Bazel Kotlin rules ... TODO: even if we cannot create ABI jars for Kotlin, it would...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found