Col-E / Recaf

The modern Java bytecode editor
https://recaf.coley.software
MIT License
6.02k stars 465 forks source link

Support JDK v23 #865

Closed stevenxxiu closed 1 week ago

stevenxxiu commented 1 week ago

Can JDK v23 be supported? Arch Linux doesn't have v22. I haven't managed to build this.

Col-E commented 1 week ago

You can run the Recaf 4X snapshots with JDK v23. There are no blockers.

stevenxxiu commented 1 week ago

I got this to build for JDK v23, after disabling some parts that failed. The patches may be of interest:

diff --git a/build.gradle b/build.gradle
index af978ba29..0e3a43af2 100644
--- a/build.gradle
@@ -51,7 +51,6 @@
     // gradlew -q javaToolchains - see the list of detected toolchains.
     java {
         toolchain {
-            languageVersion = JavaLanguageVersion.of(22)
         }
     }

@@ -136,8 +135,6 @@
 tasks.register('test') {
     dependsOn(subprojects.test)
     doLast {
-        if (subprojects.test.stream().anyMatch(Task::getDidWork))
-            buildJacocoAggregate.execute()
     }
 }

diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 19cfad969..1e2fbf0d4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
diff --git a/recaf-core/src/test/java/software/coley/recaf/services/compile/JavacCompilerTest.java b/recaf-core/src/test/java/software/coley/recaf/services/compile/JavacCompilerTest.java
index 792358ea9..6d15cc10a 100644
--- a/recaf-core/src/test/java/software/coley/recaf/services/compile/JavacCompilerTest.java
@@ -75,7 +75,7 @@ public static void main(String[] args) {

        // Run compiler, it should fail with no passed workspace due to the unknown 'StringConsumer'
        CompilerResult result = javac.compile(arguments, null, null);
-       assertEquals(1, result.getDiagnostics().size(), "Expected compilation failure");
+       // assertEquals(1, result.getDiagnostics().size(), "Expected compilation failure");
        assertFalse(result.getCompilations().containsKey("HelloWorld"), "Class should have failed compilation");

        // First, create the class that was missing. We cannot use the existing StringConsumer because Javac will find
xxDark commented 1 week ago

I got this to build for JDK v23, after disabling some parts that failed. The patches may be of interest:

diff --git a/build.gradle b/build.gradle
index af978ba29..0e3a43af2 100644
--- a/build.gradle
@@ -51,7 +51,6 @@
     // gradlew -q javaToolchains - see the list of detected toolchains.
     java {
         toolchain {
-            languageVersion = JavaLanguageVersion.of(22)
         }
     }

@@ -136,8 +135,6 @@
 tasks.register('test') {
     dependsOn(subprojects.test)
     doLast {
-        if (subprojects.test.stream().anyMatch(Task::getDidWork))
-            buildJacocoAggregate.execute()
     }
 }

diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 19cfad969..1e2fbf0d4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
diff --git a/recaf-core/src/test/java/software/coley/recaf/services/compile/JavacCompilerTest.java b/recaf-core/src/test/java/software/coley/recaf/services/compile/JavacCompilerTest.java
index 792358ea9..6d15cc10a 100644
--- a/recaf-core/src/test/java/software/coley/recaf/services/compile/JavacCompilerTest.java
@@ -75,7 +75,7 @@ public static void main(String[] args) {

      // Run compiler, it should fail with no passed workspace due to the unknown 'StringConsumer'
      CompilerResult result = javac.compile(arguments, null, null);
-     assertEquals(1, result.getDiagnostics().size(), "Expected compilation failure");
+     // assertEquals(1, result.getDiagnostics().size(), "Expected compilation failure");
      assertFalse(result.getCompilations().containsKey("HelloWorld"), "Class should have failed compilation");

      // First, create the class that was missing. We cannot use the existing StringConsumer because Javac will find

The changes in build.gradle file will break any other build done on a Windows and (probably) non-arch Linux installation. This prevents Gradle from downloading the JDK to build the project. Im not sure how did you attempt to do a build.

stevenxxiu commented 1 week ago

Here JDK isn't installed by Gradle, nor will it have permissions to install a system package. The JDK package is specified in a PKGBUILD, so Gradle doesn't need to install anything.

I suppose without this, the version just needs to be bumped in build.gradle.