diff --git a/Launcher/src/main/java/ru/gravit/launcher/AvanguardStarter.java b/Launcher/src/main/java/ru/gravit/launcher/AvanguardStarter.java index 06081e55..d481b9ad 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/AvanguardStarter.java +++ b/Launcher/src/main/java/ru/gravit/launcher/AvanguardStarter.java @@ -9,6 +9,7 @@ import net.minecraftforge.fml.SafeExitJVM; import ru.gravit.launcher.hasher.DirWatcher; import ru.gravit.launcher.hasher.HashedDir; +import ru.gravit.utils.NativeJVMHalt; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.JVMHelper; @@ -51,11 +52,19 @@ public void run() { static void safeHalt(int exitcode) { try { - SafeExitJVM.exit(exitcode); - } catch (Throwable e) - { SafeExitJVMLegacy.exit(exitcode); + } catch (Throwable ignored) + { + } + try { + SafeExitJVM.exit(exitcode); + } catch (Throwable ignored) + { + + } + NativeJVMHalt halt = new NativeJVMHalt(exitcode); + halt.halt(); } public static final String NAME = Launcher.getConfig().projectname; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/hasher/DirWatcher.java b/libLauncher/src/main/java/ru/gravit/launcher/hasher/DirWatcher.java index 998e4460..10a386cd 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/hasher/DirWatcher.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/hasher/DirWatcher.java @@ -19,6 +19,7 @@ import net.minecraftforge.fml.SafeExitJVM; import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.hasher.HashedEntry.Type; +import ru.gravit.utils.NativeJVMHalt; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.JVMHelper; import ru.gravit.utils.helper.JVMHelper.OS; @@ -72,8 +73,16 @@ private static void handleError(Throwable e) { SafeExitJVMLegacy.exit(-123); } catch (Throwable ignored) { - SafeExitJVM.exit(-123); + } + try { + SafeExitJVM.exit(-123); + } catch (Throwable ignored) + { + + } + NativeJVMHalt halt = new NativeJVMHalt(-123); + halt.halt(); } private static Deque toPath(Iterable path) { diff --git a/libLauncher/src/main/java/ru/gravit/utils/NativeJVMHalt.java b/libLauncher/src/main/java/ru/gravit/utils/NativeJVMHalt.java new file mode 100644 index 00000000..786861d4 --- /dev/null +++ b/libLauncher/src/main/java/ru/gravit/utils/NativeJVMHalt.java @@ -0,0 +1,14 @@ +package ru.gravit.utils; + +import ru.gravit.utils.helper.LogHelper; + +public class NativeJVMHalt { + public NativeJVMHalt(int haltCode) { + this.haltCode = haltCode; + LogHelper.error("JVM exit code %d",haltCode); + halt(); + } + + public int haltCode; + public native void halt(); +} diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java index 2165d916..cc5e6f37 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java +++ b/libLauncher/src/main/java/ru/gravit/utils/helper/JVMHelper.java @@ -118,6 +118,7 @@ public static URL[] getClassPathURL() { } public static void checkStackTrace(Class mainClass) { + LogHelper.debug("Testing stacktrace"); Exception e = new Exception("Testing stacktrace"); StackTraceElement[] list = e.getStackTrace(); if(!list[list.length - 1].getClassName().equals(mainClass.getName()))