Status Update
Comments
ag...@google.com <ag...@google.com> #2
Initial debugging on an Android O+ device shows the following steps. We compile the fragment which gives us class files containing invoke-dynamic
instructions as expected. Since the class files contain features that are not supported by eval4j, we hit the code path where we dex the class files, load the dex classes in a class loader on the device, and use the debugger to invoke the fragment method. However, that invocation fails. When that invocation fails, we fall back to using eval4j even though we know it will not work. That then leads to the error.
We should figure out why the invocation fails. It shouldn't.
ag...@google.com <ag...@google.com> #3
Oh, no wonder. We have configured the dexer to not make sure that things work on android:
We need to make sure that we enable desugaring, at least on this path where we know we are on Android O+ so that evaluate expression will succeed.
ac...@google.com <ac...@google.com> #4
I am a bit surprised by this. I figure Kristoffer was doing all that work and was upstreaming fixes to switch over.
Now it makes sense. Live Edit has:
compilerConfiguration.put(JVMConfigurationKeys.SAM_CONVERSIONS, JvmClosureGenerationScheme.CLASS)
compilerConfiguration.put(JVMConfigurationKeys.LAMBDAS, JvmClosureGenerationScheme.CLASS)
so we didn't see this even as we needed the IR backend but K2 isn't respecting that flag (and have future plans to remove it)
ag...@google.com <ag...@google.com> #5
Evaluate expression in Android Studio currently uses the non-IR evaluator.
I am a bit surprised by this. I figure Kristoffer was doing all that work and was upstreaming fixes to switch over.
Kristoffer implemented evaluate expression support for IR backend in the Kotlin compiler and IntelliJ. It has been a bit of a journey to get it turned on by default. It is now the default in IntelliJ, so it should be in studio as well soon.
Speaking of which, I just noticed:
Description
Background: Evaluate expression in Android Studio currently uses the non-IR evaluator. That is based on the old JVM backend which will be removed. Therefore, we need to make sure that Android Studio works with the IR evaluator.
To reproduce, make sure that you run android studio with the
debugger.kotlin.evaluator.use.jvm.ir.backend=true
option.In a Kotlin Android application add the following Java code:
I.java
Consume.java
Debug the android application. At a breakpoint, evaluate the following fragment:
Evaluation fails with the message
Can not evaluate the expression: INVOKEDYNAMIC is not supported
.