mthmulders / mcs

Search the Maven Central Repository from your command line!
https://maarten.mulders.it/projects/mcs/
MIT License
173 stars 23 forks source link

Upgrade to Java 21 #395

Open mthmulders opened 1 month ago

mthmulders commented 1 month ago

There are a few spots in the code where using Java 21 (more specifically, switch with instanceof patterns) would be beneficial.

shaikhu commented 2 weeks ago

Hi @mthmulders , just an FYI, since you mentioned pattern matching for switch, the Palantir Java Format (declared in mcs pom here) currently doesn't support it. See this Github issue. I did some testing on my forked repo, and the problem seems to be when using a guard condition.

Also I tested on my fork, configuring spotless to use Google Java Format successfully works with jdk 21 and pattern matching for switch (with the guard condition). Seems a bit drastic to switch though (introduces a lot of formatting changes). Alternatively maybe upgrade to jdk 21 and not use pattern matching for switch, until palantir format supports it?

mthmulders commented 2 weeks ago

Thanks for the initial investigation, @shaikhu! Upgrading to Java 21 is not (yet) necessary. It's something I'd like to do "at some point". I can patiently wait until the Palantir Java formatter starts understanding pattern matching w/ switch. At this point, using a different formatting style (that is probably less lambda-friendly and also has narrower lines feels) a bit drastic.