Skip to content
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

Support Java's fancy modern main style (JEP 445 & 463 & 477 & 495) #1216

Open
vorburger opened this issue Dec 29, 2024 · 1 comment
Open

Comments

@vorburger
Copy link
Member

vorburger commented Dec 29, 2024

In enola-dev/enola#974 for enola-dev/enola#971 with enola-dev/enola#970, I am using "Java's fancy modern main style", AKA the JEP 445 & 463 & 477 & 495 stuff:

So I have e.g. a hello.java which looks e.g. like this, which is actually valid (with --enable-preview) Java 21 syntax:

import static java.lang.System.out;

void main() {
    out.println("Hello World: " + dev.enola.common.Version.get());
}

google-java-format chokes on this with:

    stderr: learn/jbang/hello.java:26:6: error: did not generate token "void"
void main() {

This is on v1.25.1, which is the 2nd most recent release today; looking at the 1.25.2 Release Notes, I have no reason to believe that this (just) got fixed there; ergo reporting this here.

Stating that google-java-format does not support --enable-preview would be valid. But from what little I figured (so far) this feature, contrary to e.g. those preview String Templates which then got removed again, this syntax appears to be here to stay, so probably should be supported, sooner or later.

@vorburger vorburger changed the title Support Java's fancy modern main style (JEP 445 & 463 & 477) Support Java's fancy modern main style (JEP 445 & 463 & 477 & 495) Dec 30, 2024
@cushon
Copy link
Collaborator

cushon commented Jan 3, 2025

These are still preview features, so we may want to wait until the feature is finalized. We've added support for preview features before, and may do that again depending on the feature. But it's wasted effort if the preview feature changes or is removed, so it's probably a case-by-case thing.

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

No branches or pull requests

2 participants