[FIX] Duplicate classpath and modulepath entities

This commit is contained in:
Gravita 2025-05-04 22:03:28 +07:00
parent 90f74aaf25
commit 911ca1e69f

View file

@ -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<Path> ignoredPath = new HashSet<>();
List<Path> 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<URL> 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<Path> ignoredPath = new HashSet<>();
if(options.moduleConf != null && options.moduleConf.modulePath != null) {
List<Path> resolvedModulePath = resolveClassPath(ignoredPath, clientDir, null, params.profile).toList();
}
List<Path> 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<URL> 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<Path> resolveClassPathStream(Set<Path> ignorePaths, Path c
public static Stream<Path> resolveClassPath(Set<Path> ignorePaths, Path clientDir, Set<OptionalAction> actions, ClientProfile profile) throws IOException {
Stream<Path> 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;
}