Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin Bytecode - How to analyze in IntelliJ IDEA?

I want to see the compiled bytecode so I can learn more about how it works under the cover. I'm using IntelliJ IDEA 15 but can't find a way to see the bytecode. What am I missing?

like image 542
CaseyB Avatar asked Feb 21 '16 15:02

CaseyB


People also ask

How do I read Kotlin bytecode?

Tools → Kotlin → Show Kotlin Bytecode Now, in the bytecode view, there is also an option to decompile the bytecode to Java. So, you can actually see both the bytecode and the equivalent java code in intellij. You even have an option to convert using JVM 8 target.

How do I find my Kotlin compiled code?

Fortunately, IntelliJ and Android Studio allow to instantly see bytecode and Java equivalent. Display java equivalent: just click “Decompile” button on the top of “Kotlin Bytecode” window.

Does IntelliJ IDEA support Kotlin?

IntelliJ IDEA provides first-class support for Kotlin. It includes Kotlin-specific project templates, coding assistance, refactorings, debugging, analysis tools, and so on.


1 Answers

IntelliJ IDEA comes with a bytecode viewing tool for Kotlin:

Tools → Kotlin icon Kotlin → Show Kotlin Bytecode

Also available through Ctrl / ⌘+Shift+A as Show Kotlin Bytecode action.

It's a great tool that can jump to the corresponding bytecode when you move around in the source file. And it updates the bytecode on the fly whenever the source changes.


Also, I'd like to recommend jclasslib Bytecode Viewer as an external tool for low-level class files analysis (such as inspecting constant pools). Now it is also available as an IntelliJ IDEA plugin.

like image 70
hotkey Avatar answered Sep 25 '22 01:09

hotkey