Skip to content

Commit 468cbdb

Browse files
committed
Got rid of needing a URLClassloader....
1 parent 9b9d626 commit 468cbdb

File tree

3 files changed

+2
-41
lines changed

3 files changed

+2
-41
lines changed

src/main/java/org/mangorage/bootstrap/Bootstrap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static void main(String[] args) throws IOException {
4848
Util.getModuleNames(pluginsPath)
4949
);
5050

51-
final var moduleCl = new MangoLoader(fetchJars(librariesPath, pluginsPath), moduleCfg.modules(), Thread.currentThread().getContextClassLoader());
51+
final var moduleCl = new MangoLoader(moduleCfg.modules(), Thread.currentThread().getContextClassLoader());
5252

5353
final var moduleLayerController = ModuleLayer.defineModules(moduleCfg, List.of(parent), s -> moduleCl);
5454
final var moduleLayer = moduleLayerController.layer();

src/main/java/org/mangorage/bootstrap/internal/MangoLoader.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ public final class MangoLoader extends SecureClassLoader {
3030
private final Map<String, LoadedModule> moduleMap = new ConcurrentHashMap<>();
3131
private final Map<String, LoadedModule> localPackageToModule = new ConcurrentHashMap<>();
3232

33-
34-
35-
public MangoLoader(URL[] urls, Set<ResolvedModule> modules, ClassLoader parent) {
33+
public MangoLoader(Set<ResolvedModule> modules, ClassLoader parent) {
3634
super(parent);
3735

3836
modules.forEach(module -> {

src/main/java/org/mangorage/bootstrap/internal/Util.java

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,12 @@
44
import java.lang.module.ModuleFinder;
55
import java.lang.module.ModuleReference;
66
import java.lang.reflect.Method;
7-
import java.net.MalformedURLException;
8-
import java.net.URL;
97
import java.nio.file.Path;
10-
import java.util.ArrayList;
11-
import java.util.Arrays;
128
import java.util.HashSet;
13-
import java.util.List;
149
import java.util.Set;
1510

1611
public final class Util {
1712

18-
19-
public static URL[] fetchJars(Path... paths) {
20-
return fetchJars(
21-
Arrays.stream(paths)
22-
.map(Path::toFile)
23-
.toArray(File[]::new)
24-
);
25-
}
26-
27-
public static URL[] fetchJars(File[] directories) {
28-
// Add your extra folder here, you glutton for suffering
29-
30-
List<URL> urls = new ArrayList<>();
31-
32-
for (File dir : directories) {
33-
if (!dir.exists() || !dir.isDirectory()) continue;
34-
35-
File[] jarFiles = dir.listFiles((d, name) -> name.endsWith(".jar"));
36-
if (jarFiles == null) continue;
37-
38-
for (File jar : jarFiles) {
39-
try {
40-
urls.add(jar.toURI().toURL());
41-
} catch (MalformedURLException e) {
42-
throw new RuntimeException("Malformed URL while processing: " + jar.getAbsolutePath(), e);
43-
}
44-
}
45-
}
46-
47-
return urls.toArray(URL[]::new);
48-
}
49-
5013
public static Set<String> getModuleNames(Path folder) {
5114
final Set<String> moduleNames = new HashSet<>();
5215

0 commit comments

Comments
 (0)