Skip to content

Commit

Permalink
Remove ModularURLHandler hacks in tests (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte authored Jun 11, 2024
1 parent f119ede commit 5d17885
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 22 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ accesstransformers_version=10.0.1
coremods_version=7.0.3
eventbus_version=7.0.16
modlauncher_version=10.1.10
securejarhandler_version=3.0.4
securejarhandler_version=3.0.7
bootstraplauncher_version=1.1.8
asm_version=9.5
mixin_version=0.13.1+mixin.0.8.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private void transformTestClass(Dist dist, @Language("java") String classContent

private void transformTestClass(Dist dist, @Language("java") String classContent, Consumer<Class<?>> asserter) throws Exception {
var distCleaner = new RuntimeDistCleaner();
distCleaner.getExtension().accept(dist);
distCleaner.setDistribution(dist);

var modJar = tempDir.resolve("modjar.jar");
new ModFileBuilder(modJar)
Expand Down
20 changes: 0 additions & 20 deletions loader/src/test/java/net/neoforged/fml/loading/LauncherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import static org.mockito.Mockito.when;

import cpw.mods.cl.JarModuleFinder;
import cpw.mods.cl.ModularURLHandler;
import cpw.mods.cl.ModuleClassLoader;
import cpw.mods.cl.UnionURLStreamHandler;
import cpw.mods.jarhandling.SecureJar;
import cpw.mods.modlauncher.Launcher;
import cpw.mods.modlauncher.api.IEnvironment;
Expand Down Expand Up @@ -43,7 +41,6 @@
import net.neoforged.neoforgespi.language.IModFileInfo;
import net.neoforged.neoforgespi.language.IModInfo;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mock;
import org.mockito.MockedStatic;
Expand All @@ -70,23 +67,6 @@ public abstract class LauncherTest {
// and ModDirTransformerDiscoverer, which pick up files like mixin.
Set<Path> locatedPaths = new HashSet<>();

/**
* See https://github.com/McModLauncher/securejarhandler/pull/74
*/
@BeforeAll
static void fixUpUnionUrlProtocol() throws Exception {
// Force Class-Init of ModuleClassLoader, since it'll set the URLStreamHandlerFactory and call initFrom
try {
new ModuleClassLoader(null, null, null);
} catch (Exception ignored) {}

// Now fix up the handlers in the handler
var handlers = Map.of("union", new UnionURLStreamHandler());
var handlersField = ModularURLHandler.class.getDeclaredField("handlers");
handlersField.setAccessible(true);
handlersField.set(ModularURLHandler.INSTANCE, handlers);
}

@BeforeEach
void setUp() throws IOException {
Launcher.INSTANCE = launcher;
Expand Down

0 comments on commit 5d17885

Please sign in to comment.