From a6396850530567a1131d1ce79dee404fe1193c6f Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Sat, 18 Jun 2022 13:35:14 +0200 Subject: [PATCH] Remove obsolete Java compatibility code See gh-31452 --- .../boot/gradle/tasks/run/BootRun.java | 19 ------------------- .../tasks/run/BootRunIntegrationTests.java | 18 +++--------------- .../boot/maven/RunIntegrationTests.java | 13 +------------ .../springframework/boot/maven/RunMojo.java | 13 ------------- .../build.gradle | 6 ++---- 5 files changed, 6 insertions(+), 63 deletions(-) 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 a0c46a4676..5a4731ae6e 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 @@ -17,16 +17,13 @@ package org.springframework.boot.gradle.tasks.run; import java.io.File; -import java.lang.reflect.Method; import java.util.Set; import org.gradle.api.file.SourceDirectorySet; -import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.JavaExec; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetOutput; -import org.gradle.jvm.toolchain.JavaLauncher; import org.gradle.work.DisableCachingByDefault; /** @@ -78,9 +75,6 @@ public class BootRun extends JavaExec { public void exec() { if (this.optimizedLaunch) { setJvmArgs(getJvmArgs()); - if (!isJava13OrLater()) { - jvmArgs("-Xverify:none"); - } jvmArgs("-XX:TieredStopAtLevel=1"); } if (System.console() != null) { @@ -90,17 +84,4 @@ public class BootRun extends JavaExec { super.exec(); } - private boolean isJava13OrLater() { - Property javaLauncher = this.getJavaLauncher(); - if (javaLauncher.isPresent()) { - return javaLauncher.get().getMetadata().getLanguageVersion().asInt() >= 13; - } - 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-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/run/BootRunIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/run/BootRunIntegrationTests.java index f58042d5d4..05e78bbd44 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/run/BootRunIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/run/BootRunIntegrationTests.java @@ -24,7 +24,6 @@ import java.util.jar.Attributes; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; -import org.gradle.api.JavaVersion; import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.TaskOutcome; import org.junit.jupiter.api.TestTemplate; @@ -96,12 +95,7 @@ class BootRunIntegrationTests { copyJvmArgsApplication(); BuildResult result = this.gradleBuild.build("bootRun"); assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_13)) { - assertThat(result.getOutput()).contains("-XX:TieredStopAtLevel=1"); - } - else { - assertThat(result.getOutput()).contains("-Xverify:none").contains("-XX:TieredStopAtLevel=1"); - } + assertThat(result.getOutput()).contains("-XX:TieredStopAtLevel=1"); } @TestTemplate @@ -117,14 +111,8 @@ class BootRunIntegrationTests { copyJvmArgsApplication(); BuildResult result = this.gradleBuild.build("bootRun"); assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_13)) { - assertThat(result.getOutput()).contains("-Dcom.bar=baz").contains("-Dcom.foo=bar") - .contains("-XX:TieredStopAtLevel=1"); - } - else { - assertThat(result.getOutput()).contains("-Dcom.bar=baz").contains("-Dcom.foo=bar").contains("-Xverify:none") - .contains("-XX:TieredStopAtLevel=1"); - } + assertThat(result.getOutput()).contains("-Dcom.bar=baz").contains("-Dcom.foo=bar") + .contains("-XX:TieredStopAtLevel=1"); } @TestTemplate diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/RunIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/RunIntegrationTests.java index dd7ce477eb..742801cef5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/RunIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/RunIntegrationTests.java @@ -17,7 +17,6 @@ package org.springframework.boot.maven; import java.io.File; -import java.lang.reflect.Method; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.condition.DisabledOnOs; @@ -38,8 +37,7 @@ class RunIntegrationTests { @TestTemplate void whenTheRunGoalIsExecutedTheApplicationIsForkedWithOptimizedJvmArguments(MavenBuild mavenBuild) { mavenBuild.project("run").goals("spring-boot:run", "-X").execute((project) -> { - String jvmArguments = isJava13OrLater() ? "JVM argument(s): -XX:TieredStopAtLevel=1" - : "JVM argument(s): -Xverify:none -XX:TieredStopAtLevel=1"; + String jvmArguments = "JVM argument(s): -XX:TieredStopAtLevel=1"; assertThat(buildLog(project)).contains("I haz been run").contains(jvmArguments); }); } @@ -136,13 +134,4 @@ class RunIntegrationTests { return contentOf(new File(project, "target/build.log")); } - 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 47844341ce..eb2ff574d2 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,7 +17,6 @@ package org.springframework.boot.maven; import java.io.File; -import java.lang.reflect.Method; import java.util.List; import java.util.Map; @@ -56,22 +55,10 @@ public class RunMojo extends AbstractApplicationRunMojo { RunArguments jvmArguments = super.resolveJvmArguments(); if (this.optimizedLaunch) { jvmArguments.getArgs().addFirst("-XX:TieredStopAtLevel=1"); - 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 run(File workingDirectory, List args, Map environmentVariables) throws MojoExecutionException { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webservices/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webservices/build.gradle index 853e4c2877..ceb139e5e6 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webservices/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webservices/build.gradle @@ -11,10 +11,8 @@ dependencies { runtimeOnly("jaxen:jaxen") runtimeOnly("wsdl4j:wsdl4j") - if (JavaVersion.current().java11Compatible) { - runtimeOnly("jakarta.activation:jakarta.activation-api") - runtimeOnly("org.glassfish.jaxb:jaxb-runtime") - } + runtimeOnly("jakarta.activation:jakarta.activation-api") + runtimeOnly("org.glassfish.jaxb:jaxb-runtime") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.springframework.ws:spring-ws-test")