-
Notifications
You must be signed in to change notification settings - Fork 49
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
Java 21: Pattern Matching + StringTemplate JEP-430 + Unnamed JEP-445 #935
base: develop
Are you sure you want to change the base?
Conversation
Thanks for your interest in palantir/palantir-java-format, @npeters! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request. |
Generate changelog in
|
The build is so painful... I push all the jar / idea-plugin https://github.com/npeters/palantir-java-format/releases/tag/java21-draft. |
great job, now gotta wait for approval |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to use palantir-java-format and saw this PR. I read through and commented on code changes appearing unusual to me. Feel free to use or to ignore - I am not affiliated with the project, just some Java project lead.
build.gradle
Outdated
sourceCompatibility = 11 | ||
targetCompatibility = 11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep as is - and remove the "duplicate" settings in the sub projects.
java{ | ||
sourceCompatibility = 11 | ||
targetCompatibility = 11 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed (because configured globally)
idea-plugin/build.gradle
Outdated
java{ | ||
sourceCompatibility = 11 | ||
targetCompatibility = 11 | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed (because configured globally)
java{ | ||
sourceCompatibility = 11 | ||
targetCompatibility = 11 | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed (because configured globally)
java{ | ||
sourceCompatibility = 11 | ||
targetCompatibility = 11 | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed (because configured globally)
if (stringFragmentKind) { | ||
stringFragmentEndPos = t.endPos(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove empty line
@@ -394,6 +394,7 @@ protected void handleModule(boolean first, CompilationUnitTree node) {} | |||
|
|||
/** Skips over extra semi-colons at the top-level, or in a class member declaration lists. */ | |||
protected void dropEmptyDeclarations() { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove empty line
import a.A;; | ||
import a.A; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was the test input changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
";;" is not valid on java 21.
"Disallow Extra Semicolons Between "import" Statements"
https://www.oracle.com/java/technologies/javase/21-relnote-issues.html#JDK-8027682
I was not able to disable the test only for Java21
package foo;; | ||
package foo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was the test input changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
";;" is not valid on java 21.
"Disallow Extra Semicolons Between "import" Statements"
https://www.oracle.com/java/technologies/javase/21-relnote-issues.html#JDK-8027682
I was not able to disable the test only for Java21
Void r = scan(node.getDeconstructor(), unused); | ||
token("("); | ||
|
||
// r = scanAndReduceVoid(, unused, r); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this comment mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remove it
Has there been any progress on this PR? Would love to see a new release supporting Java 21. |
Thanks for submitting this PR - although we're unlikely to be able review it/actually support Java 21 in palantir-java-format by the end of the year. There's a significant amount of other work we need to do on our internal repos (currently ongoing) before we can start using Java 21 source features and these take priority. Unfortunately, we are quite resource constrained at the moment. Until then, you may be able to use something like jitpack (https://jitpack.io/) if it is allowed by your organisation to use this commit hash until we are in a place to review/merging/supporting it. |
Is there also a chance for the gradle plugin? I also hit some issues and would like to test if the modification works with https://github.com/JabRef/jabref/blob/39569344d4051ac958e4fc5edda89866d0706498/src/main/java/org/jabref/gui/fieldeditors/identifier/IdentifierEditor.java#L63. (which is issue #952) |
|
||
|
||
switch (something){ | ||
case Integer i when i > 10-> System.out.println(i.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the #952 should be fix and the test is here
yes, the PR should manage the #952. It is part of 'JEP-441 Pattern Matching switch (with guard)' . |
@CRogers Is there any news regarding when the team will have the capacity to review this PR? |
End of WHICH year? 😄 |
In relation to this - StringTemplates as we currently no them are 100% dead and will not be in JDK 23, even under --enable-preview: https://mail.openjdk.org/pipermail/amber-spec-experts/2024-April/004106.html |
Maybe a smaller scope would be easier to review? What about limiting the support to the new pattern matching features like |
As far as I understand the whole setting, the whole endeavor is blocked by the release of version 2.0 of the IntelliJ Gradle Plugin, because of the fix JetBrains/intellij-platform-gradle-plugin#1494 is needed. (Source: #997) |
@koppor How can I assist you?
@koppor If you agree with this plan. I can try to do it. |
@talios thank you for the point. We need to create a |
396d2aa
to
182fd9a
Compare
How it's looking? |
Yo, any updates in regard to the following changes. |
Since String templates was removed from JDK 23 (see: Update on String Templates (JEP 459) it should probably be removed from this PR? |
182fd9a
to
56b6eab
Compare
Currently I am using this PR on my project and it works fine: so the java code work correctly. Gradle has been updated and it is possible to support Java 21. I completely rewrite the system:
|
Before this PR
May error on parsing Java 21 file.
After this PR
Support of different JEP of Java 21 and preview
Possible downsides?
Build
Code
JavaInput.java
andvisitStringTemplate
. The complexity of this part is really to high.