redhat-developer / redhat-developer/vscode-java
The java builder should use the correct compiler compliance to build the project
@snjeza is already working on this.
Since Feb 20, 2020.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 546
- Avg merge
- 20h 1m
- Merged PRs (30d)
- 11
Description
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
- Have java.home to point to JDK 13, and launch the language server.
- Have Java 8 installed in the machine.
- 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"
}
]
- Open an eclipse Java 8 project 26.environmentVariables.zip
.

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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.