-
Notifications
You must be signed in to change notification settings - Fork 128
SLE-1443 Migrate to Java 21 for the backend #1020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1ed6064
Update to Java 21 SLCORE
damien-urruty-sonarsource 3127f89
SLE-1443 Bump version to 12.0
damien-urruty-sonarsource 3c23355
SLE-1443 Migrate to Java 21 for the backend
damien-urruty-sonarsource dfc36da
SLE-1449 Timeout if the backend is not responsive
damien-urruty-sonarsource File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
...e.tests/src/test/java/org/sonarlint/eclipse/core/internal/utils/JavaRuntimeUtilsTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| /* | ||
| * SonarLint for Eclipse | ||
| * Copyright (C) 2015-2025 SonarSource Sàrl | ||
| * sonarlint@sonarsource.com | ||
| * | ||
| * This program is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 3 of the License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License | ||
| * along with this program; if not, write to the Free Software Foundation, | ||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| */ | ||
| package org.sonarlint.eclipse.core.internal.utils; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.junit.rules.TemporaryFolder; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| public class JavaRuntimeUtilsTest { | ||
|
|
||
| @Rule | ||
| public TemporaryFolder temporaryFolder = new TemporaryFolder(); | ||
|
|
||
| @Test | ||
| public void returns_empty_when_release_file_is_absent() throws IOException { | ||
| var dir = temporaryFolder.newFolder().toPath(); | ||
| assertThat(JavaRuntimeUtils.getJavaMajorVersion(dir)).isEmpty(); | ||
| } | ||
|
|
||
| @Test | ||
| public void returns_empty_when_release_file_has_no_java_version_line() throws IOException { | ||
| var dir = releaseFileWith("OS_NAME=\"Linux\"\nOS_VERSION=\"5.15\"\n"); | ||
| assertThat(JavaRuntimeUtils.getJavaMajorVersion(dir)).isEmpty(); | ||
| } | ||
|
|
||
| @Test | ||
| public void returns_empty_when_version_string_is_malformed() throws IOException { | ||
| var dir = releaseFileWithVersion("not-a-version"); | ||
| assertThat(JavaRuntimeUtils.getJavaMajorVersion(dir)).isEmpty(); | ||
| } | ||
|
|
||
| @Test | ||
| public void parses_modern_version_with_patch() throws IOException { | ||
| assertThat(JavaRuntimeUtils.getJavaMajorVersion(releaseFileWithVersion("21.0.1"))).hasValue(21); | ||
| } | ||
|
|
||
| @Test | ||
| public void parses_modern_version_without_minor() throws IOException { | ||
| assertThat(JavaRuntimeUtils.getJavaMajorVersion(releaseFileWithVersion("21"))).hasValue(21); | ||
| } | ||
|
|
||
| @Test | ||
| public void parses_java_17() throws IOException { | ||
| assertThat(JavaRuntimeUtils.getJavaMajorVersion(releaseFileWithVersion("17.0.9"))).hasValue(17); | ||
| } | ||
|
|
||
| @Test | ||
| public void parses_java_11() throws IOException { | ||
| assertThat(JavaRuntimeUtils.getJavaMajorVersion(releaseFileWithVersion("11.0.22"))).hasValue(11); | ||
| } | ||
|
|
||
| @Test | ||
| public void parses_legacy_java_8_version_format() throws IOException { | ||
| assertThat(JavaRuntimeUtils.getJavaMajorVersion(releaseFileWithVersion("1.8.0_382"))).hasValue(8); | ||
| } | ||
|
|
||
| @Test | ||
| public void ignores_unrelated_lines_around_java_version() throws IOException { | ||
| var dir = releaseFileWith( | ||
| "OS_NAME=\"Linux\"\n" | ||
| + "JAVA_VERSION=\"21.0.1\"\n" | ||
| + "IMPLEMENTOR=\"Eclipse Adoptium\"\n" | ||
| + "JAVA_RUNTIME_VERSION=\"21.0.1+12\"\n"); | ||
| assertThat(JavaRuntimeUtils.getJavaMajorVersion(dir)).hasValue(21); | ||
| } | ||
|
|
||
| @Test | ||
| public void detects_java_executable_on_unix() throws IOException { | ||
| var dir = temporaryFolder.newFolder().toPath(); | ||
| var bin = Files.createDirectory(dir.resolve("bin")); | ||
| Files.createFile(bin.resolve("java")); | ||
|
|
||
| assertThat(JavaRuntimeUtils.checkForJavaExecutable(dir)).isTrue(); | ||
| } | ||
|
|
||
| @Test | ||
| public void returns_false_when_executable_is_missing() throws IOException { | ||
| var dir = temporaryFolder.newFolder().toPath(); | ||
| Files.createDirectory(dir.resolve("bin")); | ||
|
|
||
| assertThat(JavaRuntimeUtils.checkForJavaExecutable(dir)).isFalse(); | ||
| } | ||
|
|
||
| private Path releaseFileWithVersion(String version) throws IOException { | ||
| return releaseFileWith("JAVA_VERSION=\"" + version + "\"\n"); | ||
| } | ||
|
|
||
| private Path releaseFileWith(String content) throws IOException { | ||
| var dir = temporaryFolder.newFolder().toPath(); | ||
| Files.writeString(dir.resolve("release"), content); | ||
| return dir; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.