redhat-developer / redhat-developer/vscode-java

dependency with com.sun.java.tools causes building error

オープン
#3,047 コメント 4 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
TypeScript
スター
2.3k
フォーク
546
平均マージ
20時間 1分
マージ済み PR(30日)
11

説明

I have a Maven project that uses JDK 1.8. If I add a dependency, such as net.openhft.lang, containing com.sun.java.tools (without specifying the version) to this project, the language server will generate an error "Missing artifact com.sun.java:tools🫙17.0.6", indicating that it cannot compile.
However, if I compile the project directly using mvn package, there are no errors. I use mvn dependency:tree to find that the version of com.sun.java.tools is just same as my JDK version installed and specified in the system (1.8.0_151).
It seems that the compilation behavior of the language server is different from directly using Maven, as it tries to look for version 17.0.6 (the JDK version embedded in the language server), instead of using version 1.8 in my system.

Environment
  • Operating System: MacOS 11.4
  • JDK version: 1.8.0_151 (Installed in /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home)
  • Visual Studio Code version: 1.76.2
  • Java extension version: v1.16.0
Steps To Reproduce
  1. Create a Maven project with pom.xml
  2. Add a dependency that requires com.sun.java.tools, such as net.openhft.lang (6.6.11 here), into dependencies in pom.xml
  3. Wait for Language Support for Java to reload the project.

sample project: https://github.com/straywarrior/issue_samples/tree/main/vscode-java/maven-test-project
logs:

!ENTRY org.eclipse.jdt.ls.core 4 0 2023-04-06 15:05:37.733
!MESSAGE Error occured while building workspace. Details: 
 message: The container 'Maven Dependencies' references non existing library '/Users/XXX/.m2/repository/com/sun/java/tools/17.0.6/tools-17.0.6.jar'; code: 964; resource: /Users/XXX/maven-test-project;
 message: The project cannot be built until build path errors are resolved; code: 0; resource: /Users/XXX/maven-test-project;
 message: Missing artifact com.sun.java:tools:jar:17.0.6; code: 0; resource: /Users/XXX/maven-test-project/pom.xml; line: 4
Current Result

Language server returns error: Missing artifact com.sun.java:tools🫙17.0.6

Expected Result

No error should occur.

Additional Informations

mvn dependency:tree output:

[INFO] com.straywarrior:maven-test-project:jar:1.0
[INFO] \- net.openhft:lang:jar:6.6.11:compile
[INFO]    +- org.ow2.asm:asm:jar:5.0.3:compile
[INFO]    +- org.slf4j:slf4j-api:jar:1.7.6:compile
[INFO]    +- com.sun.java:tools:jar:1.8.0_151:system
[INFO]    +- net.openhft:compiler:jar:2.2.0:compile
[INFO]    |  +- (org.slf4j:slf4j-api:jar:1.7.6:compile - omitted for duplicate)
[INFO]    |  +- (com.sun.java:tools:jar:1.8.0_151:system - omitted for duplicate)
[INFO]    |  \- org.kohsuke.jetbrains:annotations:jar:9.0:compile
[INFO]    \- org.xerial.snappy:snappy-java:jar:1.1.1.6:compile

VSCode settings.json

    "java.configuration.runtimes": [
        {
            "name": "JavaSE-1.8",
            "path": "/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home",
            "default": true
        }
    ]

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされたサンプル Maven プロジェクトから始め、記載されている JDK 1.8 ランタイムと VS Code の設定を使用して依存関係の解決を再現します。記録された JDT LS のビルドパスエラーを読み、com.sun.java:tools の扱いを mvn dependency:tree と比較します。サンプルプロジェクトが missing-artifact エラーや build-path エラーなしで再読み込みされれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
build-system, tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。