From e7c866d9e5aa4c7e2050182878298e07649ebe09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Coet?= Date: Wed, 26 Aug 2026 08:43:08 +0200 Subject: [PATCH] Upgrade the minimum Java version to 21 --- README.md | 1 - docs/java-custom-rules-example/pom.xml | 4 ++-- pom.xml | 2 +- sonar-java-plugin/pom.xml | 2 +- .../src/main/resources/static/documentation.md | 13 +++++++++---- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ad557bd79d5..df0e07d6706 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,6 @@ To run tests locally follow these instructions. ### Java versions You need `Java 26` to compile and run the Unit Tests of the project and `Java 21` run most Integration Tests (ITs). -Ruling test on Guava project require `Java 17`. Note that `Java 21` can be used to build and test all modules except under `java-checks-test-sources` (as they require `Java 26`). If you are adding or moving rule test samples, see [java-checks-test-sources/README.md](java-checks-test-sources/README.md) for guidance on when samples belong in the dedicated test-source modules instead of `java-checks/src/test/files`. diff --git a/docs/java-custom-rules-example/pom.xml b/docs/java-custom-rules-example/pom.xml index 78a243f2ac9..cabbe0bd93a 100644 --- a/docs/java-custom-rules-example/pom.xml +++ b/docs/java-custom-rules-example/pom.xml @@ -109,8 +109,8 @@ org.apache.maven.plugins maven-compiler-plugin - 17 - 17 + 21 + 21 diff --git a/pom.xml b/pom.xml index 47395eb5492..5f30b6f3889 100644 --- a/pom.xml +++ b/pom.xml @@ -82,7 +82,7 @@ SonarQube Java - 17 + 21 true diff --git a/sonar-java-plugin/pom.xml b/sonar-java-plugin/pom.xml index b850dbaaa9c..330121d96b1 100644 --- a/sonar-java-plugin/pom.xml +++ b/sonar-java-plugin/pom.xml @@ -169,7 +169,7 @@ java,jsp,kotlin true 9.14.0.375 - 17 + 21 ${project.version} diff --git a/sonar-java-plugin/src/main/resources/static/documentation.md b/sonar-java-plugin/src/main/resources/static/documentation.md index 92f286366fb..2702ed40391 100644 --- a/sonar-java-plugin/src/main/resources/static/documentation.md +++ b/sonar-java-plugin/src/main/resources/static/documentation.md @@ -38,20 +38,20 @@ Key | Value ## Project's specific JDK In some situations, you might have to analyze a project built with a different version of Java than the one executing the analysis. -The most common case is to run the analysis with **Java 17**, while the project itself uses **Java 11** or before for its build. +The most common case is to run the analysis with **Java 21**, while the project itself uses **Java 17** or before for its build. If this is your case, you will need to set the `sonar.java.jdkHome` property manually to point the appropriate JDK (see below). By doing this you will specify which JDK classes the analyzer must refer to during the analysis. Not setting this property, while it would have been required, usually leads to inconsistent or even impossible to fix issues being reported, especially in relation with native JDK classes. When setting `sonar.java.jdkHome`, you need to provide the path to the JDK directory used by the project being analyzed, if different from the Java runtime executing the analysis. -For example, for a Java 11 project, by setting it as follows: `sonar.java.jdkHome=/usr/lib/jvm/jdk11.0.22` +For example, for a Java 17 project, by setting it as follows: `sonar.java.jdkHome=/usr/lib/jvm/jdk17.0.11` ```bash -# Here maven uses the default version of Java on the system but we specify that we want to analyze a Java 11 project. +# Here maven uses the default version of Java on the system but we specify that we want to analyze a Java 17 project. mvn clean verify sonar:sonar \ # other analysis parameters - -Dsonar.java.jdkHome=/usr/lib/jvm/jdk11.0.22/ + -Dsonar.java.jdkHome=/usr/lib/jvm/jdk17.0.11/ # other analysis parameters ``` This option can of course be added to your `sonar.properties` configuration. @@ -151,6 +151,11 @@ The tutorial [Writing Custom Java Rules 101](https://redirect.sonarsource.com/do ### API changes +#### **8.41** + +**Breaking** +The Java analyzer now requires `Java 21` to run. + #### **8.22** * New method: `ModuleMetadataUtils#getFullyQualifiedModuleKey(@Nullable ProjectDefinition current)`.