Closed JojoFR1 closed 1 month ago
This might be related to https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2741 . It was fixed about 7 hours ago so maybe we can update and see if this fixes the issue.
I'm not seeing this behaviour on 1.33.2024072008
or the newer pre-release. I do see a warning about : The compiler compliance specified is 17 but a JRE 1.8 is used
. @snjeza , are you able to reproduce what's described here ?
If you click on the curly brace tooltip on the bottom right corner of the editor, and then hover over the "Configure Java Runtime" link, do you see something like :
Specifically that the compliance is JavaSE-17 and that a JRE 1.8 JDK is used for it ?
I updated to 1.33.2024072408
, which did not fix the issue. About the Java Runtime I got this:
My Java Runtime settings currently look like this:
"java.configuration.runtimes": [
{
"name": "JavaSE-17",
"path": "D:/Tools/jdk/jdk-17.0.11+9",
"default": false
},
{
"name": "JavaSE-21",
"path": "D:/Tools/jdk/jdk-21.0.3+9",
"default": false
},
{
"name": "JavaSE-22",
"path": "D:/Tools/jdk/jdk-22.0.1+8",
"default": true
}
],
I'm not seeing this behaviour on 1.33.2024072008 or the newer pre-release. I do see a warning about : The compiler compliance specified is 17 but a JRE 1.8 is used . @snjeza , are you able to reproduce what's described here ?
@rgrunber I can't reproduce the issue. I have tried Java LS 1.32.0 and pre-release. My settings:
"java.configuration.runtimes": [
{
"name": "JavaSE-21",
"path": "/usr/local/jdk-21",
"default": false
},
{
"name": "JavaSE-22",
"path": "/usr/local/jdk-22",
"default": true
},
{
"name": "JavaSE-1.8",
"path": "/usr/lib/jvm/java-1.8.0-openjdk",
"default": false
},
{
"name": "JavaSE-11",
"path": "/usr/local/jdk-11.0.8+10.hotspot/",
"default": false
},
{
"name": "JavaSE-13",
"path": "/usr/local/jdk-13.0.2"
},
{
"name": "JavaSE-14",
"path": "/usr/local/jdk-14"
},
{
"name": "JavaSE-17",
"path": "/usr/lib/jvm/java-17-openjdk",
"default": false
},
{
"name": "JavaSE-15",
"path": "/usr/local/jdk-15.0.1",
"sources": "/usr/local/jdk-15.0.1/lib/src.zip",
"default": false
},
{
"name": "JavaSE-16",
"path": "/usr/local/jdk-16.0.1",
"sources": "/usr/local/jdk-16.0.1/lib/src.zip",
"default": false
},
{
"name": "JavaSE-19",
"path": "/usr/local/jdk-19",
"default": false
},
{
"name": "JavaSE-20",
"path": "/usr/local/jdk-20",
"default": false
}
],
I don't know if it's a bug or a feature, but the error will be resolved by doing the following:
build.gradle
// options.compilerArgs.addAll(['--release', '8'])
options.compilerArgs.addAll(['--release', '17'])
@cypher256 Could you try to add
"java.gradle.buildServer.enabled": "off",
to your settings.json?
I don't know if it's a bug or a feature, but the error will be resolved by doing the following:
build.gradle
// options.compilerArgs.addAll(['--release', '8']) options.compilerArgs.addAll(['--release', '17'])
As far as I know the Java 8 backwards compatibility is required for it to work on Android. I will ask about it to have clear answers. I will also test later but I can't at the moment, it's almost 5AM.
Update: The developer did confirm it's to support 32bits and Android.
@snjeza
"java.gradle.buildServer.enabled": "off",
The error is gone!
@jdneo , could this be some incompatibility between how the gradle build server performs the build and buildship ?
It has been 2 weeks so far since the last comment, is there any news/idea on the problem?
So far the settings (that was previously suggested) to disable the gradle build server does work on removing the error, I wonder does it impact anything important/useful if it's disabled?
You can read more about the Gradle build server at https://devblogs.microsoft.com/java/announcing-the-build-server-for-gradle-open-source-repository/ . It should play nicely with the vscode-java extension. If java.gradle.buildServer.enabled
is enabled, then the build server will handle Gradle projects, and if disabled, vscode-java's embedded Gradle support will handle it. It seemed to me like this issue was a case of the build server performing incorrectly, hence why disabling it seems to resolve the issue.
@jdneo , could this be some incompatibility between how the gradle build server performs the build and buildship ?
TBH, I don't know who should be blamed for this issue. I think the behavior that gradle build server sets the source & target level to 1.8 is correct. Due to that --release 8
is added into the javac options. The document of javac says:
Note: When using --release, you cannot also use the --source/-source or --target/-target options.
This is the reason why both source and target level is set to 1.8 from gradle build server.
What's more, the source level should not be higher than the target level, which is a javac limitation: https://github.com/gradle/gradle/issues/8009#issuecomment-446419050
I don't know why gradle can compile the java code successfully 🤔
I can bring this question to our sync meeting with Gradle.
Instead of disabling gradle build server, another workaround is that you can change the language level via the project setting page.
Open Project Settings
Compiler
section, change the bytecode version to sth like 17
Ok, I understand why the project can compile the new java language features with --release 8
.
Yes, it's due to the annotation processor jabel
. If I comment out that line, it will fail. With it, the compilation succeeds.
That makes me thinking that whether we should take the release
argument in compilation option into consideration, or just simply takes the source compatibility that user sets.
Please try the latest pre-release version of vscode-gradle
(v3.16.2024102102), which fixes the problem. Now everything should work out of box.
Hi, sorry for the late reply but it does work! Thank you.
While modding for the game Mindustry, I noticed that I get the error
The Java feature 'Type Patterns' is only available with source level 16 and above - Java(4195411)
while doing 'Type Pattern' even though thesourceLevel
is set to 17 (see linked mod template repository down below). The explanation for this error might be becausetargetLevel
is set to 8 and the--release 8
argument is also added. If you are wondering why it is like that... I do not know but one of the dependecy,jabel
(https://github.com/Anuken/jabel), is supposed to make the Java 17 features be retro compatible with Java 8.Environment
Steps To Reproduce
}