feat(crash): ModResolutionException (Could not resolve valid mod collection)

This commit is contained in:
huanghongxun
2021-10-13 02:32:56 +08:00
parent 6b656bdc48
commit 7973179ddf
9 changed files with 53 additions and 10 deletions

View File

@@ -37,7 +37,7 @@ public final class CrashReportAnalyzer {
OPENJ9(Pattern.compile("(Open J9 is not supported|OpenJ9 is incompatible)")),
TOO_OLD_JAVA(Pattern.compile("java\\.lang\\.UnsupportedClassVersionError: (.*?) version (?<expected>\\d+)\\.0"), "expected"),
JVM_32BIT(Pattern.compile("Could not reserve enough space for (.*?) object heap")),
JVM_32BIT(Pattern.compile("(Could not reserve enough space for (.*?) object heap|The specified size exceeds the maximum representable size)")),
// Some mods/shader packs do incorrect GL operations.
GL_OPERATION_FAILURE(Pattern.compile("1282: Invalid operation")),
@@ -68,6 +68,7 @@ public final class CrashReportAnalyzer {
MOD_RESOLUTION_CONFLICT(Pattern.compile("ModResolutionException: Found conflicting mods: (?<sourcemod>.*) conflicts with (?<destmod>.*)"), "sourcemod", "destmod"),
MOD_RESOLUTION_MISSING(Pattern.compile("ModResolutionException: Could not find required mod: (?<sourcemod>.*) requires (?<destmod>.*)"), "sourcemod", "destmod"),
MOD_RESOLUTION_MISSING_MINECRAFT(Pattern.compile("ModResolutionException: Could not find required mod: (?<mod>.*) requires \\{minecraft @ (?<version>.*)}"), "mod", "version"),
MOD_RESOLUTION_COLLECTION(Pattern.compile("ModResolutionException: Could not resolve valid mod collection \\(at: (?<sourcemod>.*) requires (?<destmod>.*)\\)"), "sourcemod", "destmod"),
// Some mods require a file not existing, asking user to manually delete it
FILE_ALREADY_EXISTS(Pattern.compile("java\\.nio\\.file\\.FileAlreadyExistsException: (?<file>.*)"), "file"),
// Forge found some mod crashed in game loading

View File

@@ -51,18 +51,34 @@ public class CrashReportAnalyzerTest {
CrashReportAnalyzer.Rule.JDK_9);
}
@Test
public void jvm32() throws IOException {
CrashReportAnalyzer.Result result = findResultByRule(
CrashReportAnalyzer.anaylze(loadLog("/logs/jvm_32bit.txt")),
CrashReportAnalyzer.Rule.JVM_32BIT);
}
@Test
public void modResolution() throws IOException {
CrashReportAnalyzer.Result result = findResultByRule(
CrashReportAnalyzer.anaylze(loadLog("/logs/mod_resolution.txt")),
CrashReportAnalyzer.Rule.MOD_RESOLUTION);
Assert.assertEquals(("Errors were found!\n" +
" - Mod test depends on mod {fabricloader @ [>=0.11.3]}, which is missing!\n" +
" - Mod test depends on mod {fabric @ [*]}, which is missing!\n" +
" - Mod test depends on mod {java @ [>=16]}, which is missing!\n").replaceAll("\\s+", ""),
" - Mod test depends on mod {fabricloader @ [>=0.11.3]}, which is missing!\n" +
" - Mod test depends on mod {fabric @ [*]}, which is missing!\n" +
" - Mod test depends on mod {java @ [>=16]}, which is missing!\n").replaceAll("\\s+", ""),
result.getMatcher().group("reason").replaceAll("\\s+", ""));
}
@Test
public void modResolutionCollection() throws IOException {
CrashReportAnalyzer.Result result = findResultByRule(
CrashReportAnalyzer.anaylze(loadLog("/logs/mod_resolution_collection.txt")),
CrashReportAnalyzer.Rule.MOD_RESOLUTION_COLLECTION);
Assert.assertEquals("tabtps-fabric", result.getMatcher().group("sourcemod"));
Assert.assertEquals("{fabricloader @ [>=0.11.1]", result.getMatcher().group("destmod"));
}
@Test
public void tooOldJava() throws IOException {
CrashReportAnalyzer.Result result = findResultByRule(

View File

@@ -17,7 +17,6 @@
*/
package org.jackhuang.hmcl.game;
import org.jackhuang.hmcl.util.Pair;
import org.jackhuang.hmcl.util.Range;
import org.jackhuang.hmcl.util.versioning.VersionNumber;
import org.junit.Assert;
@@ -27,13 +26,13 @@ public class JavaVersionConstraintTest {
@Test
public void vanillaJava16() {
Pair<Range<VersionNumber>, Range<VersionNumber>> range = JavaVersionConstraint.findSuitableJavaVersionRange(
JavaVersionConstraint.VersionRange range = JavaVersionConstraint.findSuitableJavaVersionRange(
VersionNumber.asVersion("1.17"),
null
);
Assert.assertEquals(
Range.between(VersionNumber.asVersion("16"), VersionNumber.asVersion(JavaVersionConstraint.MAX)),
range.getKey());
range.getMandatory());
}
}

View File

@@ -0,0 +1,4 @@
Invalid initial heap size: -Xms4096M
The specified size exceeds the maximum representable size.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

View File

@@ -0,0 +1,17 @@
[00:39:00] [main/INFO]: Loading for game Minecraft 1.17.1
Exception in thread "main" java.lang.RuntimeException: Failed to resolve mods!
at net.fabricmc.loader.FabricLoader.load(FabricLoader.java:159)
at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:122)
at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26)
Caused by: net.fabricmc.loader.discovery.ModResolutionException: Could not resolve valid mod collection (at: tabtps-fabric requires {fabricloader @ [>=0.11.1]})
at net.fabricmc.loader.discovery.ModResolver.findCompatibleSet(ModResolver.java:184)
at net.fabricmc.loader.discovery.ModResolver.resolve(ModResolver.java:508)
at net.fabricmc.loader.FabricLoader.load(FabricLoader.java:157)
... 2 more
Caused by: net.fabricmc.loader.util.sat4j.specs.ContradictionException: Creating Empty clause ?
at net.fabricmc.loader.util.sat4j.minisat.constraints.cnf.Clauses.propagationCheck(Clauses.java:117)
at net.fabricmc.loader.util.sat4j.minisat.constraints.cnf.Clauses.sanityCheck(Clauses.java:97)
at net.fabricmc.loader.util.sat4j.minisat.constraints.MixedDataStructureDanielWL.createClause(MixedDataStructureDanielWL.java:81)
at net.fabricmc.loader.util.sat4j.minisat.core.Solver.addClause(Solver.java:401)
at net.fabricmc.loader.discovery.ModResolver.findCompatibleSet(ModResolver.java:182)
... 4 more