feat(crash): read crash report from raw log as fallback.

This commit is contained in:
huanghongxun
2021-10-20 01:13:52 +08:00
parent de421f93b5
commit 6707ce1ed9
8 changed files with 187 additions and 27 deletions

View File

@@ -0,0 +1,46 @@
/*
* Hello Minecraft! Launcher
* Copyright (C) 2020 huangyuhui <huanghongxun2008@126.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
public final class JavaFXLauncher {
private JavaFXLauncher() {
}
public static void start() {
// init JavaFX Toolkit
try {
// Java 9 or Latter
final MethodHandle startup =
MethodHandles.publicLookup().findStatic(
javafx.application.Platform.class, "startup", MethodType.methodType(void.class, Runnable.class));
startup.invokeExact((Runnable) () -> {
});
} catch (Throwable e) {
// Java 8
try {
Class.forName("javafx.embed.swing.JFXPanel").getDeclaredConstructor().newInstance();
} catch (Throwable ignored) {
}
}
}
}

View File

@@ -17,6 +17,7 @@
*/
package org.jackhuang.hmcl.util;
import org.jackhuang.hmcl.JavaFXLauncher;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.task.TaskExecutor;
@@ -25,9 +26,6 @@ import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
@@ -80,20 +78,7 @@ public class TaskTest {
}
public void testThenAccept() {
// init JavaFX Toolkit
try {
// Java 9 or Latter
final MethodHandle startup =
MethodHandles.publicLookup().findStatic(
javafx.application.Platform.class, "startup", MethodType.methodType(void.class, Runnable.class));
startup.invokeExact((Runnable) () -> {});
} catch (Throwable e) {
// Java 8
try {
Class.forName("javafx.embed.swing.JFXPanel").getDeclaredConstructor().newInstance();
} catch (Throwable ignored) {
}
}
JavaFXLauncher.start();
AtomicBoolean flag = new AtomicBoolean();
boolean result = Task.supplyAsync(JavaVersion::fromCurrentEnvironment)
.thenAcceptAsync(Schedulers.javafx(), javaVersion -> {