diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/run/BootRun.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/run/BootRun.java index 99eea75b40..b7e9efc882 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/run/BootRun.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/run/BootRun.java @@ -16,6 +16,9 @@ package org.springframework.boot.gradle.tasks.run; +import java.lang.reflect.Method; + +import org.gradle.api.JavaVersion; import org.gradle.api.file.SourceDirectorySet; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.JavaExec; @@ -69,7 +72,11 @@ public class BootRun extends JavaExec { public void exec() { if (this.optimizedLaunch) { setJvmArgs(getJvmArgs()); - jvmArgs("-Xverify:none", "-XX:TieredStopAtLevel=1"); + JavaVersion.current(); + if (!isJava13OrLater()) { + jvmArgs("-Xverify:none"); + } + jvmArgs("-XX:TieredStopAtLevel=1"); } if (System.console() != null) { // Record that the console is available here for AnsiOutput to detect later @@ -78,4 +85,13 @@ public class BootRun extends JavaExec { super.exec(); } + private boolean isJava13OrLater() { + for (Method method : String.class.getMethods()) { + if (method.getName().equals("stripIndent")) { + return true; + } + } + return false; + } + } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java index a8ca5d8f1f..6ece2797a0 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java @@ -17,6 +17,7 @@ package org.springframework.boot.maven; import java.io.File; +import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; import java.util.List; @@ -81,11 +82,22 @@ public class RunMojo extends AbstractRunMojo { RunArguments jvmArguments = super.resolveJvmArguments(); if (isFork() && this.optimizedLaunch) { jvmArguments.getArgs().addFirst("-XX:TieredStopAtLevel=1"); - jvmArguments.getArgs().addFirst("-Xverify:none"); + if (!isJava13OrLater()) { + jvmArguments.getArgs().addFirst("-Xverify:none"); + } } return jvmArguments; } + private boolean isJava13OrLater() { + for (Method method : String.class.getMethods()) { + if (method.getName().equals("stripIndent")) { + return true; + } + } + return false; + } + @Override protected void runWithForkedJvm(File workingDirectory, List args, Map environmentVariables) throws MojoExecutionException {