From f10254f9eab2a96bfb4aff660d7cdc655ca5ae7f Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Thu, 21 Jan 2021 23:25:21 +0800 Subject: [PATCH] Fallback to builtin cl --- .../io/izzel/arclight/forgeinstaller/ForgeInstaller.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/ForgeInstaller.java b/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/ForgeInstaller.java index 2d6881e4..e5c01fd9 100644 --- a/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/ForgeInstaller.java +++ b/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/ForgeInstaller.java @@ -90,7 +90,7 @@ public class ForgeInstaller { FileDownloader fd = new FileDownloader(format, dist, info.installer.hash); CompletableFuture installerFuture = reportSupply(pool).apply(fd).thenAccept(path -> { try { - FileSystem system = FileSystems.newFileSystem(path, null); + FileSystem system = FileSystems.newFileSystem(path, (ClassLoader) null); Map> map = new HashMap<>(); Path profile = system.getPath("install_profile.json"); map.putAll(profileLibraries(profile)); @@ -186,7 +186,12 @@ public class ForgeInstaller { private static void addToPath(Path path) throws Throwable { ClassLoader loader = ForgeInstaller.class.getClassLoader(); - Field ucpField = loader.getClass().getDeclaredField("ucp"); + Field ucpField; + try { + ucpField = loader.getClass().getDeclaredField("ucp"); + } catch (NoSuchFieldException e) { + ucpField = loader.getClass().getSuperclass().getDeclaredField("ucp"); + } long offset = Unsafe.objectFieldOffset(ucpField); Object ucp = Unsafe.getObject(loader, offset); Method method = ucp.getClass().getDeclaredMethod("addURL", URL.class);