Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Java cannot resolve Kotlin imports in a mixed Maven project despite successful compilation

Ouverte
#4,537 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
48/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
java, kotlin
Domaine
tooling

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug

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:

  1. Open a mixed Java/Kotlin Maven project in VSCode, with Java sources under src/main/java and Kotlin sources under src/main/kotlin.
  2. Configure Maven to compile Kotlin before Java using kotlin-maven-plugin and maven-compiler-plugin.
  3. Import and use a public Kotlin class from a Java file in the same project.
  4. Run Maven compilation manually. The build completes with BUILD SUCCESS.
  5. Open the Java file. The import and usages of the Kotlin type are marked as unresolved.
  6. 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.java 1.56.0.
  • Kotlin extension version: fwcd.kotlin 0.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/classes and can be inspected using javap.
  • The inspected cached Java language server classpath does not include a source entry for src/main/kotlin. It lists target/classes as an output directory. These are observations, not a confirmed root cause.
  • The workspace setting java.autobuild.enabled is false. 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?
Langage dominant
TypeScript
Étoiles
2.3k
Forks
549
Merge moyen
8 h 20 min
PR mergées (30 j)
6

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de redhat-developer/vscode-java

Toutes les issues de redhat-developer/vscode-java

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.