Browse Source

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
pull/47637/head
Moritz Halbritter 2 months ago
parent
commit
e1f9116684
  1. 1
      build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/pages/reacting.adoc
  2. 28
      core/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
  3. 10
      documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/native-image/developing-your-first-application.adoc
  4. 2
      gradle.properties
  5. 2
      starter/spring-boot-starter-parent/build.gradle

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

@ -87,7 +87,6 @@ When the {url-native-build-tools-docs-gradle-plugin}[GraalVM Native Image plugin @@ -87,7 +87,6 @@ When the {url-native-build-tools-docs-gradle-plugin}[GraalVM Native Image plugin
. Adds the output of the `aot` source set to the classpath of the `main` GraalVM native binary.
. Adds the output of the `aotTest` source set to the classpath of the `test` GraalVM native binary.
. Configures the GraalVM extension to disable Toolchain detection.
. Configures each GraalVM native binary to require GraalVM 22.3 or later.
. Configures the `bootJar` task to include the reachability metadata produced by the `collectReachabilityMetadata` task in its jar.
. Configures the `bootJar` task to add the `Spring-Boot-Native-Processed: true` manifest entry.

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

@ -66,6 +66,7 @@ import org.springframework.boot.context.properties.bind.Binder; @@ -66,6 +66,7 @@ import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
import org.springframework.boot.convert.ApplicationConversionService;
import org.springframework.boot.env.DefaultPropertiesPropertySource;
import org.springframework.boot.system.JavaVersion;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ApplicationListener;
@ -418,6 +419,9 @@ public class SpringApplication { @@ -418,6 +419,9 @@ public class SpringApplication {
}
private void addAotGeneratedInitializerIfNecessary(List<ApplicationContextInitializer<?>> initializers) {
if (NativeDetector.inNativeImage()) {
checkNativeImageVersion();
}
if (AotDetector.useGeneratedArtifacts()) {
List<ApplicationContextInitializer<?>> aotInitializers = new ArrayList<>(
initializers.stream().filter(AotApplicationContextInitializer.class::isInstance).toList());
@ -434,6 +438,15 @@ public class SpringApplication { @@ -434,6 +438,15 @@ public class SpringApplication {
}
}
private void checkNativeImageVersion() {
JavaVersion minRequiredJavaVersion = JavaVersion.TWENTY_FIVE;
if (JavaVersion.getJavaVersion().isOlderThan(minRequiredJavaVersion)) {
throw new NativeImageRequirementsNotMetException(
"Native Image requirements not met, please upgrade it. Native Image must support at least Java %s"
.formatted(minRequiredJavaVersion));
}
}
private void refreshContext(ConfigurableApplicationContext context) {
if (this.properties.isRegisterShutdownHook()) {
shutdownHook.registerApplicationContext(context);
@ -1645,6 +1658,21 @@ public class SpringApplication { @@ -1645,6 +1658,21 @@ public class SpringApplication {
}
/**
* Exception which is thrown if GraalVM's native-image requirements aren't met.
*/
private static final class NativeImageRequirementsNotMetException extends RuntimeException {
/**
* Creates a new {@link NativeImageRequirementsNotMetException} instance.
* @param message the message
*/
private NativeImageRequirementsNotMetException(String message) {
super(message);
}
}
/**
* {@link SpringApplicationHook} decorator that ensures the hook is only used once.
*/

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

@ -175,8 +175,8 @@ Get SDKMAN! from https://sdkman.io and install the Liberica GraalVM distribution @@ -175,8 +175,8 @@ Get SDKMAN! from https://sdkman.io and install the Liberica GraalVM distribution
[source,shell,subs="verbatim,attributes"]
----
$ sdk install java {version-graal}.r17-nik
$ sdk use java {version-graal}.r17-nik
$ sdk install java 25.r25-nik
$ sdk use java 25.r25-nik
----
Verify that the correct version has been configured by checking the output of `java -version`:
@ -184,9 +184,9 @@ Verify that the correct version has been configured by checking the output of `j @@ -184,9 +184,9 @@ Verify that the correct version has been configured by checking the output of `j
[source,shell,subs="verbatim,attributes"]
----
$ java -version
openjdk version "17.0.5" 2022-10-18 LTS
OpenJDK Runtime Environment GraalVM 22.3.0 (build 17.0.5+8-LTS)
OpenJDK 64-Bit Server VM GraalVM 22.3.0 (build 17.0.5+8-LTS, mixed mode)
openjdk version "25" 2025-09-16 LTS
OpenJDK Runtime Environment Liberica-NIK-25.0.0-1 (build 25+37-LTS)
OpenJDK 64-Bit Server VM Liberica-NIK-25.0.0-1 (build 25+37-LTS, mixed mode, sharing)
----

2
gradle.properties

@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8 @@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
assertjVersion=3.27.6
checkstyleToolVersion=10.12.4
commonsCodecVersion=1.19.0
graalVersion=22.3
graalVersion=25
hamcrestVersion=3.0
jackson2Version=2.20.0
jacksonVersion=3.0.0

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

@ -297,7 +297,6 @@ publishing.publications.withType(MavenPublication) { @@ -297,7 +297,6 @@ publishing.publications.withType(MavenPublication) {
delegate.artifactId('native-maven-plugin')
configuration {
delegate.classesDirectory('${project.build.outputDirectory}')
delegate.requiredVersion('22.3')
exclusions {
exclusion {
delegate.groupId('org.springframework.boot')
@ -347,7 +346,6 @@ publishing.publications.withType(MavenPublication) { @@ -347,7 +346,6 @@ publishing.publications.withType(MavenPublication) {
delegate.artifactId('native-maven-plugin')
configuration {
delegate.classesDirectory('${project.build.outputDirectory}')
delegate.requiredVersion('22.3')
exclusions {
exclusion {
delegate.groupId('org.springframework.boot')

Loading…
Cancel
Save