diff --git a/src/main/java/org/quiltmc/loader/impl/launch/knot/KnotClassDelegate.java b/src/main/java/org/quiltmc/loader/impl/launch/knot/KnotClassDelegate.java index 46c79bd7c..9bff5f9eb 100644 --- a/src/main/java/org/quiltmc/loader/impl/launch/knot/KnotClassDelegate.java +++ b/src/main/java/org/quiltmc/loader/impl/launch/knot/KnotClassDelegate.java @@ -244,11 +244,19 @@ Class tryLoadClass(String name, boolean allowFromParent) throws ClassNotFound } } - if (!allowedPrefixes.isEmpty()) { + if (!allowedPrefixes.isEmpty() && url != null) { + String fileName = LoaderUtil.getClassFileName(name); + URL codeSource = null; + + try { + codeSource = UrlUtil.getSource(fileName, url); + } catch (UrlConversionException e) { + Log.warn(LogCategory.GENERAL, "Failed to get the code source URL for " + url); + } + String[] prefixes; - if (url != null - && (prefixes = allowedPrefixes.get(url.toString())) != null) { + if (codeSource != null && (prefixes = allowedPrefixes.get(codeSource.toString())) != null) { assert prefixes.length > 0; boolean found = false; @@ -260,7 +268,7 @@ Class tryLoadClass(String name, boolean allowFromParent) throws ClassNotFound } if (!found) { - throw new ClassNotFoundException("class "+name+" is currently restricted from being loaded"); + throw new ClassNotFoundException("class " + name + " is currently restricted from being loaded"); } } } @@ -350,7 +358,6 @@ Class tryLoadClass(String name, boolean allowFromParent) throws ClassNotFound return c; } - private boolean shouldRerouteToParent(String name) { return name.startsWith("org.slf4j.") || name.startsWith("org.apache.logging.log4j."); } diff --git a/src/main/java/org/quiltmc/loader/impl/util/UrlUtil.java b/src/main/java/org/quiltmc/loader/impl/util/UrlUtil.java index b932d05bb..ff05e01d7 100644 --- a/src/main/java/org/quiltmc/loader/impl/util/UrlUtil.java +++ b/src/main/java/org/quiltmc/loader/impl/util/UrlUtil.java @@ -77,7 +77,7 @@ public static URL asUrl(File file) throws MalformedURLException { } public static URL asUrl(Path path) throws MalformedURLException { - return path.toUri().toURL(); + return LoaderUtil.normalizePath(path).toUri().toURL(); } public static Path getCodeSource(URL url, String localPath) throws UrlConversionException {