Extracted URLClassLoader out of try-with-resources block

This commit is contained in:
Vaishnav Anil 2021-06-25 05:07:14 +05:30
parent 0c6dd5466c
commit 09e68e7510

View File

@ -42,13 +42,11 @@ public class FileUtil {
} }
final URL jar = file.toURI().toURL(); final URL jar = file.toURI().toURL();
final URLClassLoader loader = new URLClassLoader(new URL[]{jar}, clazz.getClassLoader());
final List<String> matches = new ArrayList<>(); final List<String> matches = new ArrayList<>();
final List<Class<? extends T>> classes = new ArrayList<>(); final List<Class<? extends T>> classes = new ArrayList<>();
try (final JarInputStream stream = new JarInputStream( try (final JarInputStream stream = new JarInputStream(jar.openStream())) {
jar.openStream()); final URLClassLoader loader = new URLClassLoader(new URL[]{jar},
clazz.getClassLoader())) {
JarEntry entry; JarEntry entry;
while ((entry = stream.getNextJarEntry()) != null) { while ((entry = stream.getNextJarEntry()) != null) {
final String name = entry.getName(); final String name = entry.getName();