Skip to content

Commit 048b6bd

Browse files
committed
Update to JDK 25 (release = 17)
This commit updates the build to use JDK 25 while remaining compatable with JDK 17. Note that we must update our JAAS related tests to use release=25 due to the disabling of the Security Manager. See https://docs.oracle.com/en/java/javase/25/security/security-manager-is-permanently-disabled.html Closes gh-18512
1 parent 6e9b4f8 commit 048b6bd

11 files changed

Lines changed: 53 additions & 17 deletions

File tree

.github/workflows/check-snapshots.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ jobs:
1818
strategy:
1919
matrix:
2020
include:
21-
- java-version: 21-ea
22-
toolchain: 21
23-
- java-version: 17
24-
toolchain: 17
21+
- java-version: 25
22+
toolchain: 25
2523
with:
2624
java-version: ${{ matrix.java-version }}
2725
test-args: --refresh-dependencies -PforceMavenRepositories=snapshot,https://oss.sonatype.org/content/repositories/snapshots -PisOverrideVersionCatalog -PtestToolchain=${{ matrix.toolchain }} -PspringFrameworkVersion=7.+ -PreactorVersion=2025.+ -PspringDataVersion=2025.+ --stacktrace

.github/workflows/continuous-integration-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
strategy:
2222
matrix:
2323
os: [ ubuntu-latest, windows-latest ]
24-
jdk: [ 17 ]
24+
jdk: [ 25 ]
2525
with:
2626
runs-on: ${{ matrix.os }}
2727
java-version: ${{ matrix.jdk }}

.github/workflows/gradle-wrapper-upgrade-execution.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
2121
- name: Checkout
2222
uses: actions/checkout@v4
23-
- name: Set up JDK 17
23+
- name: Set up JDK 25
2424
uses: actions/setup-java@v4
2525
with:
26-
java-version: '17'
26+
java-version: '25'
2727
distribution: 'temurin'
2828
- name: Set up Gradle
2929
uses: gradle/gradle-build-action@v2

.github/workflows/pr-build-workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up gradle
1616
uses: spring-io/spring-gradle-build-action@v2
1717
with:
18-
java-version: '17'
18+
java-version: '25'
1919
distribution: 'temurin'
2020
- name: Build with Gradle
2121
run: ./gradlew clean build -PskipCheckExpectedBranchVersion --continue --scan
@@ -28,7 +28,7 @@ jobs:
2828
- name: Set up gradle
2929
uses: spring-io/spring-gradle-build-action@v2
3030
with:
31-
java-version: '17'
31+
java-version: '25'
3232
distribution: 'temurin'
3333
- name: Run Antora
3434
run: ./gradlew -PbuildSrc.skipTests=true :spring-security-docs:antora

.sdkmanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# See https://sdkman.io/usage#config
44
# A summary is to add the following to ~/.sdkman/etc/config
55
# sdkman_auto_env=true
6-
java=17.0.3-tem
6+
java=25-librca

build.gradle

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import io.spring.gradle.IncludeRepoTask
2+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
23
import trang.RncToXsd
4+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
35

46
buildscript {
57
dependencies {
@@ -50,7 +52,7 @@ def toolchainVersion() {
5052
if (project.hasProperty('testToolchain')) {
5153
return project.property('testToolchain').toString().toInteger()
5254
}
53-
return 17
55+
return 25
5456
}
5557

5658
subprojects {
@@ -61,14 +63,20 @@ subprojects {
6163
}
6264
kotlin {
6365
jvmToolchain {
64-
languageVersion = JavaLanguageVersion.of(17)
66+
languageVersion = JavaLanguageVersion.of(toolchainVersion())
6567
}
6668
}
6769
tasks.withType(JavaCompile).configureEach {
6870
options.encoding = "UTF-8"
6971
options.compilerArgs.add("-parameters")
7072
options.release.set(17)
7173
}
74+
tasks.withType(KotlinCompile).configureEach {
75+
compilerOptions {
76+
javaParameters = true
77+
jvmTarget.set(JvmTarget.JVM_17)
78+
}
79+
}
7280
}
7381

7482
allprojects {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import org.gradle.api.tasks.compile.JavaCompile
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
4+
/**
5+
* We need to compile with JDK 25 for nullability support, but using JDK 25 means that our tests will fail due to the
6+
* <a href="https://docs.oracle.com/en/java/javase/25/security/security-manager-is-permanently-disabled.html">removal
7+
* of the Java Security Manager</a>. For example, in JDK 25 {@code Subject.getSubject(AccessControlContext)} throws an
8+
* {@code UnsupportedOperationException}.
9+
*
10+
* To resolve this, we must migrate tests to use the new APIs (e.g. {@code Subject.current()}) but those APIs are not
11+
* available in the JDK 17 source, so compiling with JDK 25 and release 17 fails. The plugin overrides the test
12+
* compilation to use release 25.
13+
*
14+
* @see <a href="https://docs.oracle.com/en/java/javase/25/security/security-manager-is-permanently-disabled.html">The
15+
* Security Manager Is Permanently Disabled</a>
16+
* @see <a href="https://inside.java/2024/07/08/quality-heads-up/">Quality Outreach Heads-up - JDK 23: Re-Specified
17+
* Subject.getSubject API</a>
18+
*/
19+
20+
tasks.withType(JavaCompile).configureEach { task ->
21+
if (task.name == 'compileTestJava' || task.name == 'compileIntegrationTestJava') {
22+
task.options.release.set(25)
23+
}
24+
}
25+
26+
tasks.withType(KotlinCompile).configureEach { task ->
27+
if (task.name == 'compileTestKotlin' || task.name == 'compileIntegrationTestKotlin') {
28+
task.kotlinOptions.jvmTarget = '25'
29+
}
30+
}

config/spring-security-config.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import trang.RncToXsd
44
apply plugin: 'io.spring.convention.spring-module'
55
apply plugin: 'trang'
66
apply plugin: 'security-kotlin'
7+
apply plugin: 'test-compile-target-jdk25'
78

89
configurations {
910
opensaml5 {

config/src/test/java/org/springframework/security/config/http/MiscHttpConfigTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.io.ByteArrayOutputStream;
2020
import java.io.IOException;
2121
import java.io.OutputStream;
22-
import java.security.AccessController;
2322
import java.security.Principal;
2423
import java.security.cert.X509Certificate;
2524
import java.util.Arrays;
@@ -989,7 +988,7 @@ static class JaasController {
989988

990989
@GetMapping("/username")
991990
String username() {
992-
Subject subject = Subject.getSubject(AccessController.getContext());
991+
Subject subject = Subject.current();
993992
return subject.getPrincipals().iterator().next().getName();
994993
}
995994

web/spring-security-web.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'security-nullability'
33
id 'javadoc-warnings-error'
4+
id 'test-compile-target-jdk25'
45
}
56

67
apply plugin: 'io.spring.convention.spring-module'

0 commit comments

Comments
 (0)