Skip to content

Add support for Minecraft 26.2-snapshot-1+ to unofficial supported platforms#5928

Merged
Glavo merged 6 commits into
HMCL-dev:mainfrom
Glavo:multiarch
Apr 7, 2026
Merged

Add support for Minecraft 26.2-snapshot-1+ to unofficial supported platforms#5928
Glavo merged 6 commits into
HMCL-dev:mainfrom
Glavo:multiarch

Conversation

@Glavo
Copy link
Copy Markdown
Member

@Glavo Glavo commented Apr 7, 2026

No description provided.

@Glavo
Copy link
Copy Markdown
Member Author

Glavo commented Apr 7, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates LWJGL native dependencies in natives.json, adding support for ARM64, RISCV64, and FreeBSD platforms. In DefaultLauncher.java, the logic for determining the native library path was refined to support subfolders introduced in recent Minecraft snapshots, and the internal Command class was refactored into a record. Feedback was provided regarding the robustness of the java.library.path extraction logic, specifically concerning multiple property occurrences and empty path handling.

Comment on lines +305 to +312
Optional<String> javaLibraryPathArgument = parsedArguments.stream().filter(it -> it.startsWith(libraryPathPrefix)).findFirst();
if (javaLibraryPathArgument.isPresent()) {
// Since Minecraft 26.2-snapshot-1, the java.library.path will be located in a subfolder of ${natives_directory}.
try {
javaNativeFolder = Path.of(javaLibraryPathArgument.get().substring(libraryPathPrefix.length()));
} catch (IllegalArgumentException ignored) {
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The logic for extracting java.library.path is fragile. findFirst() may not correctly handle multiple occurrences of the property, and Path.of() can throw an InvalidPathException if the path string is malformed. Additionally, if the property value is empty, Path.of("") resolves to the current working directory, which could lead to unintended directory operations. Consider finding the last occurrence of the property and validating the path before use.

Suggested change
Optional<String> javaLibraryPathArgument = parsedArguments.stream().filter(it -> it.startsWith(libraryPathPrefix)).findFirst();
if (javaLibraryPathArgument.isPresent()) {
// Since Minecraft 26.2-snapshot-1, the java.library.path will be located in a subfolder of ${natives_directory}.
try {
javaNativeFolder = Path.of(javaLibraryPathArgument.get().substring(libraryPathPrefix.length()));
} catch (IllegalArgumentException ignored) {
}
}
Optional<String> javaLibraryPathArgument = parsedArguments.stream()
.filter(it -> it.startsWith(libraryPathPrefix))
.reduce((first, second) -> second);
if (javaLibraryPathArgument.isPresent()) {
String pathStr = javaLibraryPathArgument.get().substring(libraryPathPrefix.length());
if (!pathStr.isEmpty()) {
try {
javaNativeFolder = Path.of(pathStr);
} catch (Exception ignored) {
}
}
}

@Glavo
Copy link
Copy Markdown
Member Author

Glavo commented Apr 7, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates natives.json to include native library definitions for shaderc, spvc, vma, and vulkan on Linux ARM64, RISC-V 64, and FreeBSD, while removing redundant LWJGL entries. It also modifies DefaultLauncher.java to handle native library path subdirectories in JVM arguments and refactors the Command class into a record. Feedback indicates that the path resolution logic should catch InvalidPathException instead of IllegalArgumentException to avoid runtime crashes.

@Glavo Glavo merged commit 7d41f7b into HMCL-dev:main Apr 7, 2026
2 checks passed
@Glavo Glavo deleted the multiarch branch April 7, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant