* Support analyze crash reasons from latest.log * Fix
This commit is contained in:
@@ -114,7 +114,7 @@ public final class CrashReportAnalyzer {
|
||||
FORGE_REPEAT_INSTALLATION(Pattern.compile("--launchTarget, fmlclient, --fml.forgeVersion,[\\w\\W]*?--launchTarget, fmlclient, --fml.forgeVersion,[\\w\\W\\n\\r]*?MultipleArgumentsForOptionException: Found multiple arguments for option gameDir, but you asked for only one")),//https://github.com/huanghongxun/HMCL/issues/1880
|
||||
OPTIFINE_REPEAT_INSTALLATION(Pattern.compile("ResolutionException: Module optifine reads another module named optifine")),//Optifine 重复安装(及Mod文件夹有,自动安装也有)
|
||||
JAVA_VERSION_IS_TOO_HIGH(Pattern.compile("(Unable to make protected final java\\.lang\\.Class java\\.lang\\.ClassLoader\\.defineClass|java\\.lang\\.NoSuchFieldException: ucp|Unsupported class file major version|because module java\\.base does not export|java\\.lang\\.ClassNotFoundException: jdk\\.nashorn\\.api\\.scripting\\.NashornScriptEngineFactory|java\\.lang\\.ClassNotFoundException: java\\.lang\\.invoke\\.LambdaMetafactory)")),//Java版本过高
|
||||
|
||||
|
||||
//Forge 默认会把每一个 mod jar 都当做一个 JPMS 的模块(Module)加载。在这个 jar 没有给出 module-info 声明的情况下,JPMS 会采用这样的顺序决定 module 名字:
|
||||
//1. META-INF/MANIFEST.MF 里的 Automatic-Module-Name
|
||||
//2. 根据文件名生成。文件名里的 .jar 后缀名先去掉,然后检查是否有 -(\\d+(\\.|$)) 的部分,有的话只取 - 前面的部分,- 后面的部分成为 module 的版本号(即尝试判断文件名里是否有版本号,有的话去掉),然后把不是拉丁字母和数字的字符(正则表达式 [^A-Za-z0-9])都换成点,然后把连续的多个点换成一个点,最后去掉开头和结尾的点。那么
|
||||
@@ -178,10 +178,30 @@ public final class CrashReportAnalyzer {
|
||||
public Matcher getMatcher() {
|
||||
return matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Result result = (Result) o;
|
||||
|
||||
if (rule != result.rule) return false;
|
||||
if (!log.equals(result.log)) return false;
|
||||
return matcher.equals(result.matcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = rule.hashCode();
|
||||
result = 31 * result + log.hashCode();
|
||||
result = 31 * result + matcher.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Result> anaylze(String log) {
|
||||
List<Result> results = new ArrayList<>();
|
||||
public static Set<Result> anaylze(String log) {
|
||||
Set<Result> results = new HashSet<>();
|
||||
for (Rule rule : Rule.values()) {
|
||||
Matcher matcher = rule.pattern.matcher(log);
|
||||
if (matcher.find()) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class CrashReportAnalyzerTest {
|
||||
return IOUtils.readFullyAsString(is);
|
||||
}
|
||||
|
||||
private CrashReportAnalyzer.Result findResultByRule(List<CrashReportAnalyzer.Result> results, CrashReportAnalyzer.Rule rule) {
|
||||
private CrashReportAnalyzer.Result findResultByRule(Set<CrashReportAnalyzer.Result> results, CrashReportAnalyzer.Rule rule) {
|
||||
CrashReportAnalyzer.Result r = results.stream().filter(result -> result.getRule() == rule).findFirst().orElse(null);
|
||||
assertNotNull(r);
|
||||
return r;
|
||||
|
||||
Reference in New Issue
Block a user