mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
JVM Halt через несуществующий нативный метод
This commit is contained in:
parent
d6f203d9bf
commit
a944282469
4 changed files with 37 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -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<String> toPath(Iterable<Path> path) {
|
||||
|
|
14
libLauncher/src/main/java/ru/gravit/utils/NativeJVMHalt.java
Normal file
14
libLauncher/src/main/java/ru/gravit/utils/NativeJVMHalt.java
Normal file
|
@ -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();
|
||||
}
|
|
@ -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()))
|
||||
|
|
Loading…
Reference in a new issue