diff --git a/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClassDelegate.java b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClassDelegate.java index 3e7e75f1d..3e5d301d5 100644 --- a/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClassDelegate.java +++ b/src/main/java/net/fabricmc/loader/impl/launch/knot/KnotClassDelegate.java @@ -512,10 +512,7 @@ private static boolean hasRegularCodeSource(URL url) { private static Path getCodeSource(URL url, String fileName) { try { - Path ret = UrlUtil.getCodeSource(url, fileName); - assert ret.equals(LoaderUtil.normalizeExistingPath(ret)); // ret should already be normalized - - return ret; + return LoaderUtil.normalizeExistingPath(UrlUtil.getCodeSource(url, fileName)); } catch (UrlConversionException e) { throw ExceptionUtil.wrap(e); } diff --git a/src/main/java/net/fabricmc/loader/impl/util/LoaderUtil.java b/src/main/java/net/fabricmc/loader/impl/util/LoaderUtil.java index 170234a47..82f9f8235 100644 --- a/src/main/java/net/fabricmc/loader/impl/util/LoaderUtil.java +++ b/src/main/java/net/fabricmc/loader/impl/util/LoaderUtil.java @@ -24,9 +24,13 @@ import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.stream.Collectors; public final class LoaderUtil { + private static final ConcurrentMap pathNormalizationCache = new ConcurrentHashMap<>(); + public static String getClassFileName(String className) { return className.replace('.', '/').concat(".class"); } @@ -40,6 +44,10 @@ public static Path normalizePath(Path path) { } public static Path normalizeExistingPath(Path path) { + return pathNormalizationCache.computeIfAbsent(path, LoaderUtil::normalizeExistingPath0); + } + + private static Path normalizeExistingPath0(Path path) { try { return path.toRealPath(); } catch (IOException e) {