You've already forked AstralRinth
forked from didirus/AstralRinth
Merge commit 'bc90c27e27df60f95a1fdc3572fb0bd5aa4fd102' into feature-clean
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "theseus"
|
||||
version = "0.10.1"
|
||||
version = "1.0.0-local" # The actual version is set by the theseus-build workflow on tagging
|
||||
authors = ["Jai A <jaiagr+gpg@pm.me>"]
|
||||
edition.workspace = true
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.modrinth.theseus;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.AccessibleObject;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
@@ -76,14 +77,14 @@ public final class MinecraftLaunch {
|
||||
|
||||
Object thisObject = null;
|
||||
if (!Modifier.isStatic(mainMethod.getModifiers())) {
|
||||
thisObject = mainClass.getDeclaredConstructor().newInstance();
|
||||
thisObject = forceAccessible(mainClass.getDeclaredConstructor()).newInstance();
|
||||
}
|
||||
|
||||
final Object[] parameters = mainMethod.getParameterCount() > 0 ? new Object[] {args} : new Object[] {};
|
||||
|
||||
mainMethod.invoke(thisObject, parameters);
|
||||
} else {
|
||||
findSimpleMainMethod(mainClass).invoke(null, new Object[] {args});
|
||||
forceAccessible(findSimpleMainMethod(mainClass)).invoke(null, new Object[] {args});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,4 +116,14 @@ public final class MinecraftLaunch {
|
||||
private static Method findSimpleMainMethod(Class<?> mainClass) throws NoSuchMethodException {
|
||||
return mainClass.getMethod("main", String[].class);
|
||||
}
|
||||
|
||||
private static <T extends AccessibleObject> T forceAccessible(T object) throws ReflectiveOperationException {
|
||||
try {
|
||||
final Method setAccessible0 = AccessibleObject.class.getDeclaredMethod("setAccessible0", boolean.class);
|
||||
setAccessible0.setAccessible(true);
|
||||
setAccessible0.invoke(object, true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
}
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -622,6 +622,12 @@ pub async fn launch_minecraft(
|
||||
.into_iter(),
|
||||
);
|
||||
|
||||
// The java launcher requires access to java.lang.reflect in order to force access in to
|
||||
// whatever module the main class is in
|
||||
if java_version.parsed_version >= 9 {
|
||||
command.arg("--add-opens=java.base/java.lang.reflect=ALL-UNNAMED");
|
||||
}
|
||||
|
||||
// The java launcher code requires internal JDK code in Java 25+ in order to support JEP 512
|
||||
if java_version.parsed_version >= 25 {
|
||||
command.arg("--add-opens=jdk.internal/jdk.internal.misc=ALL-UNNAMED");
|
||||
|
||||
Reference in New Issue
Block a user