Decompiling Kotlin to Java

Sometimes, to debug Java/Kotlin interoperability issues, it helps to see the equivalent Java code for a particular Kotlin source file.

IntelliJ IDEA and Android Studio both offer this capability. From the Tools > Kotlin menu, choose “Show Kotlin Bytecode”. This will open up the “Kotlin Bytecode” view and will show you the JVM bytecode associated with the current Kotlin source file. In that view, the “Decompile” button will attempt to decompile that bytecode into Java source code, opening up the result in another editor tab.

This works but is not without its flaws:


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.