Skip to content

Support JEP 330 "shebang" headers #1214

Description

@vorburger

I'm toying (more "for fun") with https://openjdk.org/jeps/330 in enola-dev/enola#971:

I am using https://www.jbang.dev, but this issue doesn't really have anything to do with that (JBang) per se:

For the following content of learnenola.java which (at least as I understand it) is technically "valid standard Java syntax" per JEP 330:

#!/usr/bin/env jbang

import static java.lang.System.out;

public class learnenola {

    public static void main(String... args) {
        out.println("Hello World");
    }
}

google-java-format currently fails like this:

$ ./google-java-format_linux-x86-64 --aosp --lines 1:11 learnenola.java

<stdin>:1:1: error: illegal character: '#'
#!/usr/bin/env jbang
^
<stdin>:1:3: error: class, interface, enum, or record expected
#!/usr/bin/env jbang
  ^
 Command failed: ./google-java-format_linux-x86-64 --aosp --lines 1:13 -
<stdin>:1:1: error: illegal character: '#'
#!/usr/bin/env jbang
^
<stdin>:1:3: error: class, interface, enum, or record expected
#!/usr/bin/env jbang
  ^

See also https://www.jbang.dev/documentation/guide/latest/faq.html for some further background if needed.

PS: I've opened another issue #1215 for something that's a separate problem related to "special" (non-shebang) /// comments.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions