[FIX] LauncherAgent.addJVMClassPath

This commit is contained in:
Zaxar163 2019-08-23 13:35:36 +03:00
parent eb9762ce5b
commit 81aaaf6e37
4 changed files with 13 additions and 6 deletions

View file

@ -4,9 +4,11 @@
import static org.objectweb.asm.Opcodes.ARETURN; import static org.objectweb.asm.Opcodes.ARETURN;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.instrument.Instrumentation; import java.lang.instrument.Instrumentation;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -31,7 +33,12 @@ public final class LauncherAgent {
public static void addJVMClassPath(String path) throws IOException { public static void addJVMClassPath(String path) throws IOException {
LogHelper.debug("Launcher Agent addJVMClassPath"); LogHelper.debug("Launcher Agent addJVMClassPath");
inst.appendToSystemClassLoaderSearch(new JarFile(path)); inst.appendToSystemClassLoaderSearch(new JarFile(new File(path)));
}
public static void addJVMClassPath(Path path) throws IOException {
LogHelper.debug("Launcher Agent addJVMClassPath");
inst.appendToSystemClassLoaderSearch(new JarFile(path.toFile()));
} }
public boolean isAgentStarted() { public boolean isAgentStarted() {

View file

@ -470,12 +470,12 @@ public static void main(String... args) throws Throwable {
LogHelper.debug("Verifying ClientLauncher sign and classpath"); LogHelper.debug("Verifying ClientLauncher sign and classpath");
LinkedList<Path> classPath = resolveClassPathList(params.clientDir, profile.getClassPath()); LinkedList<Path> classPath = resolveClassPathList(params.clientDir, profile.getClassPath());
for (Path classpathURL : classPath) { for (Path classpathURL : classPath) {
LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString()); LauncherAgent.addJVMClassPath(classpathURL.normalize().toAbsolutePath());
} }
profile.pushOptionalClassPath(cp -> { profile.pushOptionalClassPath(cp -> {
LinkedList<Path> optionalClassPath = resolveClassPathList(params.clientDir, cp); LinkedList<Path> optionalClassPath = resolveClassPathList(params.clientDir, cp);
for (Path classpathURL : optionalClassPath) { for (Path classpathURL : optionalClassPath) {
LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString()); LauncherAgent.addJVMClassPath(classpathURL.normalize().toAbsolutePath());
} }
}); });
URL[] classpathurls = resolveClassPath(params.clientDir, profile.getClassPath()); URL[] classpathurls = resolveClassPath(params.clientDir, profile.getClassPath());

View file

@ -10,12 +10,12 @@
public class JarHelper { public class JarHelper {
@FunctionalInterface @FunctionalInterface
public interface ZipWalkCallback { public interface ZipWalkCallback {
void process(ZipInputStream input, ZipEntry e); void process(ZipInputStream input, ZipEntry e) throws IOException;
} }
@FunctionalInterface @FunctionalInterface
public interface JarWalkCallback { public interface JarWalkCallback {
void process(ZipInputStream input, ZipEntry e, String fullClassName, String clazz); void process(ZipInputStream input, ZipEntry e, String fullClassName, String clazz) throws IOException;
} }
public static void zipWalk(ZipInputStream input, ZipWalkCallback callback) throws IOException { public static void zipWalk(ZipInputStream input, ZipWalkCallback callback) throws IOException {

@ -1 +1 @@
Subproject commit 36559441ba26db3cc71818bd8a93b6464f7f00e0 Subproject commit ed27a816fdc5794be260da0a3fb6e5f27db51bf8