diff --git a/Launcher/build.gradle b/Launcher/build.gradle index 3db21f40..b99e62a8 100644 --- a/Launcher/build.gradle +++ b/Launcher/build.gradle @@ -53,7 +53,7 @@ task javadocJar(type: Jar) { } dependencies { - pack project(':LauncherAuthlib') + pack project(':LauncherAPI') bundle 'com.github.oshi:oshi-core:3.13.0' pack 'io.netty:netty-codec-http:4.1.43.Final' pack 'org.ow2.asm:asm-tree:7.1' diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java index c0ce62b8..23412318 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java @@ -292,6 +292,10 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl LogHelper.debug("Args: " + copy); // Resolve main class and method Class mainClass = classLoader.loadClass(profile.getMainClass()); + for(URL u : classLoader.getURLs()) + { + LogHelper.info("ClassLoader URL: %s", u.toString()); + } MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)).asFixedArity(); Launcher.LAUNCHED.set(true); JVMHelper.fullGC(); @@ -468,12 +472,12 @@ public static void main(String... args) throws Throwable { LogHelper.debug("Verifying ClientLauncher sign and classpath"); LinkedList classPath = resolveClassPathList(params.clientDir, profile.getClassPath()); for (Path classpathURL : classPath) { - LauncherAgent.addJVMClassPath(classpathURL.normalize().toAbsolutePath()); + //LauncherAgent.addJVMClassPath(classpathURL.normalize().toAbsolutePath()); } profile.pushOptionalClassPath(cp -> { LinkedList optionalClassPath = resolveClassPathList(params.clientDir, cp); for (Path classpathURL : optionalClassPath) { - LauncherAgent.addJVMClassPath(classpathURL.normalize().toAbsolutePath()); + //LauncherAgent.addJVMClassPath(classpathURL.normalize().toAbsolutePath()); } }); URL[] classpathurls = resolveClassPath(params.clientDir, profile.getClassPath()); @@ -507,6 +511,8 @@ public static void main(String... args) throws Throwable { AuthService.uuid = params.pp.uuid; ClientService.instrumentation = LauncherAgent.inst; ClientService.classLoader = classLoader; + classLoader.addURL(IOHelper.getCodeSource(ClientLauncher.class).toUri().toURL()); + //classForName(classLoader, "com.google.common.collect.ForwardingMultimap"); ClientService.baseURLs = classpathurls; LogHelper.debug("Starting JVM and client WatchService"); FileNameMatcher assetMatcher = profile.getAssetUpdateMatcher(); @@ -532,6 +538,13 @@ public static void main(String... args) throws Throwable { launch(profile, params); } } + public static void classForName(ClassLoader loader, String name) + { + try { + Class.forName(name, false, loader); + } catch (ClassNotFoundException ignored) { + } + } private static URL[] resolveClassPath(Path clientDir, String... classPath) throws IOException { return resolveClassPathStream(clientDir, classPath).map(IOHelper::toURL).toArray(URL[]::new); diff --git a/LauncherCore/src/main/java/pro/gravit/utils/PublicURLClassLoader.java b/LauncherCore/src/main/java/pro/gravit/utils/PublicURLClassLoader.java index 6ea17422..0879d53a 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/PublicURLClassLoader.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/PublicURLClassLoader.java @@ -1,6 +1,8 @@ package pro.gravit.utils; import pro.gravit.launcher.LauncherAPI; +import pro.gravit.utils.helper.IOHelper; +import pro.gravit.utils.helper.JVMHelper; import java.net.URL; import java.net.URLClassLoader; @@ -66,7 +68,25 @@ public PublicURLClassLoader(URL[] urls, ClassLoader parent) { @Override public String findLibrary(String name) { - return nativePath.concat(name); + return nativePath.concat(IOHelper.PLATFORM_SEPARATOR).concat(getNativePrefix()).concat(name).concat(getNativeEx()); + } + public String getNativeEx() + { + if(JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) + return ".dll"; + else if(JVMHelper.OS_TYPE == JVMHelper.OS.LINUX) + return ".so"; + else if(JVMHelper.OS_TYPE == JVMHelper.OS.MACOSX) + return ".dylib"; + return ""; + } + public String getNativePrefix() + { + if(JVMHelper.OS_TYPE == JVMHelper.OS.LINUX) + return "lib"; + else if(JVMHelper.OS_TYPE == JVMHelper.OS.MACOSX) + return "lib"; + return ""; } @Override