Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kotlin][debugger] Introduce Kotin class metadata helper #2951

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nikita-nazarov
Copy link
Contributor

@nikita-nazarov nikita-nazarov commented Feb 20, 2025

Related issue: https://youtrack.jetbrains.com/issue/IDEA-357870

This pull requests introduces MetadataDebugHelper - a helper class that allows fetching Kotlin class metadata in the debugger.

Also, "evaluatable getters" filtering is reimplemented using the mentioned helper class. Unfortunately the new implementation of filtering is slower than the previous one that relied on bytecode inspections:

Kotlin class metadata implementation vs  Bytecode implementation

However, at the same time the new implementation allows the debugger to filter out getters like:

fun getX()
fun isX()

Which were previously shown. And show getters like:

val x: Int get() = 1

Which were previously filtered out.

Kotlin compiler stores meta information about every class in the `kotlin.Metadata` annotation. Unfortunately, there is no way to fetch this annotation using plain JDI interface, because unlike method information, class annotations are not exposed to the debugger. This commit adds a helper class that allows fetching `kotlin.Metadata` of a specific class as a JSON string.
@nikita-nazarov
Copy link
Contributor Author

@zuevmaxim

@nikita-nazarov nikita-nazarov force-pushed the nazarov/kotlin-class-metadata branch from 6845674 to 681d8bd Compare February 20, 2025 20:48
Copy link
Contributor

@zuevmaxim zuevmaxim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll dig into details on Monday. In general, it looks great! Thank you!

@nikita-nazarov nikita-nazarov force-pushed the nazarov/kotlin-class-metadata branch from 681d8bd to 3d323aa Compare February 24, 2025 21:18
@nikita-nazarov nikita-nazarov force-pushed the nazarov/kotlin-class-metadata branch from 3d323aa to 69ae30d Compare February 25, 2025 13:46
Previously, filtering of evaluatable getters in variables view relied on bytecode inspections. Because of this, in some cases incorrect getters were shown, and also filtering was disabled completely in Android Studio.
@nikita-nazarov nikita-nazarov force-pushed the nazarov/kotlin-class-metadata branch from 69ae30d to acb6170 Compare February 26, 2025 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants