From 3dbe6ccdeda092f3c32cb0c81bbe8c5a1af4cccb Mon Sep 17 00:00:00 2001 From: cpw Date: Tue, 24 Jun 2014 22:15:11 -0400 Subject: [PATCH] Fix up other exit points. Should stop process hangs for clean exits. --- .../java/cpw/mods/fml/relauncher/FMLSecurityManager.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fml/src/main/java/cpw/mods/fml/relauncher/FMLSecurityManager.java b/fml/src/main/java/cpw/mods/fml/relauncher/FMLSecurityManager.java index 4c7fba0ec..71a092544 100644 --- a/fml/src/main/java/cpw/mods/fml/relauncher/FMLSecurityManager.java +++ b/fml/src/main/java/cpw/mods/fml/relauncher/FMLSecurityManager.java @@ -16,9 +16,11 @@ public class FMLSecurityManager extends SecurityManager { String permName = perm.getName() != null ? perm.getName() : "missing"; if (permName.startsWith("exitVM")) { - String callingClass = getClassContext()[4].getName(); - // FML is allowed to call system exit - if (!callingClass.startsWith("cpw.mods.fml.")) + Class[] classContexts = getClassContext(); + String callingClass = classContexts.length > 3 ? classContexts[4].getName() : "none"; + String callingParent = classContexts.length > 4 ? classContexts[5].getName() : "none"; + // FML is allowed to call system exit and the Minecraft applet (from the quit button) + if (!(callingClass.startsWith("cpw.mods.fml.") || ( "net.minecraft.client.Minecraft".equals(callingClass) && "net.minecraft.client.Minecraft".equals(callingParent)) || ("net.minecraft.server.dedicated.DedicatedServer".equals(callingClass) && "net.minecraft.server.MinecraftServer".equals(callingParent)))) { throw new ExitTrappedException(); }