Skip to content

After opening the Kotlin class of the downloaded Maven dependency source code, I see a .class file instead of a .kt file #4297

Closed
eclipse-jdtls/eclipse.jdt.ls
#3666

Description

@linghengqian
  • After opening the Kotlin class of the downloaded Maven dependency source code, I see a .class file instead of a .kt file.
  • Suppose I have a Kotlin class that references com.facebook.presto.jdbc.internal.okhttp3.OkHttpClient. Now I hover my mouse over the text com.facebook.presto.jdbc.internal.okhttp3.OkHttpClient, hold down the Ctrl key, and left-click.
  • Image
  • At this point, I am accessing the OkHttpClient.class file of com.facebook.presto.jdbc.internal.okhttp3.OkHttpClient, not the OkHttpClient.kt file.
  • Image
  • I'm not entirely sure if this is expected behavior. I personally believe the title of this page should be OkHttpClient.kt instead of OkHttpClient.class, because it displays the content of https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/OkHttpClient.kt , not the decompiled content. My current .vscode/settings.json file contains the following:
{
    "java.compile.nullAnalysis.mode": "automatic",
    "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx8G -Xms100m -Xlog:disable",
    "java.jdt.ls.java.home": "~/.sdkman/candidates/java/25.0.1-graalce",
    "java.configuration.runtimes": [
        {
            "name": "JavaSE-22",
            "path": "~/.sdkman/candidates/java/22.0.2-graalce",
        },
        {
            "name": "JavaSE-24",
            "path": "~/.sdkman/candidates/java/24.0.2-graalce",
            "default": true
        },
        {
            "name": "JavaSE-25",
            "path": "~/.sdkman/candidates/java/25.0.1-graalce",
        },
    ],
}
  • Or am I misunderstanding something? For example, are there any VS Code plugins that specifically parse Kotlin files?

Activity

  1. fbricon commented on Jan 8, 2026

    @fbricon
    Collaborator

    So because the class is coming from a jar, the java language server generates a link to the .class in that jar, which is then opened by vscode. At that point, we don't know whether the .class is associated to a source file, java or something else. And then on the client side (vscode) there's a hard-coded mapping from .class to java syntax highlighting. So if the source sent to vscode is kotlin, well, that doesn't look good.
    I don't know if it's fixable. In theory, we would need to detect whether the source is attached in the 1st place during , identify which source that is, then compute a URI that both vscode and the language server could handle. But that would need to be done in several place and might be quite slow in certain circumstances.

  2. fbricon commented on Jan 8, 2026

    @fbricon
    Collaborator

    It was actually super simple to do ;-)

    open-proper-source.mp4

    Now I need to fix all the unit tests that expected .class

  3. added this to the End January 2026 milestone on Jan 8, 2026
  4. self-assigned this
    on Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions