Java cannot resolve Kotlin imports in a mixed Maven project despite successful compilation
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
First build the missing evidence the issue admits is absent: a minimal Java/Kotlin Maven reproducer (kotlin-maven-plugin before maven-compiler-plugin) plus the redhat.java output log with java.projectConfiguration.logs and java.project.classpath inspection, confirming whether target/classes output and src/main/kotlin are registered in the JDT-LS project model. Then check how m2e computes classpath entries and whether java.autobuild.enabled: false prevents the .class file from being picked up. Done means either unresolved-import diagnostics disappear for the reproducer, or the limitation is confirmed and documented with a recommended configuration.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
In a mixed Java/Kotlin Maven project, the Java extension cannot resolve an import of a public Kotlin class defined in the same project. Maven compilation succeeds, and the corresponding .class file exists, but the editor continues to report unresolved import and type errors.
Example diagnostics (package and class names anonymized):
The import com.example.SampleTable cannot be resolved
SampleTable cannot be resolved to a type
The problem persists after running Java: Reload Projects and Java: Clean Java Language Server Workspace.
To Reproduce
Steps observed in the existing project:
- Open a mixed Java/Kotlin Maven project in VSCode, with Java sources under
src/main/javaand Kotlin sources undersrc/main/kotlin. - Configure Maven to compile Kotlin before Java using
kotlin-maven-pluginandmaven-compiler-plugin. - Import and use a public Kotlin class from a Java file in the same project.
- Run Maven compilation manually. The build completes with
BUILD SUCCESS. - Open the Java file. The import and usages of the Kotlin type are marked as unresolved.
- Reload the Java projects and clean the Java language server workspace. The diagnostics persist.
Sample project: An independent minimal reproducer has not yet been prepared. The steps above describe observations in the existing project.
Logs: The same unresolved import and type diagnostics were found in the Java language server log. No log file is attached yet.
Expected behavior
The Java extension should resolve the Kotlin type in the same Maven project, including after Maven has successfully compiled it. If this scenario is unsupported, guidance on the limitation and recommended configuration would be helpful.
Screenshots
No screenshots attached. The diagnostic text is included above.
Environment
- Operating System: Windows_NT x64 10.0.19045 (VSCode client); the project and extensions are on Linux via VSCode Server. The remote connection method is not specified here.
- JDK version: Not yet confirmed for either the Java language server or Maven. The project's Java/Kotlin JVM compilation target is 11.
- Visual Studio Code version: 1.122.1 (user setup), commit
8761a5560cfd65fdd19ce7e2bd18dab5c0a4d84e. - Java extension version:
redhat.java1.56.0. - Kotlin extension version:
fwcd.kotlin0.2.36. - Kotlin Maven plugin version: 2.0.0.
- Maven version: Not yet confirmed.
Additional Information
- The Kotlin class is public, and its package matches the Java import.
- The generated class exists under
target/classesand can be inspected usingjavap. - The inspected cached Java language server classpath does not include a source entry for
src/main/kotlin. It liststarget/classesas an output directory. These are observations, not a confirmed root cause. - The workspace setting
java.autobuild.enabledisfalse. Maven compilation was run manually; the effect of enabling automatic builds has not been tested. - Is this a known limitation of Java/Kotlin interoperability, or a type-resolution defect? Is there an existing issue or a recommended configuration for this setup?
- 主要语言
- TypeScript
- 星标
- 2.3k
- 派生
- 548
- 平均合并
- 8 小时 20 分钟
- 30 天内合并 PR
- 6
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
redhat-developer/vscode-java 的其他 Issue
-
JDK_HOME can be sorted after lower-priority auto-detected JDK sources可能已有人在做 @shblue21 于 114 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
redhat-developer/vscode-java#4426 ·
维护者通常 1 天内回复
-
bug Lombok
难度 4/5 3-5 天 新手友好度 52/100
redhat-developer/vscode-java#4521 · 2 条评论 ·
维护者通常 1 天内回复
-
bug need info
难度 4/5 3-5 天 新手友好度 35/100
redhat-developer/vscode-java#4520 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 25/100
redhat-developer/vscode-java#4517 · 1 条评论 ·
维护者通常 1 天内回复
-
bug documentation
难度 3/5 1-2 天 新手友好度 25/100
redhat-developer/vscode-java#4516 · 1 条评论 ·
维护者通常 1 天内回复
查看 redhat-developer/vscode-java 的全部 Issue
相似的 Issue
-
bug DUP Reservations
难度 2/5 1-3 小时 新手友好度 62/100
bcgov/reserve-rec-public#952 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
daufderheide/racecoordinator_ai#948 ·
维护者通常 1 天内回复
-
Bug pulumi/pulumi
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bug priority:high
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
api bug claude
难度 2/5 1-3 小时 新手友好度 84/100
diegosouzapw/OmniRoute#15764 ·
维护者通常 2 天内回复