Recaf icon indicating copy to clipboard operation
Recaf copied to clipboard

Add support for compiling against JDK 23+

Open xroberx opened this issue 7 months ago • 8 comments

Now that gradle 8.14 is out with support for Java 24, it would be great to be able to compile Recaf with JDK 24. Currently it fails in:

Execution failed for task ':recaf-ui:compileJava'.
> Compilation failed; see the compiler output below.
  warning: unknown enum constant Level.FULL
    reason: class file for com.google.j2objc.annotations.ReflectionSupport$Level not found
  D:\Temp\Recaf\recaf-ui\src\main\java\software\coley\recaf\util\SVG.java:114: warning: [deprecation] load(@org.jetbrains.annotations.NotNull InputStream) in SVGLoader has been deprecated
                                return loader.load(is);
                                             ^
  D:\Temp\Recaf\recaf-ui\src\main\java\software\coley\recaf\util\SVG.java:35: error: cannot access NotNull
                                .load(new ByteArrayInputStream(("<svg width=\"0\" height=\"0\" xmlns=\"http://www.w3.org/2000/svg\">" +
                                ^
    class file for org.jetbrains.annotations.NotNull not found
  1 error
  3 warnings

xroberx avatar Apr 26 '25 14:04 xroberx

Renamed since the issue is actually for compiling in the context of people in nix/aur environments. Existing builds of Recaf run fine in JDK 23/24.

Col-E avatar Apr 27 '25 05:04 Col-E

Renamed since the issue is actually for compiling in the context of people in nix/aur environments. Existing builds of Recaf run fine in JDK 23/24.

Hi Matt,

Actually, the error I posted happens on Windows 11.

Best regards, Robert.

xroberx avatar Apr 27 '25 08:04 xroberx

I used Windows 11

I was mainly referring to people in the discord who had also brought up the issue, along with similar requests in the past. Most people do not have a reason to change the version of Java or Gradle Recaf is compiled against. End users are intended to receive the Recaf jar compiled against Java 22. Running with a higher version works, but when somebody chooses to change the version of Java Recaf compiles against this problem occurs.

Col-E avatar Apr 27 '25 18:04 Col-E

20e27a92eface509643a7acc83a85e83a9f43e68 - I upgraded to Gradle 9 and was able to build with JDK 25 (The project still targets 22, but the host Gradle JVM uses 25). The weird error no longer occurs.

Col-E avatar Aug 31 '25 06:08 Col-E

Hi Matt,

I am unable to build with JDK 24, could you please share the steps you followed? I changed languageVersion = JavaLanguageVersion.of(22) to languageVersion = JavaLanguageVersion.of(24), but I am getting the exact same error you can see in the first message.

Best regards, Robert.

xroberx avatar Aug 31 '25 07:08 xroberx

Made a workaround for the SVG class complaining about a class we don't even reference. Try again and use TARGET_VERSION as an env variable to specify your desired JDK target version. It defaults to 22 but you can specify 24, 25, etc.

Col-E avatar Aug 31 '25 15:08 Col-E

Thank you so much, Matt. It's working perfectly now.

xroberx avatar Aug 31 '25 17:08 xroberx

I updated JSVG to 2.0.0 and curiously enough, it doesn't encounter this behavior in 2.0.0. So I downgrade it back to 1.7.3 and it comes back. In both versions, the method being called has the same annotation. Uhhh.....😕 I mean sure whatever if I can remove the reflection workaround that's great but this is still incredibly odd that this was ever an issue.

Col-E avatar Sep 01 '25 23:09 Col-E