[FIX] Расширенная обработка ошибок NativeJVMHalt

This commit is contained in:
Gravit 2020-02-28 11:10:40 +07:00
parent ec5c076a16
commit de47594083
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
3 changed files with 16 additions and 8 deletions

View file

@ -61,7 +61,7 @@ public static void exitLauncher(int code)
modulesManager.invokeEvent(new ClientExitPhase(code)); modulesManager.invokeEvent(new ClientExitPhase(code));
try { try {
System.exit(code); System.exit(code);
} catch (Exception e) //Forge Security Manager? } catch (Throwable e) //Forge Security Manager?
{ {
NativeJVMHalt.haltA(code); NativeJVMHalt.haltA(code);
} }
@ -99,7 +99,7 @@ public static void main(String... args) throws Throwable {
LogHelper.debug("Launcher started in %dms", endTime - startTime); LogHelper.debug("Launcher started in %dms", endTime - startTime);
//Request.service.close(); //Request.service.close();
//FunctionalBridge.close(); //FunctionalBridge.close();
SystemService.exit(0); LauncherEngine.exitLauncher(0);
} }
public static void initGson(ClientModuleManager modulesManager) { public static void initGson(ClientModuleManager modulesManager) {

View file

@ -301,7 +301,7 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl
try { try {
mainMethod.invokeWithArguments((Object) args.toArray(new String[0])); mainMethod.invokeWithArguments((Object) args.toArray(new String[0]));
} finally { } finally {
SystemService.exit(0); LauncherEngine.exitLauncher(0);
} }
} }

View file

@ -2,6 +2,7 @@
import pro.gravit.launcher.patches.FMLPatcher; import pro.gravit.launcher.patches.FMLPatcher;
import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.JVMHelper;
import pro.gravit.utils.helper.LogHelper;
import javax.swing.*; import javax.swing.*;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
@ -22,23 +23,30 @@ private boolean aaabBooleanC_D() {
} }
public static void haltA(int code) { public static void haltA(int code) {
Throwable[] th = new Throwable[3];
NativeJVMHalt halt = new NativeJVMHalt(code); NativeJVMHalt halt = new NativeJVMHalt(code);
try { try {
JVMHelper.RUNTIME.exit(code); JVMHelper.RUNTIME.exit(code);
} catch (Throwable ignored) { } catch (Throwable exitExc) {
th[0] = exitExc;
try { try {
new WindowShutdown(); new WindowShutdown();
} catch (Throwable ignored1) { } catch (Throwable windowExc) {
th[1] = windowExc;
} }
} }
try { try {
FMLPatcher.exit(code); FMLPatcher.exit(code);
} catch (Throwable ignored) { } catch (Throwable fmlExc) {
th[2] = fmlExc;
}
for(Throwable t : th)
{
if(t != null) LogHelper.error(t);
} }
halt.aaabbb38C_D();
boolean a = halt.aaabBooleanC_D(); boolean a = halt.aaabBooleanC_D();
System.out.println(a); System.out.println(a);
halt.aaabbb38C_D();
} }