Skip to content

Java 21 with Graal support #1211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 112 commits into from
Mar 11, 2025
Merged

Java 21 with Graal support #1211

merged 112 commits into from
Mar 11, 2025

Conversation

crogoz
Copy link
Contributor

@crogoz crogoz commented Feb 18, 2025

Before this PR

No java 21 support

After this PR

Java 21 support that can run either through the native-image - by setting the gradle property palantir.native.formatter=true or - by default - using the java-based implementation.

Adds the following support:

  • JEP-441 Pattern Matching switch (with guard)
  • JEP-443 Unnamed Patterns and Variables
  • Fixes the comments indentation inside switch statements

==COMMIT_MSG==
Java 21 Support with Graal & Java-based Implementations
==COMMIT_MSG==

FLUPs:

Possible downsides?

+ " incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis"
+ " nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo"
+ " consequat.");
System.err.println(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -11,8 +11,3 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
}

tasks.withType(JavaCompile).named('compileJava') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved all the *Compatibility blocks to the root build.gradle in the subprojects block. We need to set the sourceCompatibility for groovy sourceSets as well, so I think it is better to always set the source & target compatibility to 11

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to set the sourceCompatibility for the groovy source sets too? If we can, I'd like to contain this strangeness to just the place that needs, ie the code for running the actual formatter

Copy link
Contributor

@CRogers CRogers Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might avoid being able to do this by keeping libraryTarget = 17 on the root project (so the gradle plugin, idea plugin etc use 17) then putting libraryTarget = 21 on the palantir-java-format and palantir-java-format-spi projects

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I mean target = 21 in the subprojects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed in ff54182

@@ -1,56 +0,0 @@
[
{
"name":"[Lcom.fasterxml.jackson.databind.deser.Deserializers;"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crogoz crogoz marked this pull request as ready for review March 10, 2025 11:39
@crogoz crogoz requested a review from CRogers March 10, 2025 11:40
build.gradle Outdated
}

jdks {
daemonTarget = 17
daemonTarget = 21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need daemonTarget 21?

Copy link
Contributor Author

@crogoz crogoz Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, but since everything else would use java 21, I thought it is OK to move the daemon as well.
Moved it back to 17 5ca751c

@@ -67,7 +71,8 @@ subprojects {
}

javaVersions {
libraryTarget = 17
libraryTarget = 21
runtime = 21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libraryTarget implies runtime, I think we can just leave this out to keep it like our other Gradle plugins.

@crogoz
Copy link
Contributor Author

crogoz commented Mar 11, 2025

👍

@bulldozer-bot bulldozer-bot bot merged commit 46d7be3 into develop Mar 11, 2025
9 checks passed
@bulldozer-bot bulldozer-bot bot deleted the cr/21-with-graal branch March 11, 2025 09:31
@autorelease3
Copy link

autorelease3 bot commented Mar 11, 2025

Released 2.57.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants