redhat-developer / redhat-developer/vscode-java

The java builder should use the correct compiler compliance to build the project

オープン
#1,290 コメント 14 件 リアクション 1 件 担当者 1 名 GitHub で見る

@snjeza がすでに取り組んでいます。

2020年2月20日 から。

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

説明

Environment
  • Operating System: MacOS and Windows 10
  • JDK version: any
  • Visual Studio Code version: 1.41.x or 1.42.0-insider
  • Java extension version: 0.57.0
Steps To Reproduce
  1. Have java.home to point to JDK 13, and launch the language server.
  2. Have Java 8 installed in the machine.
  3. Configure multiple JDKs in the user setting.
    "java.configuration.runtimes": [
        {
            "name": "JavaSE-13",
            "path": "C:\\Program Files\\Java\\jdk-13.0.1"
        },
        {
            "name": "JavaSE-1.8",
            "path": "C:\\Program Files\\AdoptOpenJDK\\jdk-8.0.242.08-hotspot"
        }
    ]
  1. Open an eclipse Java 8 project 26.environmentVariables.zip
    .
    image
Current Result:

See the screenshot above, the PROBLEMS viewlet reports a warning on the project: "The compiler compliance specified is 13 but a JRE 1.8 is used". This means the classfile built by the ls is targeting to java 13, that would make it not able to be launched in JDK 8.

Besides, the debugger has fixed a bug https://github.com/microsoft/vscode-java-debug/issues/753 about using the project's Java runtime to launch the application. The latest debugger would fail at this case.

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: EnvrionmentVariable has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
Expected

The language server should generate the compatible .class files with the project's Java Runtime.

// @fbricon @snjeza

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

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

はじめの一歩

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

評価

この issue はまだ評価されていません。

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

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