feat(crash): read crash report from raw log as fallback.
This commit is contained in:
@@ -155,6 +155,13 @@ public final class CrashReportAnalyzer {
|
||||
}
|
||||
}
|
||||
|
||||
public static String extractCrashReport(String rawLog) {
|
||||
int begin = rawLog.lastIndexOf("---- Minecraft Crash Report ----");
|
||||
int end = rawLog.lastIndexOf("#@!@# Game crashed! Crash report saved to");
|
||||
if (begin == -1 || end == -1 || begin >= end) return null;
|
||||
return rawLog.substring(begin, end);
|
||||
}
|
||||
|
||||
private static final Pattern CRASH_REPORT_STACK_TRACE_PATTERN = Pattern.compile("Description: (.*?)[\\n\\r]+(?<stacktrace>[\\w\\W\\n\\r]+)A detailed walkthrough of the error");
|
||||
private static final Pattern STACK_TRACE_LINE_PATTERN = Pattern.compile("at (?<method>.*?)\\((.*?)\\)");
|
||||
private static final Set<String> PACKAGE_KEYWORD_BLACK_LIST = new HashSet<>(Arrays.asList(
|
||||
@@ -171,7 +178,7 @@ public final class CrashReportAnalyzer {
|
||||
"fabricmc", "loader", "game", "knot", "launch", "mixin" // fabric
|
||||
));
|
||||
|
||||
public static Set<String> findKeywordsFromCrashReport(String crashReport) throws IOException, InvalidPathException {
|
||||
public static Set<String> findKeywordsFromCrashReport(String crashReport) {
|
||||
Matcher matcher = CRASH_REPORT_STACK_TRACE_PATTERN.matcher(crashReport);
|
||||
Set<String> result = new HashSet<>();
|
||||
if (matcher.find()) {
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 -> {
|
||||
|
||||
Reference in New Issue
Block a user