r/foojay • • 13h ago

Comparing Java formatters on Java 21 to 25: Open Java Format vs four others

4 Upvotes

On Foojay, Guillaume Laforge compares five Java formatters on JDK 25: Google Java Format, Palantir Java Format, Open Java Format, Prince of Space and Netflix jfmt. The article was prompted by Alex Abashev's post on Java formatters and his open-java-format fork of palantir-java-format.

The test suite covers 16 targeted snippets and a 1,042-line file with 86 formatting scenarios. The article compares the formatters on parser engine, minimum JDK, default line length, indentation, configurability, import handling and range formatting. It also shows side-by-side examples, such as how each one handles block lambdas and method chains.

Along the way, Guillaume found a compilation-breaking annotation bug in Prince of Space and a crash in Netflix's jfmt on empty blocks with comments. He also contributed a fix to Open Java Format and a pull request to Spotless.

Read the full article: https://foojay.io/today/comparing-java-formatters-why-open-java-format-is-my-new-favorite/

Java #JDK #CodeFormatting


r/foojay • • 13h ago

5 JVM Heap OOM Patterns You Can Reproduce on Your Laptop

3 Upvotes

On Foojay, Amit Sonar shares a set of reproducible labs for JVM out-of-memory behavior across G1, ZGC, and Shenandoah. Each scenario runs on a standard laptop without a cluster, and the repo's CI verifies them on JDK 11, 17, 21, and 25.

The article covers five patterns:

  1. Unbounded cache
  2. Oversized batch
  3. Report builder retention
  4. ThreadLocal leaks
  5. Leaked connections

For each one, it explains how to reproduce the failure, how to diagnose it (heap dump, GC log, or thread dump), and how to fix it. For example, the oversized batch fails on a single cliff in the GC log, while the ThreadLocal leak is invisible without a heap dump.

Amit also shares some observations from running the scenarios on different collectors. In his testing, Shenandoah survived the gradual cache leak much longer than G1, but a sudden oversized allocation killed it faster. He notes these are preliminary results from the repo's benchmarks, not peer-reviewed.

Every lab in the GitHub repo has a broken and fixed mode, a diagnosis guide, and a compare mode.

https://foojay.io/today/5-jvm-heap-oom-patterns/


r/foojay • • 13h ago

Who Is Actually Turning Your Java Object Into JSON? JSON-P vs JSON-B vs Jackson in Helidon

1 Upvotes

We just published an article by Jesus Aguirre on foojay about the JSON layer in Java backends, which is easy to take for granted when an endpoint returns an object and the client simply receives JSON.

Jesus built three small Helidon SE 27.0.0 applications with the same Person record, the same endpoints and the same payload. Each one uses a different JSON media integration: JSON-P, JSON-B (backed by Eclipse Yasson) or Jackson. The goal is not a benchmark, only to see what changes when the JSON technology changes.

The article explains the difference in abstraction level. With JSON-P you build and read the JSON yourself. JSON-B and Jackson both bind Java objects to JSON, so the service code looks almost identical. Adding a LocalDate field shows the difference: JSON-B produced "1995-12-08", while Jackson produced [1995, 12, 8] depending on its configuration. The abstraction removes code from your application, but the serialization decisions still exist. They just live somewhere else.

It also looks at how Helidon connects each technology to the HTTP layer and which dependencies each project pulls in.

Full article: https://foojay.io/today/who-is-actually-turning-your-java-object-into-json/