From 911ca1e69ffc7cefe7e2987548285dcf87f2528b Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Sun, 4 May 2025 22:03:28 +0700 Subject: [PATCH] [FIX] Duplicate classpath and modulepath entities --- .../client/ClientLauncherEntryPoint.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java index 65dcb764..d38100b3 100644 --- a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java +++ b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java @@ -116,15 +116,6 @@ private static void realMain(String[] args) throws Throwable { // Verify ClientLauncher sign and classpath LogHelper.debug("Verifying ClientLauncher sign and classpath"); - Set ignoredPath = new HashSet<>(); - List classpath = resolveClassPath(ignoredPath, clientDir, params.actions, params.profile) - .collect(Collectors.toCollection(ArrayList::new)); - if(LogHelper.isDevEnabled()) { - for(var e : classpath) { - LogHelper.dev("Classpath entry %s", e); - } - } - List classpathURLs = classpath.stream().map(IOHelper::toURL).toList(); // Start client with WatchService monitoring RequestService service; if (params.offlineMode) { @@ -158,6 +149,18 @@ private static void realMain(String[] args) throws Throwable { System.load(Paths.get(params.nativesDir).resolve(ClientService.findLibrary(e)).toAbsolutePath().toString()); } } + Set ignoredPath = new HashSet<>(); + if(options.moduleConf != null && options.moduleConf.modulePath != null) { + List resolvedModulePath = resolveClassPath(ignoredPath, clientDir, null, params.profile).toList(); + } + List classpath = resolveClassPath(ignoredPath, clientDir, params.actions, params.profile) + .collect(Collectors.toCollection(ArrayList::new)); + if(LogHelper.isDevEnabled()) { + for(var e : classpath) { + LogHelper.dev("Classpath entry %s", e); + } + } + List classpathURLs = classpath.stream().map(IOHelper::toURL).toList(); if (classLoaderConfig == ClientProfile.ClassLoaderConfig.LAUNCHER || classLoaderConfig == ClientProfile.ClassLoaderConfig.MODULE) { if(JVMHelper.JVM_VERSION <= 11) { launch = new LegacyLaunch(); @@ -274,9 +277,11 @@ private static Stream resolveClassPathStream(Set ignorePaths, Path c public static Stream resolveClassPath(Set ignorePaths, Path clientDir, Set actions, ClientProfile profile) throws IOException { Stream result = resolveClassPathStream(ignorePaths, clientDir, profile.getClassPath()); - for (OptionalAction a : actions) { - if (a instanceof OptionalActionClassPath) - result = Stream.concat(result, resolveClassPathStream(ignorePaths, clientDir, ((OptionalActionClassPath) a).args)); + if(actions != null) { + for (OptionalAction a : actions) { + if (a instanceof OptionalActionClassPath) + result = Stream.concat(result, resolveClassPathStream(ignorePaths, clientDir, ((OptionalActionClassPath) a).args)); + } } return result; }