Fix loading into isolated classloaders

This commit is contained in:
Vankka 2024-06-20 22:08:54 +03:00
parent 2f01d15032
commit f5b8829de1
No known key found for this signature in database
GPG Key ID: 62E48025ED4E7EBB

View File

@ -89,12 +89,16 @@ public class DependencyLoader {
public IsolatedClassLoader intoIsolated() throws IOException { public IsolatedClassLoader intoIsolated() throws IOException {
IsolatedClassLoader classLoader = new IsolatedClassLoader(); IsolatedClassLoader classLoader = new IsolatedClassLoader();
downloadRelocateAndLoad().join(); downloadRelocateAndLoad(classLoader).join();
return classLoader; return classLoader;
} }
public CompletableFuture<Void> downloadRelocateAndLoad() { public CompletableFuture<Void> downloadRelocateAndLoad() {
return download().thenCompose(v -> relocateAndLoad(true)); return downloadRelocateAndLoad(classpathAppender);
}
public CompletableFuture<Void> downloadRelocateAndLoad(ClasspathAppender appender) {
return download().thenCompose(v -> relocateAndLoad(true, appender));
} }
public CompletableFuture<Void> download() { public CompletableFuture<Void> download() {
@ -102,8 +106,12 @@ public class DependencyLoader {
} }
public CompletableFuture<Void> relocateAndLoad(boolean useExecutor) { public CompletableFuture<Void> relocateAndLoad(boolean useExecutor) {
return relocateAndLoad(useExecutor, classpathAppender);
}
public CompletableFuture<Void> relocateAndLoad(boolean useExecutor, ClasspathAppender appender) {
Executor executorToUse = useExecutor ? executor : null; Executor executorToUse = useExecutor ? executor : null;
return dependencyManager.relocateAll(executorToUse) return dependencyManager.relocateAll(executorToUse)
.thenCompose(v -> dependencyManager.loadAll(executorToUse, classpathAppender)); .thenCompose(v -> dependencyManager.loadAll(executorToUse, appender));
} }
} }