Raise the minimum supported version of Java to 17

Closes gh-28101
This commit is contained in:
Andy Wilkinson
2021-10-06 19:09:24 +01:00
parent 99f33ede14
commit 900085628a
15 changed files with 62 additions and 262 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.boot.reactor;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import reactor.core.Scannable;
import reactor.core.publisher.Flux;
@@ -30,7 +31,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @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 {
static {