Updated libraries

This commit is contained in:
RaphiMC 2023-05-30 22:46:59 +02:00
parent b6abe50c1e
commit 0a1fc12e22
2 changed files with 4 additions and 35 deletions

View File

@ -93,7 +93,7 @@ dependencies {
include "com.google.code.gson:gson:2.10.1"
include "com.formdev:flatlaf:3.1.1"
include "com.google.guava:guava:31.1-jre"
include "com.google.guava:guava:32.0.0-jre"
include "org.apache.commons:commons-lang3:3.12.0"
include "commons-io:commons-io:2.12.0"
include "net.sf.jopt-simple:jopt-simple:5.0.4"
@ -103,7 +103,7 @@ dependencies {
include "net.lenni0451.classtransform:mixinstranslator:1.9.1"
include "net.lenni0451.classtransform:mixinsdummy:1.9.1"
include "net.lenni0451.classtransform:additionalclassprovider:1.9.1"
include "net.lenni0451:Reflect:1.1.0"
include "net.lenni0451:Reflect:1.2.0"
include "net.lenni0451:LambdaEvents:2.0.3"
include "net.raphimc.netminecraft:all:2.3.3"
include("net.raphimc:MinecraftAuth:2.1.3") {

View File

@ -17,13 +17,10 @@
*/
package net.raphimc.viaproxy.util;
import net.lenni0451.reflect.Classes;
import net.lenni0451.reflect.stream.RStream;
import net.lenni0451.reflect.ClassLoaders;
import net.raphimc.viaproxy.util.logging.Logger;
import java.io.File;
import java.net.URL;
import java.util.List;
public class ClassLoaderPriorityUtil {
@ -33,7 +30,7 @@ public class ClassLoaderPriorityUtil {
for (File file : jarsFolder.listFiles()) {
try {
if (file.getName().endsWith(".jar")) {
loadWithHighestPriority(file.toURI().toURL());
ClassLoaders.loadToFront(file.toURI().toURL());
Logger.LOGGER.info("Loaded overriding jar " + file.getName());
}
} catch (Throwable e) {
@ -43,32 +40,4 @@ public class ClassLoaderPriorityUtil {
}
}
private static void loadWithHighestPriority(final URL url) {
// First add the URl into the classpath
final Object ucp = RStream.of(Thread.currentThread().getContextClassLoader()).withSuper().fields().by("ucp").get();
RStream.of(ucp).methods().by("addURL", URL.class).invokeArgs(url);
// Then move the URL to the front of the classpath, so it gets loaded first
final List<Object> ucpPath = RStream.of(ucp).fields().by("path").get();
ucpPath.add(0, ucpPath.remove(ucpPath.size() - 1));
// Force the ClassLoader to populate the whole list of Loaders (Its lazy loaded by default)
if (ClassLoaderPriorityUtil.class.getClassLoader().getResourceAsStream("I_HOPE_THIS_FILE_NEVER_EXISTS_" + System.nanoTime()) != null) {
throw new IllegalStateException("The file that should never exist exists! Please report this to the ViaProxy developers!");
}
// Move the loader for that URL to the front of the list
final Class<?> jarLoaderClazz = Classes.forName(ucp.getClass().getName() + "$JarLoader");
final List<Object> loaders = RStream.of(ucp).fields().by("loaders").get();
for (Object loader : loaders) {
if (jarLoaderClazz.equals(loader.getClass())) {
final URL loaderUrl = RStream.of(loader).fields().filter(URL.class).by(0).get();
if (url.equals(loaderUrl)) {
loaders.add(0, loaders.remove(loaders.size() - 1));
break;
}
}
}
}
}