Skip to content

Commit e1f9116

Browse files
committed
Raise GraalVM baseline to 25
This also removes the 'requiredVersion' setting from the native-maven-plugin configuration, as this is deprecated in the native build tools. Close gh-47433
1 parent 712389b commit e1f9116

5 files changed

Lines changed: 34 additions & 9 deletions

File tree

build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/pages/reacting.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ When the {url-native-build-tools-docs-gradle-plugin}[GraalVM Native Image plugin
8787
. Adds the output of the `aot` source set to the classpath of the `main` GraalVM native binary.
8888
. Adds the output of the `aotTest` source set to the classpath of the `test` GraalVM native binary.
8989
. Configures the GraalVM extension to disable Toolchain detection.
90-
. Configures each GraalVM native binary to require GraalVM 22.3 or later.
9190
. Configures the `bootJar` task to include the reachability metadata produced by the `collectReachabilityMetadata` task in its jar.
9291
. Configures the `bootJar` task to add the `Spring-Boot-Native-Processed: true` manifest entry.
9392

core/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
6767
import org.springframework.boot.convert.ApplicationConversionService;
6868
import org.springframework.boot.env.DefaultPropertiesPropertySource;
69+
import org.springframework.boot.system.JavaVersion;
6970
import org.springframework.context.ApplicationContext;
7071
import org.springframework.context.ApplicationContextInitializer;
7172
import org.springframework.context.ApplicationListener;
@@ -418,6 +419,9 @@ private void prepareContext(DefaultBootstrapContext bootstrapContext, Configurab
418419
}
419420

420421
private void addAotGeneratedInitializerIfNecessary(List<ApplicationContextInitializer<?>> initializers) {
422+
if (NativeDetector.inNativeImage()) {
423+
checkNativeImageVersion();
424+
}
421425
if (AotDetector.useGeneratedArtifacts()) {
422426
List<ApplicationContextInitializer<?>> aotInitializers = new ArrayList<>(
423427
initializers.stream().filter(AotApplicationContextInitializer.class::isInstance).toList());
@@ -434,6 +438,15 @@ private void addAotGeneratedInitializerIfNecessary(List<ApplicationContextInitia
434438
}
435439
}
436440

441+
private void checkNativeImageVersion() {
442+
JavaVersion minRequiredJavaVersion = JavaVersion.TWENTY_FIVE;
443+
if (JavaVersion.getJavaVersion().isOlderThan(minRequiredJavaVersion)) {
444+
throw new NativeImageRequirementsNotMetException(
445+
"Native Image requirements not met, please upgrade it. Native Image must support at least Java %s"
446+
.formatted(minRequiredJavaVersion));
447+
}
448+
}
449+
437450
private void refreshContext(ConfigurableApplicationContext context) {
438451
if (this.properties.isRegisterShutdownHook()) {
439452
shutdownHook.registerApplicationContext(context);
@@ -1645,6 +1658,21 @@ public AbandonedRunException(@Nullable ConfigurableApplicationContext applicatio
16451658

16461659
}
16471660

1661+
/**
1662+
* Exception which is thrown if GraalVM's native-image requirements aren't met.
1663+
*/
1664+
private static final class NativeImageRequirementsNotMetException extends RuntimeException {
1665+
1666+
/**
1667+
* Creates a new {@link NativeImageRequirementsNotMetException} instance.
1668+
* @param message the message
1669+
*/
1670+
private NativeImageRequirementsNotMetException(String message) {
1671+
super(message);
1672+
}
1673+
1674+
}
1675+
16481676
/**
16491677
* {@link SpringApplicationHook} decorator that ensures the hook is only used once.
16501678
*/

documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/native-image/developing-your-first-application.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,18 @@ Get SDKMAN! from https://sdkman.io and install the Liberica GraalVM distribution
175175

176176
[source,shell,subs="verbatim,attributes"]
177177
----
178-
$ sdk install java {version-graal}.r17-nik
179-
$ sdk use java {version-graal}.r17-nik
178+
$ sdk install java 25.r25-nik
179+
$ sdk use java 25.r25-nik
180180
----
181181

182182
Verify that the correct version has been configured by checking the output of `java -version`:
183183

184184
[source,shell,subs="verbatim,attributes"]
185185
----
186186
$ java -version
187-
openjdk version "17.0.5" 2022-10-18 LTS
188-
OpenJDK Runtime Environment GraalVM 22.3.0 (build 17.0.5+8-LTS)
189-
OpenJDK 64-Bit Server VM GraalVM 22.3.0 (build 17.0.5+8-LTS, mixed mode)
187+
openjdk version "25" 2025-09-16 LTS
188+
OpenJDK Runtime Environment Liberica-NIK-25.0.0-1 (build 25+37-LTS)
189+
OpenJDK 64-Bit Server VM Liberica-NIK-25.0.0-1 (build 25+37-LTS, mixed mode, sharing)
190190
----
191191

192192

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
99
assertjVersion=3.27.6
1010
checkstyleToolVersion=10.12.4
1111
commonsCodecVersion=1.19.0
12-
graalVersion=22.3
12+
graalVersion=25
1313
hamcrestVersion=3.0
1414
jackson2Version=2.20.0
1515
jacksonVersion=3.0.0

starter/spring-boot-starter-parent/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ publishing.publications.withType(MavenPublication) {
297297
delegate.artifactId('native-maven-plugin')
298298
configuration {
299299
delegate.classesDirectory('${project.build.outputDirectory}')
300-
delegate.requiredVersion('22.3')
301300
exclusions {
302301
exclusion {
303302
delegate.groupId('org.springframework.boot')
@@ -347,7 +346,6 @@ publishing.publications.withType(MavenPublication) {
347346
delegate.artifactId('native-maven-plugin')
348347
configuration {
349348
delegate.classesDirectory('${project.build.outputDirectory}')
350-
delegate.requiredVersion('22.3')
351349
exclusions {
352350
exclusion {
353351
delegate.groupId('org.springframework.boot')

0 commit comments

Comments
 (0)