Raise the minimum supported version of Java to 17

Closes gh-28101
pull/28862/head
Andy Wilkinson 3 years ago
parent 99f33ede14
commit 900085628a

@ -10,8 +10,8 @@ repositories {
maven { url "https://repo.spring.io/release" } maven { url "https://repo.spring.io/release" }
} }
sourceCompatibility = 1.8 sourceCompatibility = 17
targetCompatibility = 1.8 targetCompatibility = 17
dependencies { dependencies {
checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}" checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}"
@ -22,8 +22,8 @@ dependencies {
implementation("org.gradle:test-retry-gradle-plugin:1.1.9") implementation("org.gradle:test-retry-gradle-plugin:1.1.9")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0")
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.0") implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.0")
implementation("org.springframework:spring-core:5.2.2.RELEASE") implementation("org.springframework:spring-core:5.3.10")
implementation("org.springframework:spring-web:5.2.2.RELEASE") implementation("org.springframework:spring-web:5.3.10")
implementation("io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}") implementation("io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}")
testImplementation("org.assertj:assertj-core:3.11.1") testImplementation("org.assertj:assertj-core:3.11.1")
testImplementation("org.apache.logging.log4j:log4j-core:2.12.1") testImplementation("org.apache.logging.log4j:log4j-core:2.12.1")

@ -45,6 +45,7 @@ import org.gradle.api.tasks.bundling.Jar;
import org.gradle.api.tasks.compile.JavaCompile; import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.api.tasks.javadoc.Javadoc; import org.gradle.api.tasks.javadoc.Javadoc;
import org.gradle.api.tasks.testing.Test; import org.gradle.api.tasks.testing.Test;
import org.gradle.external.javadoc.CoreJavadocOptions;
import org.gradle.testretry.TestRetryPlugin; import org.gradle.testretry.TestRetryPlugin;
import org.gradle.testretry.TestRetryTaskExtension; import org.gradle.testretry.TestRetryTaskExtension;
@ -59,7 +60,7 @@ import org.springframework.util.StringUtils;
* plugin is applied: * plugin is applied:
* *
* <ul> * <ul>
* <li>The project is configured with source and target compatibility of 1.8 * <li>The project is configured with source and target compatibility of 17
* <li>{@link SpringJavaFormatPlugin Spring Java Format}, {@link CheckstylePlugin * <li>{@link SpringJavaFormatPlugin Spring Java Format}, {@link CheckstylePlugin
* Checkstyle}, {@link TestFailuresPlugin Test Failures}, and {@link TestRetryPlugin Test * Checkstyle}, {@link TestFailuresPlugin Test Failures}, and {@link TestRetryPlugin Test
* Retry} plugins are applied * Retry} plugins are applied
@ -74,9 +75,9 @@ import org.springframework.util.StringUtils;
* {@link JavaPlugin} applied * {@link JavaPlugin} applied
* <li>{@link JavaCompile}, {@link Javadoc}, and {@link Format} tasks are configured to * <li>{@link JavaCompile}, {@link Javadoc}, and {@link Format} tasks are configured to
* use UTF-8 encoding * use UTF-8 encoding
* <li>{@link JavaCompile} tasks are configured to use {@code -parameters}. * <li>{@link JavaCompile} tasks are configured to:
* <li>When building with Java 8, {@link JavaCompile} tasks are also configured to:
* <ul> * <ul>
* <li>Use {@code -parameters}.
* <li>Treat warnings as errors * <li>Treat warnings as errors
* <li>Enable {@code unchecked}, {@code deprecation}, {@code rawtypes}, and {@code varags} * <li>Enable {@code unchecked}, {@code deprecation}, {@code rawtypes}, and {@code varags}
* warnings * warnings
@ -102,7 +103,7 @@ import org.springframework.util.StringUtils;
*/ */
class JavaConventions { class JavaConventions {
private static final String SOURCE_AND_TARGET_COMPATIBILITY = "1.8"; private static final String SOURCE_AND_TARGET_COMPATIBILITY = "17";
void apply(Project project) { void apply(Project project) {
project.getPlugins().withType(JavaBasePlugin.class, (java) -> { project.getPlugins().withType(JavaBasePlugin.class, (java) -> {
@ -178,7 +179,12 @@ class JavaConventions {
} }
private void configureJavadocConventions(Project project) { private void configureJavadocConventions(Project project) {
project.getTasks().withType(Javadoc.class, (javadoc) -> javadoc.getOptions().source("1.8").encoding("UTF-8")); project.getTasks().withType(Javadoc.class, (javadoc) -> {
CoreJavadocOptions options = (CoreJavadocOptions) javadoc.getOptions();
options.source("17");
options.encoding("UTF-8");
options.addStringOption("Xdoclint:none", "-quiet");
});
} }
private void configureJavaConventions(Project project) { private void configureJavaConventions(Project project) {
@ -196,17 +202,11 @@ class JavaConventions {
compile.setSourceCompatibility(SOURCE_AND_TARGET_COMPATIBILITY); compile.setSourceCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
compile.setTargetCompatibility(SOURCE_AND_TARGET_COMPATIBILITY); compile.setTargetCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
} }
else if (buildingWithJava8(project)) { args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes", "-Xlint:varargs"));
"-Xlint:varargs"));
}
}); });
} }
private boolean buildingWithJava8(Project project) {
return !project.hasProperty("toolchainVersion") && JavaVersion.current() == JavaVersion.VERSION_1_8;
}
private void configureSpringJavaFormat(Project project) { private void configureSpringJavaFormat(Project project) {
project.getPlugins().apply(SpringJavaFormatPlugin.class); project.getPlugins().apply(SpringJavaFormatPlugin.class);
project.getTasks().withType(Format.class, (Format) -> Format.setEncoding("UTF-8")); project.getTasks().withType(Format.class, (Format) -> Format.setEncoding("UTF-8"));

@ -144,7 +144,7 @@ public class MavenPluginPlugin implements Plugin<Project> {
private MavenExec createGenerateHelpMojoTask(Project project, File helpMojoDir) { private MavenExec createGenerateHelpMojoTask(Project project, File helpMojoDir) {
MavenExec task = project.getTasks().create("generateHelpMojo", MavenExec.class); MavenExec task = project.getTasks().create("generateHelpMojo", MavenExec.class);
task.setProjectDir(helpMojoDir); task.setProjectDir(helpMojoDir);
task.args("org.apache.maven.plugins:maven-plugin-plugin:3.6.0:helpmojo"); task.args("org.apache.maven.plugins:maven-plugin-plugin:3.6.1:helpmojo");
task.getOutputs().dir(new File(helpMojoDir, "target/generated-sources/plugin")); task.getOutputs().dir(new File(helpMojoDir, "target/generated-sources/plugin"));
return task; return task;
} }
@ -211,7 +211,7 @@ public class MavenPluginPlugin implements Plugin<Project> {
private MavenExec createGeneratePluginDescriptorTask(Project project, File mavenDir) { private MavenExec createGeneratePluginDescriptorTask(Project project, File mavenDir) {
MavenExec generatePluginDescriptor = project.getTasks().create("generatePluginDescriptor", MavenExec.class); MavenExec generatePluginDescriptor = project.getTasks().create("generatePluginDescriptor", MavenExec.class);
generatePluginDescriptor.args("org.apache.maven.plugins:maven-plugin-plugin:3.6.0:descriptor"); generatePluginDescriptor.args("org.apache.maven.plugins:maven-plugin-plugin:3.6.1:descriptor");
generatePluginDescriptor.getOutputs().dir(new File(mavenDir, "target/classes/META-INF/maven")); generatePluginDescriptor.getOutputs().dir(new File(mavenDir, "target/classes/META-INF/maven"));
generatePluginDescriptor.getInputs().dir(new File(mavenDir, "target/classes/org")) generatePluginDescriptor.getInputs().dir(new File(mavenDir, "target/classes/org"))
.withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("plugin classes"); .withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("plugin classes");

@ -73,7 +73,7 @@ class ConventionsPluginTests {
out.println(" id 'org.springframework.boot.conventions'"); out.println(" id 'org.springframework.boot.conventions'");
out.println("}"); out.println("}");
out.println("version = '1.2.3'"); out.println("version = '1.2.3'");
out.println("sourceCompatibility = '1.8'"); out.println("sourceCompatibility = '17'");
out.println("description 'Test project for manifest customization'"); out.println("description 'Test project for manifest customization'");
out.println("jar.archiveFileName = 'test.jar'"); out.println("jar.archiveFileName = 'test.jar'");
} }
@ -90,7 +90,7 @@ class ConventionsPluginTests {
.isEqualTo(this.projectDir.getName().replace("-", ".")); .isEqualTo(this.projectDir.getName().replace("-", "."));
assertThat(mainAttributes.getValue("Implementation-Version")).isEqualTo("1.2.3"); assertThat(mainAttributes.getValue("Implementation-Version")).isEqualTo("1.2.3");
assertThat(mainAttributes.getValue("Built-By")).isEqualTo("Spring"); assertThat(mainAttributes.getValue("Built-By")).isEqualTo("Spring");
assertThat(mainAttributes.getValue("Build-Jdk-Spec")).isEqualTo("1.8"); assertThat(mainAttributes.getValue("Build-Jdk-Spec")).isEqualTo("17");
} }
} }
@ -103,7 +103,7 @@ class ConventionsPluginTests {
out.println(" id 'org.springframework.boot.conventions'"); out.println(" id 'org.springframework.boot.conventions'");
out.println("}"); out.println("}");
out.println("version = '1.2.3'"); out.println("version = '1.2.3'");
out.println("sourceCompatibility = '1.8'"); out.println("sourceCompatibility = '17'");
out.println("description 'Test'"); out.println("description 'Test'");
out.println("repositories {"); out.println("repositories {");
out.println(" mavenCentral()"); out.println(" mavenCentral()");
@ -125,7 +125,7 @@ class ConventionsPluginTests {
.isEqualTo(this.projectDir.getName().replace("-", ".")); .isEqualTo(this.projectDir.getName().replace("-", "."));
assertThat(mainAttributes.getValue("Implementation-Version")).isEqualTo("1.2.3"); assertThat(mainAttributes.getValue("Implementation-Version")).isEqualTo("1.2.3");
assertThat(mainAttributes.getValue("Built-By")).isEqualTo("Spring"); assertThat(mainAttributes.getValue("Built-By")).isEqualTo("Spring");
assertThat(mainAttributes.getValue("Build-Jdk-Spec")).isEqualTo("1.8"); assertThat(mainAttributes.getValue("Build-Jdk-Spec")).isEqualTo("17");
} }
} }
@ -138,7 +138,7 @@ class ConventionsPluginTests {
out.println(" id 'org.springframework.boot.conventions'"); out.println(" id 'org.springframework.boot.conventions'");
out.println("}"); out.println("}");
out.println("version = '1.2.3'"); out.println("version = '1.2.3'");
out.println("sourceCompatibility = '1.8'"); out.println("sourceCompatibility = '17'");
out.println("description 'Test'"); out.println("description 'Test'");
out.println("repositories {"); out.println("repositories {");
out.println(" mavenCentral()"); out.println(" mavenCentral()");
@ -160,7 +160,7 @@ class ConventionsPluginTests {
.isEqualTo(this.projectDir.getName().replace("-", ".")); .isEqualTo(this.projectDir.getName().replace("-", "."));
assertThat(mainAttributes.getValue("Implementation-Version")).isEqualTo("1.2.3"); assertThat(mainAttributes.getValue("Implementation-Version")).isEqualTo("1.2.3");
assertThat(mainAttributes.getValue("Built-By")).isEqualTo("Spring"); assertThat(mainAttributes.getValue("Built-By")).isEqualTo("Spring");
assertThat(mainAttributes.getValue("Build-Jdk-Spec")).isEqualTo("1.8"); assertThat(mainAttributes.getValue("Build-Jdk-Spec")).isEqualTo("17");
} }
} }

@ -1,12 +0,0 @@
FROM ubuntu:focal-20211006
ADD setup.sh /setup.sh
ADD get-jdk-url.sh /get-jdk-url.sh
ADD get-docker-url.sh /get-docker-url.sh
RUN ./setup.sh java11
ENV JAVA_HOME /opt/openjdk
ENV PATH $JAVA_HOME/bin:$PATH
ADD docker-lib.sh /docker-lib.sh
ENTRYPOINT [ "switch", "shell=/bin/bash", "--", "codep", "/bin/docker daemon" ]

@ -1,12 +0,0 @@
FROM ubuntu:focal-20211006
ADD setup.sh /setup.sh
ADD get-jdk-url.sh /get-jdk-url.sh
ADD get-docker-url.sh /get-docker-url.sh
RUN ./setup.sh java8 java17
ENV JAVA_HOME /opt/openjdk
ENV PATH $JAVA_HOME/bin:$PATH
ADD docker-lib.sh /docker-lib.sh
ENTRYPOINT [ "switch", "shell=/bin/bash", "--", "codep", "/bin/docker daemon" ]

@ -3,7 +3,7 @@ FROM ubuntu:focal-20211006
ADD setup.sh /setup.sh ADD setup.sh /setup.sh
ADD get-jdk-url.sh /get-jdk-url.sh ADD get-jdk-url.sh /get-jdk-url.sh
ADD get-docker-url.sh /get-docker-url.sh ADD get-docker-url.sh /get-docker-url.sh
RUN ./setup.sh java8 RUN ./setup.sh java17
ENV JAVA_HOME /opt/openjdk ENV JAVA_HOME /opt/openjdk
ENV PATH $JAVA_HOME/bin:$PATH ENV PATH $JAVA_HOME/bin:$PATH

@ -2,12 +2,6 @@
set -e set -e
case "$1" in case "$1" in
java8)
echo "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u312-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u312b07.tar.gz"
;;
java11)
echo "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.13%2B8/OpenJDK11U-jdk_x64_linux_hotspot_11.0.13_8.tar.gz"
;;
java17) java17)
echo "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.1%2B12/OpenJDK17U-jdk_x64_linux_hotspot_17.0.1_12.tar.gz" echo "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.1%2B12/OpenJDK17U-jdk_x64_linux_hotspot_17.0.1_12.tar.gz"
;; ;;

@ -171,18 +171,6 @@ resources:
source: source:
<<: *registry-image-resource-source <<: *registry-image-resource-source
repository: ((docker-hub-organization))/spring-boot-ci repository: ((docker-hub-organization))/spring-boot-ci
- name: ci-image-jdk11
type: registry-image
icon: docker
source:
<<: *registry-image-resource-source
repository: ((docker-hub-organization))/spring-boot-ci-jdk11
- name: ci-image-jdk17
type: registry-image
icon: docker
source:
<<: *registry-image-resource-source
repository: ((docker-hub-organization))/spring-boot-ci-jdk17
- name: paketo-builder-base-image - name: paketo-builder-base-image
type: registry-image type: registry-image
icon: docker icon: docker
@ -205,22 +193,6 @@ resources:
access_token: ((github-ci-status-token)) access_token: ((github-ci-status-token))
branch: ((branch)) branch: ((branch))
context: build context: build
- name: repo-status-jdk11-build
type: github-status-resource
icon: eye-check-outline
source:
repository: ((github-repo-name))
access_token: ((github-ci-status-token))
branch: ((branch))
context: jdk11-build
- name: repo-status-jdk17-build
type: github-status-resource
icon: eye-check-outline
source:
repository: ((github-repo-name))
access_token: ((github-ci-status-token))
branch: ((branch))
context: jdk17-build
- name: slack-alert - name: slack-alert
type: slack-notification type: slack-notification
icon: slack icon: slack
@ -248,66 +220,29 @@ jobs:
- get: ci-images-git-repo - get: ci-images-git-repo
trigger: true trigger: true
- get: git-repo - get: git-repo
- in_parallel: - task: build-ci-image
- task: build-ci-image privileged: true
privileged: true file: git-repo/ci/tasks/build-ci-image.yml
file: git-repo/ci/tasks/build-ci-image.yml output_mapping:
output_mapping: image: ci-image
image: ci-image vars:
vars: ci-image-name: ci-image
ci-image-name: ci-image <<: *docker-hub-mirror-vars
<<: *docker-hub-mirror-vars - put: ci-image
- task: build-ci-image-jdk11 params:
privileged: true image: ci-image/image.tar
file: git-repo/ci/tasks/build-ci-image.yml
output_mapping:
image: ci-image-jdk11
vars:
ci-image-name: ci-image-jdk11
<<: *docker-hub-mirror-vars
- task: build-ci-image-jdk17
privileged: true
file: git-repo/ci/tasks/build-ci-image.yml
output_mapping:
image: ci-image-jdk17
vars:
ci-image-name: ci-image-jdk17
<<: *docker-hub-mirror-vars
- in_parallel:
- put: ci-image
params:
image: ci-image/image.tar
- put: ci-image-jdk11
params:
image: ci-image-jdk11/image.tar
- put: ci-image-jdk17
params:
image: ci-image-jdk17/image.tar
- name: detect-jdk-updates - name: detect-jdk-updates
plan: plan:
- get: git-repo - get: git-repo
- get: every-wednesday - get: every-wednesday
trigger: true trigger: true
- get: ci-image - get: ci-image
- in_parallel: - task: detect-jdk17-update
- task: detect-jdk8-update image: ci-image
image: ci-image file: git-repo/ci/tasks/detect-jdk-updates.yml
file: git-repo/ci/tasks/detect-jdk-updates.yml params:
params: <<: *github-task-params
<<: *github-task-params JDK_VERSION: java17
JDK_VERSION: java8
- task: detect-jdk11-update
image: ci-image
file: git-repo/ci/tasks/detect-jdk-updates.yml
params:
<<: *github-task-params
JDK_VERSION: java11
- task: detect-jdk17-update
image: ci-image
file: git-repo/ci/tasks/detect-jdk-updates.yml
params:
<<: *github-task-params
JDK_VERSION: java17
- name: detect-ubuntu-image-updates - name: detect-ubuntu-image-updates
plan: plan:
- get: git-repo - get: git-repo
@ -395,63 +330,6 @@ jobs:
params: params:
path: git-repo path: git-repo
status: failure status: failure
- name: jdk11-build
serial: true
public: true
plan:
- get: ci-image-jdk11
- get: git-repo
trigger: true
- put: repo-status-jdk11-build
params: { state: "pending", commit: "git-repo" }
- do:
- task: build-project
image: ci-image-jdk11
<<: *build-project-task-params
on_failure:
do:
- put: repo-status-jdk11-build
params: { state: "failure", commit: "git-repo" }
- put: slack-alert
params:
<<: *slack-fail-params
- put: repo-status-jdk11-build
params: { state: "success", commit: "git-repo" }
- put: slack-alert
params:
<<: *slack-success-params
- name: jdk17-build
serial: true
public: true
plan:
- get: ci-image-jdk17
- get: git-repo
trigger: true
- put: repo-status-jdk17-build
params: { state: "pending", commit: "git-repo" }
- do:
- task: build-project
image: ci-image-jdk17
privileged: true
timeout: ((task-timeout))
file: git-repo/ci/tasks/build-project.yml
params:
BRANCH: ((branch))
TOOLCHAIN_JAVA_VERSION: 17
<<: *gradle-enterprise-task-params
<<: *docker-hub-task-params
on_failure:
do:
- put: repo-status-jdk17-build
params: { state: "failure", commit: "git-repo" }
- put: slack-alert
params:
<<: *slack-fail-params
- put: repo-status-jdk17-build
params: { state: "success", commit: "git-repo" }
- put: slack-alert
params:
<<: *slack-success-params
- name: windows-build - name: windows-build
serial: true serial: true
plan: plan:
@ -725,64 +603,13 @@ jobs:
- put: slack-alert - put: slack-alert
params: params:
<<: *slack-success-params <<: *slack-success-params
- name: jdk11-run-system-tests
serial: true
public: true
plan:
- get: ci-image-jdk11
- get: git-repo
- get: paketo-builder-base-image
trigger: true
- get: daily
trigger: true
- do:
- task: run-system-tests
image: ci-image-jdk11
<<: *run-system-tests-task-params
on_failure:
do:
- put: slack-alert
params:
<<: *slack-fail-params
- put: slack-alert
params:
<<: *slack-success-params
- name: jdk17-run-system-tests
serial: true
public: true
plan:
- get: ci-image-jdk17
- get: git-repo
- get: paketo-builder-base-image
trigger: true
- get: daily
trigger: true
- do:
- task: run-system-tests
image: ci-image-jdk17
privileged: true
timeout: ((task-timeout))
file: git-repo/ci/tasks/run-system-tests.yml
params:
BRANCH: ((branch))
TOOLCHAIN_JAVA_VERSION: 17
<<: *gradle-enterprise-task-params
<<: *docker-hub-task-params
on_failure:
do:
- put: slack-alert
params:
<<: *slack-fail-params
- put: slack-alert
params:
<<: *slack-success-params
groups: groups:
- name: "builds" - name: "builds"
jobs: ["build", "jdk11-build", "jdk17-build", "windows-build"] jobs: ["build", "windows-build"]
- name: "releases" - name: "releases"
jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release", "create-github-release", "publish-gradle-plugin", "publish-to-sdkman", "update-homebrew-tap"] jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release", "create-github-release", "publish-gradle-plugin", "publish-to-sdkman", "update-homebrew-tap"]
- name: "system-tests" - name: "system-tests"
jobs: ["run-system-tests", "jdk11-run-system-tests", "jdk17-run-system-tests"] jobs: ["run-system-tests"]
- name: "ci-images" - name: "ci-images"
jobs: ["build-ci-images", "detect-docker-updates", "detect-jdk-updates", "detect-ubuntu-image-updates"] jobs: ["build-ci-images", "detect-docker-updates", "detect-jdk-updates", "detect-ubuntu-image-updates"]
- name: "pull-requests" - name: "pull-requests"

@ -139,10 +139,10 @@ public class LaunchedURLClassLoader extends URLClassLoader {
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
// Tolerate race condition due to being parallel capable // Tolerate race condition due to being parallel capable
if (getPackage(name) == null) { if (getDefinedPackage(name) == null) {
// This should never happen as the IllegalArgumentException indicates // This should never happen as the IllegalArgumentException indicates
// that the package has already been defined and, therefore, // that the package has already been defined and, therefore,
// getPackage(name) should not return null. // getDefinedPackage(name) should not return null.
throw new AssertionError("Package " + name + " has already been defined but it could not be found"); throw new AssertionError("Package " + name + " has already been defined but it could not be found");
} }
} }
@ -192,16 +192,17 @@ public class LaunchedURLClassLoader extends URLClassLoader {
int lastDot = className.lastIndexOf('.'); int lastDot = className.lastIndexOf('.');
if (lastDot >= 0) { if (lastDot >= 0) {
String packageName = className.substring(0, lastDot); String packageName = className.substring(0, lastDot);
if (getPackage(packageName) == null) { if (getDefinedPackage(packageName) == null) {
try { try {
definePackage(className, packageName); definePackage(className, packageName);
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
// Tolerate race condition due to being parallel capable // Tolerate race condition due to being parallel capable
if (getPackage(packageName) == null) { if (getDefinedPackage(packageName) == null) {
// This should never happen as the IllegalArgumentException // This should never happen as the IllegalArgumentException
// indicates that the package has already been defined and, // indicates that the package has already been defined and,
// therefore, getPackage(name) should not have returned null. // therefore, getDefinedPackage(name) should not have returned
// null.
throw new AssertionError( throw new AssertionError(
"Package " + packageName + " has already been defined but it could not be found"); "Package " + packageName + " has already been defined but it could not be found");
} }

@ -557,7 +557,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
try { try {
Class<?> startClass = Class.forName(this.startClassName, false, classLoader); Class<?> startClass = Class.forName(this.startClassName, false, classLoader);
Method mainMethod = startClass.getMethod("main", String[].class); Method mainMethod = startClass.getMethod("main", String[].class);
if (!mainMethod.isAccessible()) { if (!mainMethod.canAccess(null)) {
mainMethod.setAccessible(true); mainMethod.setAccessible(true);
} }
mainMethod.invoke(null, new Object[] { this.args }); mainMethod.invoke(null, new Object[] { this.args });

@ -177,6 +177,6 @@ compileJava {
doLast new org.springframework.boot.build.log4j2.ReproducibleLog4j2PluginsDatAction() doLast new org.springframework.boot.build.log4j2.ReproducibleLog4j2PluginsDatAction()
} }
toolchain { test {
testJvmArgs.add("--add-opens=java.base/java.net=ALL-UNNAMED") jvmArgs += "--add-opens=java.base/java.net=ALL-UNNAMED"
} }

@ -256,7 +256,7 @@ class BeanDefinitionLoader {
String path = ((ClassPathResource) resource).getPath(); String path = ((ClassPathResource) resource).getPath();
if (path.indexOf('.') == -1) { if (path.indexOf('.') == -1) {
try { try {
return Package.getPackage(path) == null; return getClass().getClassLoader().getDefinedPackage(path) == null;
} }
catch (Exception ex) { catch (Exception ex) {
// Ignore // Ignore
@ -267,7 +267,7 @@ class BeanDefinitionLoader {
} }
private Package findPackage(CharSequence source) { private Package findPackage(CharSequence source) {
Package pkg = Package.getPackage(source.toString()); Package pkg = getClass().getClassLoader().getDefinedPackage(source.toString());
if (pkg != null) { if (pkg != null) {
return pkg; return pkg;
} }
@ -285,7 +285,7 @@ class BeanDefinitionLoader {
catch (Exception ex) { catch (Exception ex) {
// swallow exception and continue // swallow exception and continue
} }
return Package.getPackage(source.toString()); return getClass().getClassLoader().getDefinedPackage(source.toString());
} }
/** /**

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@
package org.springframework.boot.reactor; package org.springframework.boot.reactor;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import reactor.core.Scannable; import reactor.core.Scannable;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
@ -30,7 +31,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Brian Clozel * @author Brian Clozel
*/ */
@ClassPathOverrides("io.projectreactor:reactor-tools:3.3.0.RELEASE") @Disabled("We need the not-yet-released reactor-tools 3.4.11 for JDK 17 compatibility")
@ClassPathOverrides("io.projectreactor:reactor-tools:3.4.11")
class DebugAgentEnvironmentPostProcessorTests { class DebugAgentEnvironmentPostProcessorTests {
static { static {

@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@Testcontainers(disabledWithoutDocker = true) @Testcontainers(disabledWithoutDocker = true)
class LoaderIntegrationTests { class LoaderIntegrationTests {
private static final DockerImageName JRE = DockerImageName.parse("adoptopenjdk:15-jre-hotspot"); private static final DockerImageName JRE = DockerImageName.parse("eclipse-temurin:17.0.1_12-jdk-alpine");
private static ToStringConsumer output = new ToStringConsumer(); private static ToStringConsumer output = new ToStringConsumer();

Loading…
Cancel
Save