Skip to content

MMF-4428 Use ECJ 3.41 to support Java 23 #5081

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 4 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
common_build_definition: &COMMON_BUILD_DEFINITION
eks_container:
<<: *CONTAINER_DEFINITION
image: ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j22-latest
image: ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j23-latest
cpu: 4
memory: 4G
env:
Expand Down Expand Up @@ -127,14 +127,16 @@

qa_os_win_task:
ec2_instance:
image: base-windows-jdk22-v*
image: base-windows-jdk21-v*
<<: *WINDOWS_VM_DEFINITION
maven_cache:
folder: ${CIRRUS_WORKING_DIR}/.m2/repository
java_download_cache:
folder: ${CIRRUS_WORKING_DIR}/.java_download_cache
build_script:
- *log_develocity_url_script
- source cirrus-env CI
- mvn.cmd clean verify
- ps: .cirrus/install-latest-java-on-windows.ps1 ; if ($?) { & mvn.cmd --batch-mode clean verify }
cleanup_before_cache_script: cleanup_maven_repository

plugin_qa_task:
Expand Down Expand Up @@ -175,7 +177,7 @@
<<: *ONLY_SONARSOURCE_QA
eks_container:
<<: *CONTAINER_DEFINITION
image: ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j22-latest
image: ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j23-latest
cpu: 4
memory: 4G
maven_cache:
Expand Down Expand Up @@ -256,9 +258,9 @@
eks_container:
<<: *CONTAINER_WITH_DOCKER_DEFINITION
# For now, this autoscan_task need to execute two mvn commands:
# * The build of java-checks-test-sources module which requires Java 22.
# * The tests using Orchestrator and SonarQube that, for now, fail to work using Java 22
# This is why we have a local Dockerfile that provide the 2 versions of Java, 17 and 22.
# * The build of java-checks-test-sources module which requires Java 23.
# * The tests using Orchestrator and SonarQube that, for now, fail to work using Java 23
# This is why we have a local Dockerfile that provide the 2 versions of Java, 17 and 23.
cpu: 14
memory: 8G
maven_cache:
Expand All @@ -279,7 +281,7 @@
actual_artifacts:
path: "${CIRRUS_WORKING_DIR}/its/autoscan/target/actual/**/*"

promote_task:

Check warning on line 284 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L284

task "promote" depends on task "ws_scan", but their only_if conditions are different

Check warning on line 284 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L284

task "promote" depends on task "ws_scan", but their only_if conditions are different

Check warning on line 284 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L284

task "promote" depends on task "ws_scan", but their only_if conditions are different

Check warning on line 284 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L284

task "promote" depends on task "ws_scan", but their only_if conditions are different
depends_on:
- build
- test_analyze
Expand Down
14 changes: 7 additions & 7 deletions .cirrus/Dockerfile.jdk17AndLatest
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ USER root
ENV DEBIAN_FRONTEND=noninteractive

# The current image is `FROM public.ecr.aws/docker/library/eclipse-temurin:17-jammy`
# Use a similar method to install Java 22 copied from https://github.com/adoptium/containers/blob/main/22/jdk/ubuntu/jammy/Dockerfile
# Use a similar method to install Java 23 copied from https://github.com/adoptium/containers/blob/main/22/jdk/ubuntu/jammy/Dockerfile

ENV JAVA_LATEST_HOME /opt/java/openjdk22
ENV JAVA_LATEST_VERSION jdk-22.0.2+9
ENV JAVA_LATEST_HOME /opt/java/openjdk23
ENV JAVA_LATEST_VERSION jdk-23.0.1+11

RUN set -eux; \
ARCH="$(dpkg --print-architecture)"; \
case "${ARCH}" in \
amd64) \
ESUM='05cd9359dacb1a1730f7c54f57e0fed47942a5292eb56a3a0ee6b13b87457a43'; \
BINARY_URL='https://github.com/adoptium/temurin22-binaries/releases/download/jdk-22.0.2%2B9/OpenJDK22U-jdk_x64_linux_hotspot_22.0.2_9.tar.gz'; \
ESUM='2400267e4e9c0f6ae880a4d763af6caf18c673714bdee5debf8388b0b5d52886'; \
BINARY_URL='https://github.com/adoptium/temurin23-binaries/releases/download/jdk-23.0.1%2B11/OpenJDK23U-jdk_x64_linux_hotspot_23.0.1_11.tar.gz'; \
;; \
arm64) \
ESUM='dac62747b5158c4bf4c4636432e3bdb9dea47f80f0c9d1d007f19bd5483b7d29'; \
BINARY_URL='https://github.com/adoptium/temurin22-binaries/releases/download/jdk-22.0.2%2B9/OpenJDK22U-jdk_aarch64_linux_hotspot_22.0.2_9.tar.gz'; \
ESUM='0b498a5b673cb50fe9cfd0a13bd39c7259b4fad4d930d614e1563aeb8bca7f0e'; \
BINARY_URL='https://github.com/adoptium/temurin23-binaries/releases/download/jdk-23.0.1%2B11/OpenJDK23U-jre_aarch64_linux_hotspot_23.0.1_11.tar.gz'; \
;; \
*) \
echo "Unsupported arch: ${ARCH}"; \
Expand Down
100 changes: 100 additions & 0 deletions .cirrus/install-latest-java-on-windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
$javaVersion = "23.0.1+11"
$sha256_x64 = "eb1bc62060f17566b160fae8ce876ada5d639e2fd4781009a1219e971b9937dd"
$sha256_aarch64 = "00ea8896d42ac26cb6887eef08cd6e3b2a54f30e9e87b0fc965e66813567ac87"

Write-Output "Installing Java ${javaVersion}"

$javaMajorVersion = ($javaVersion -split '\.')[0]
Write-Output "Major version: ${javaMajorVersion}"

$javaUriVersion = $javaVersion -replace '\+', '%2B'
$javaFileVersion = $javaVersion -replace '\+', '_'
$arch = (Get-WmiObject -Class Win32_Processor).AddressWidth
if ($arch -eq 64) {
$arch = "x64"
$sha256 = $sha256_x64
} else {
$arch = "aarch64"
$sha256 = $sha256_aarch64
}
$zipFileName = "OpenJDK${javaMajorVersion}U-jdk_${arch}_windows_hotspot_${javaFileVersion}.zip"
$binaryUrl = "https://github.com/adoptium/temurin${javaMajorVersion}-binaries/releases/download/jdk-${javaUriVersion}/${zipFileName}"
$javaDownloadDirectory = "${env:CIRRUS_WORKING_DIR}/.java_download_cache"
$zipPath = "${javaDownloadDirectory}\${zipFileName}"
$javaHomeParent = "${env:CIRRUS_WORKING_DIR}/.openjdk"
$javaHome = "${javaHomeParent}\jdk-${javaVersion}"

Write-Output "Prepare download directory: ${javaDownloadDirectory}"
if (-not (Test-Path "${javaDownloadDirectory}")) {
New-Item -ItemType Directory -Path $javaDownloadDirectory -Force
}
$itemsToDelete = Get-ChildItem -Path $javaDownloadDirectory | Where-Object { $_.Name -ne $zipFileName }
foreach ($item in $itemsToDelete) {
Write-Output "Remove: ${item}"
Remove-Item -Path $item.FullName -Recurse -Force
}

Write-Output "Prepare installation directory: ${javaHomeParent}"
if (-not (Test-Path "${javaHomeParent}")) {
New-Item -ItemType Directory -Path $javaHomeParent -Force
}
Write-Output "Remove other jdk in ${javaHomeParent}"
$itemsToDelete = Get-ChildItem -Path $javaHomeParent | Where-Object { $_.Name -ne "jdk-${javaVersion}" }
foreach ($item in $itemsToDelete) {
Write-Output "Remove: $item"
Remove-Item -Path $item.FullName -Recurse -Force
}

if (-not (Test-Path "${javaHome}\bin\java.exe")) {
if (Test-Path $zipPath) {
Write-Output "Zip '$zipPath' already exists."
} else {
Write-Output "Download from '$binaryUrl' into '$zipPath'"
Invoke-WebRequest -Uri $binaryUrl -OutFile $zipPath -UseBasicParsing > $null

# Verify the checksum
Write-Output "Check the sha256 checksum of $zipPath"
$actualChecksum = Get-FileHash -Path $zipPath -Algorithm SHA256 | Select-Object -ExpandProperty Hash
if ($actualChecksum -ne $sha256) {
Write-Error "Checksum verification failed. Expected: $expectedChecksum, Actual: $actualChecksum"
exit 1
} else {
Write-Output "Checksum verification passed."
}
}

# Extract the zip file
Write-Output "Extract JDK archive"
$global:ProgressPreference = "SilentlyContinue"
Expand-Archive -Path $zipPath -DestinationPath $javaHomeParent -Force > $null

# Check if java is present
if (-not (Test-Path "${javaHome}\bin\java.exe")) {
Write-Error "Fail to find ${javaHome}\bin\java.exe in the extracted directory"
exit 1
}
} else {
Write-Output "Java already installed in ${javaHome}"
}

# Set JAVA_HOME
Write-Output "Set JAVA_HOME to $javaHome"
$env:JAVA_HOME = "${javaHome}"

# Set PATH
$javaBinPath = "${env:JAVA_HOME}\bin"

if ($env:Path -split ';' -contains $javaBinPath) {
Write-Output "The path $javaBinPath is already in the Path environment variable."
} else {
Write-Output "Adding $javaBinPath to the Path environment variable."
$env:Path = "$javaBinPath;$env:Path"
}

# Print the version
Write-Output "java.exe --version"
& "${env:JAVA_HOME}\bin\java.exe" --version

Write-Output "-- Java ${javaVersion} Installed Successfully --"

exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void javaCheckTestSources() throws Exception {
.setSourceEncoding("UTF-8")
.setSourceDirs("aws/src/main/java/,default/src/main/java/,java-17/src/main/java/,spring-3.2/src/main/java/,spring-web-4.0/src/main/java/")
.setTestDirs("default/src/test/java/,test-classpath-reader/src/test/java")
.setProperty("sonar.java.source", "22")
.setProperty("sonar.java.source", "23")
// common properties
.setProperty("sonar.cpd.exclusions", "**/*")
.setProperty("sonar.skipPackageDesign", "true")
Expand Down Expand Up @@ -195,7 +195,7 @@ public void javaCheckTestSources() throws Exception {
SoftAssertions softly = new SoftAssertions();
softly.assertThat(newDiffs).containsExactlyInAnyOrderElementsOf(knownDiffs.values());
softly.assertThat(newTotal).isEqualTo(knownTotal);
softly.assertThat(rulesCausingFPs).hasSize(8);
softly.assertThat(rulesCausingFPs).hasSize(9);
softly.assertThat(rulesNotReporting).hasSize(11);

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ruleKey": "S1128",
"hasTruePositives": true,
"falseNegatives": 33,
"falseNegatives": 36,
"falsePositives": 0
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ruleKey": "S5738",
"hasTruePositives": true,
"falseNegatives": 1,
"falseNegatives": 4,
"falsePositives": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"ruleKey": "S6204",
"hasTruePositives": true,
"falseNegatives": 0,
"falsePositives": 0
}
"falsePositives": 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,25 @@ public RequestHandlerImpl() throws SQLException {
@SneakyThrows
@Override
public Void handleRequest(Object o, Context context) {
S3Client s3Client = S3Client.builder().region(Region.EU_CENTRAL_1).build(); // Noncompliant {{Instantiate this client outside the Lambda function.}}
// ^^^^^
S3Client.builder().build(); // Noncompliant {{Instantiate this client outside the Lambda function.}}
// ^^^^^
MachineLearningClient.builder().build(); // Noncompliant {{Instantiate this client outside the Lambda function.}}
// ^^^^^
DriverManager.getConnection("foo"); // Noncompliant {{Instantiate this database connection outside the Lambda function.}}
// ^^^^^^^^^^^^^
var customClient = new FooClient(); // Noncompliant {{Instantiate this client outside the Lambda function.}}
// ^^^^^^^^^
var compliant = new Object();
build();

called();
return null;
try {
S3Client s3Client = S3Client.builder().region(Region.EU_CENTRAL_1).build(); // Noncompliant {{Instantiate this client outside the Lambda function.}}
// ^^^^^
S3Client.builder().build(); // Noncompliant {{Instantiate this client outside the Lambda function.}}
// ^^^^^
MachineLearningClient.builder().build(); // Noncompliant {{Instantiate this client outside the Lambda function.}}
// ^^^^^
DriverManager.getConnection("foo"); // Noncompliant {{Instantiate this database connection outside the Lambda function.}}
// ^^^^^^^^^^^^^
var customClient = new FooClient(); // Noncompliant {{Instantiate this client outside the Lambda function.}}
// ^^^^^^^^^
var compliant = new Object();
build();

called();
return null;
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

// Similar signature but not same:
Expand Down Expand Up @@ -110,13 +114,17 @@ public RequestStreamHandlerImpl() throws SQLException {
@SneakyThrows
@Override
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException {
S3Client s3Client = S3Client.builder().region(Region.EU_CENTRAL_1).build(); // Noncompliant
S3Client.builder().build(); // Noncompliant
MachineLearningClient.builder().build(); // Noncompliant
var customClient = new FooClient(); // Noncompliant
DriverManager.getConnection("foo"); // Noncompliant

called();
try {
S3Client s3Client = S3Client.builder().region(Region.EU_CENTRAL_1).build(); // Noncompliant
S3Client.builder().build(); // Noncompliant
MachineLearningClient.builder().build(); // Noncompliant
var customClient = new FooClient(); // Noncompliant
DriverManager.getConnection("foo"); // Noncompliant

called();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

// Similar signature but not same:
Expand Down
15 changes: 11 additions & 4 deletions java-checks-test-sources/default/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<version>1.18.38</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
Expand Down Expand Up @@ -1025,9 +1025,16 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>22</release>
<source>22</source>
<target>22</target>
<release>23</release>
<source>23</source>
<target>23</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.38</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package a.b.c;

public class ReferencedFromMarkdown {
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ void foo(
tg.setDaemon(true); // Compliant
tg.list(); // Compliant
tg.parentOf(tg); // Compliant
tg.resume(); // Compliant
tg.setMaxPriority(0); // Compliant
tg.stop(); // Compliant
tg.suspend(); // Compliant
tg.uncaughtException(new Thread(), new Exception()); // Compliant
tg.toString(); // Compliant
tg.equals(o); // Compliant - not overridden in ThreadGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@
// TODO

// Noncompliant@+1
// TODO Explenation
// TODO Explanation

// Noncompliant@+1
// [TODO]

// Noncompliant@+1
/// TODO Explanation

// Noncompliant@+1
//// TODO Explanation

// PreTodo
// toDomain
package checks;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import a.b.c.Baz;
import a.b.c.Qux;
import a.b.c.ReferencedFromJavadoc;
import a.b.c.ReferencedFromMarkdown;
import java.util.Map;
import java.util.Map.Entry;
import a.b.c.NotReferencedFromJavadoc; // Noncompliant
Expand Down Expand Up @@ -84,6 +85,8 @@ public Class<? extends Annotation> annotationType() {
}
};
}
/// This method reference has
/// a reference on [ReferencedFromMarkdown]
void foo(@Nullable int x){
System.out.println(FLUP);;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
abstract class DisallowedThreadGroupCheck {
void method_removed_in_java_21(ThreadGroup tg) { // Noncompliant
tg.allowThreadSuspension(true); // Compliant, Note: the "allowThreadSuspension" has been removed in Java 21
tg.resume(); // Compliant, Note: the "resume" has been removed in Java 23
tg.stop(); // Compliant, Note: the "stop" has been removed in Java 23
tg.suspend(); // Compliant, Note: the "suspend" has been removed in Java 23
}
}
6 changes: 3 additions & 3 deletions java-checks-test-sources/spring-3.2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>22</release>
<source>22</source>
<target>22</target>
<release>23</release>
<source>23</source>
<target>23</target>
</configuration>
</plugin>
<plugin>
Expand Down
Loading