diff --git a/Injector/src/main/java/cn/xiaozhou233/orangex/injector/Main.java b/Injector/src/main/java/cn/xiaozhou233/orangex/injector/Main.java index 4333eaa..a54b749 100644 --- a/Injector/src/main/java/cn/xiaozhou233/orangex/injector/Main.java +++ b/Injector/src/main/java/cn/xiaozhou233/orangex/injector/Main.java @@ -13,17 +13,17 @@ public class Main { public static String orangexPath = new File(System.getProperty("user.home") + "/.orangex").getAbsolutePath(); private static int pid = -1; - public static void main(String[] args) { + public static void main(String[] args) throws Exception { System.setOut(new PrintStream( new FileOutputStream(FileDescriptor.out), true, - StandardCharsets.UTF_8 + StandardCharsets.UTF_8.name() )); System.setErr(new PrintStream( new FileOutputStream(FileDescriptor.err), true, - StandardCharsets.UTF_8 + StandardCharsets.UTF_8.name() )); System.out.println("================"); diff --git a/OrangeX/build.gradle b/OrangeX/build.gradle index cb46b27..302bab6 100644 --- a/OrangeX/build.gradle +++ b/OrangeX/build.gradle @@ -37,9 +37,42 @@ dependencies { // the API whose native methods are not registered. } +// The 26.2 input classes import game classes that are records / class-file +// version 69, so they cannot be compiled with --release 8. Keep them in a +// separate source set compiled by JDK 25, but still emit Java 8 bytecode so a +// 1.8.9 JVM can load the rest of the jar. +sourceSets { + main { + java { + exclude 'cn/xiaozhou233/orangex/input/v26_2/**' + } + } + v26_2 { + java { + srcDir 'src/main/java' + include 'cn/xiaozhou233/orangex/input/v26_2/**' + } + compileClasspath += sourceSets.main.output + compileClasspath += configurations.compileClasspath + } +} + +tasks.named('compileV26_2Java', JavaCompile).configure { + javaCompiler = javaToolchains.compilerFor { + languageVersion = JavaLanguageVersion.of(25) + } + // No --release: the JDK 25 platform classpath is needed to resolve records + // from Minecraft26.2.jar, while -source/-target 8 keeps the output loadable + // by Java 8. + options.release = null + options.encoding = 'UTF-8' +} + tasks.named('shadowJar') { destinationDirectory = rootProject.layout.projectDirectory.dir('out/tmp') archiveFileName = "${project.name}.jar" + dependsOn tasks.named('v26_2Classes') + from sourceSets.v26_2.output } shadowJar { diff --git a/build.gradle b/build.gradle index 5d70af2..b143c23 100644 --- a/build.gradle +++ b/build.gradle @@ -63,7 +63,7 @@ subprojects { options.encoding = 'UTF-8' if (JavaVersion.current().isJava9Compatible()) { // Fail fast if a post-Java-8 API is used. - options.release = 25 + options.release = 8 } } }