Recaf
Recaf copied to clipboard
Add support for compiling against JDK 23+
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
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.
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.
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.
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.
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.
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.
Thank you so much, Matt. It's working perfectly now.
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.