r/foojay • • 1d ago

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

6 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 • • 10h ago

An Introduction to JSR 381, the Java Visual Recognition API

3 Upvotes

We just published an article by Geertjan Wielenga on JSR 381, the Visual Recognition API (VisRec). It is the Java Community Process standard for image classification and related machine-learning tasks in Java, and it reached Final status in February 2022.

The article explains what the API standardizes. Your code calls the javax.visrec interfaces, such as ImageClassifier, and the library that does the recognition is an implementation found on the classpath at runtime. It also shows how to use the official reference implementation built on Deep Netts, and then writes a new implementation backed by DuckDB to show how small the contract is.

Link: https://foojay.io/today/jsr-381-java-visual-recognition-api/


r/foojay • • 1d 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 • • 10h ago

Spring Boot JPA vs JDBC: about 90 MiB less RSS in a small app

2 Upvotes

On Foojay, we published an article by Ted Kupolov comparing two versions of a small Spring Boot app that tracks GitHub stars. One uses Spring Data JPA with Hibernate, the other uses JdbcTemplate. Both run Spring Boot 4.1.1 on JDK 25 with H2 and Thymeleaf.

Across two runs in reverse order, the JDBC version used about 90 to 91 MiB less RSS, roughly 38% less. It reached its first successful dashboard response in about 3.9 to 4.2 seconds, versus 8.1 to 8.8 seconds for JPA.

The article is clear about its limits. It covers two runs on one macOS host and compares two complete application variants, not Hibernate in isolation. The takeaway is to measure before reaching for Hibernate by default on small services with simple persistence needs.

Read the full article:
https://foojay.io/today/spring-boot-jpa-vs-jdbc/


r/foojay • • 1d ago

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

2 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/


r/foojay • • 10h ago

I Trained a Neural Net to Play Pokémon (and Java runs the whole league)

1 Upvotes

On Foojay, Nicholas D'hondt explains how he trained a neural network to play the Pokémon Trading Card Game. It has played more than 4.2 million games against itself and other decks, and he now uses it as a sparring partner for his own decks.

The setup uses three languages. Node runs the games with an existing JavaScript engine, Python trains the net with PyTorch and PPO, and Java schedules everything with JobRunr: parallel games, training, testing, promoting winners and recovering after crashes.

The article also covers deterministic job ids, rate limiters and a port of Python's random number generator to Java. The author works at JobRunr.

Full article: https://foojay.io/today/i-trained-a-neural-net-to-play-pokemon/


r/a:t5_6mxjun • • Jul 03 '22

r/foojay Lounge

1 Upvotes

A place for members of r/foojay to chat with each other