Closed vitalca closed 1 year ago
I'm not a bit Java expert and I'll try to document myself a bit more. In the meantime on the link you have referenced there is no trace of 1.8 version. Something worth mentioning is that recent versions of Google Java Formatter might not work without the add exports, which implies that you wouldn't be able to run them on your java version.
Hi Samuele,
In the meantime on the link you have referenced there is no trace of 1.8 version.
Java 1.8
== Java 8
, so it is mentioned over there.
Please look at the code in the pretty_format_java.py.
According to the google-java-format/README, the --add-exports
JVM flags are required when running on JDK 16 and newer.
What needs to be done is the following.
1) check java version (there is a function for this)
2) for any versions >= 16
, you add the --add-exports
arguments.
3) for all versions below 16
you do not add them.
That's it. Thanks 🙂
Google Formatter does not start on JDK 8. Sorry for bothering.
Thanks for the the report and carrying the check already.
The
--add-exports
command line option was added in Java 9. When running on Java 1.8, you don't need to add these exports. Java fails to start.Unfortunately, a lot of enterprise legacy code still uses JDK 1.8, This version is going to be supported till the end of 2030.
As a workaround I've added an alias to my
~/.bashrc
, and I rungitc
instead ofgit commit
: