Suppress deprecations for compiling on JDK 19/20

This commit is contained in:
Juergen Hoeller
2023-05-03 10:17:12 +02:00
parent 87942ed71d
commit 4db724984e
3 changed files with 19 additions and 15 deletions

View File

@@ -85,15 +85,15 @@ public class DynamicClassLoader extends ClassLoader {
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
byte[] bytes = findClassBytes(name);
if (bytes != null) {
return defineClass(name, bytes);
}
return super.findClass(name);
Class<?> clazz = defineClass(name, findClassBytes(name));
return (clazz != null ? clazz : super.findClass(name));
}
private Class<?> defineClass(String name, byte[] bytes) {
@Nullable
private Class<?> defineClass(String name, @Nullable byte[] bytes) {
if (bytes == null) {
return null;
}
if (this.defineClassMethod != null) {
return (Class<?>) ReflectionUtils.invokeMethod(this.defineClassMethod,
getParent(), name, bytes, 0, bytes.length);
@@ -142,6 +142,7 @@ public class DynamicClassLoader extends ClassLoader {
return (dynamicClassFile != null) ? dynamicClassFile.getBytes() : null;
}
@SuppressWarnings("deprecation") // on JDK 20
private URL createResourceUrl(String name, Supplier<byte[]> bytesSupplier) {
try {
return new URL(null, "resource:///" + name,