Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ModularURLHandler hacks in tests #157

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading