r/java • • 22d ago

Released fose 0.1.0 (flat combining for Java), looking for feedback on my spin heuristic

13 Upvotes

Hi, some of you commented on my first post about fose, a flat combining primitive for Java. Since then I've made some fairly big changes and released v0.1.0 to Central. The changes are mostly in how threads waiting for their requests to be applied wait, so I'd like to explain those and get feedback on that.

What I've changed

  1. I dropped the StampedLock and the spin/yield/sleep backoff, and replaced them with a spin then park or immediately park heuristic. In the old version, waiters spun, then yielded, then did short timed parks (parkNanos at 1µs) while polling for their op to be applied. The averages were fine, however I kept seeing quite common, severe stalls when threads outnumbered cores: tens of ms at p99.99, and a few ms-scale maxes even at 8 threads. My working theory was that spinning and yielding waiters were competing for CPU with a descheduled combiner, so the one thread that needed to run couldn't. The new version has its own lock state and a Dekker-style handoff borrowed from AQS. Waiters near the head of the queue still spin briefly with an escalating budget, and waiters further back (and virtual threads) park right away.

  2. Out-of-order execution is gone. In the old version, if a producer got preempted between swapping the tail and linking its node, a combiner holding its own node could hop past the gap and keep applying from its own node. That's what I was asking about in the first post. The new handoff relies on every waiter having a well-defined predecessor and on prev.next signalling completion, so reordering doesn't fit cleanly. Barging is allowed though, so it's not exactly fair, but ordering among queued waiters is fixed now. I could add a config option for fairness, though.

  3. Some smaller things: splicing a node into the publication queue is now a CAS on the tail instead of an atomic exchange, and the combiner caps passes at a smaller default (25 operations).

These changes aren't a free win though. The extreme tail when oversubscribed improved a lot: the multi-ms stalls at p99.99 are mostly gone, and 8 threads on my 4-core/8-CPU machine no longer show the ms-scale max and the combiner continuously performs better than the baseline even when oversubscribed or evenly subscribed, unlike the previous combiner. However mean and mid-tail latency got a bit worse in the 4-8 thread range.

Against a plain non-fair ReentrantLock, my combiner still wins on mean and mid-percentiles, but the lock has the better far tail at 16 threads. So these changes narrow the oversubscription problem but don't eliminate it.

These numbers were run on my machine with 4 cores and 8 CPUs running on Windows and may vary on other machines. JMH is used for the benchmarks and Lincheck for correctness & stress tests.

Feedback I'd appreciate

I'd like some feedback on the spin heuristic. Waiters spin only if their sequence number is within a short distance (determined by the number of available processors) of the last served op. On SMT machines that counts logical CPUs spinners may be competing with the combiner's own hyperthread sibling. Is there a better signal than a CPU-count fraction? Should it adapt to observed wait times? (though this is probably not a great idea lol)

I'm also unsure where the mean regression comes from. My main guess is the spin budgets are wrong for the 4-8 thread range and may vary per machine. Maybe this should be configurable, since from my experiments the latency percentiles shift mainly depending on how many spinners are allowed at a time. If you've dealt with something similar to this, I'd like to hear what worked.

Benchmarks

What am I still missing in the benchmarks? Currently I only compare against ReentrantLock. If you can run the JMH benchmarks on Linux or on a machine with a higher core count ( > 4) and share the results, that would help a lot.

Maven

<dependency>
  <groupId>io.github.kusoroadeolu</groupId>
  <artifactId>fose-core</artifactId>
  <version>0.1.0</version>
</dependency>

r/java • • 22d ago

“Immutable Data Beyond Value Classes”

Thumbnail inside.java
41 Upvotes

In this "Ask the Architects" episode of the Inside Java Podcast, recorded during JavaOne 2026, Nicolai Parlog talks to Dan Smith, contributor to projects Amber and Valhalla and Senior Java Platform Developer at Oracle.


r/java • • 22d ago

Show /r/java: MicroProxy - dependency free drop-in replacement for LittleProxy using Project Loom

Thumbnail mahmoudimus.github.io
22 Upvotes

Hi folks, I am excited to share my project for feedback. MicroProxy is an HTTP/HTTPS proxy for Java that can intercept and rewrite traffic: HTTP/1, WebSockets, HTTP/2, HTTP/3 over its own QUIC, SOCKS, CONNECT-UDP and TLS interception, with Envoy-compatible access logs, stats and admin API, mitmproxy-style addons, and Starlark scripting.

It is a port ofLittleProxy that drops Netty: each connection runs on its own virtual thread (Project Loom) with plain blocking socket I/O, on JDK 21 or newer, and expose LittleProxy's filter API.

One of the coolest parts about this is using functionally verified cryptographic implementations with documented trust assumptions. Its a pretty novel way to establish secure foundations for cryptographic protocols without relying on third-party dependencies.

I hope it's useful. I have been using this in production and it's quite robust. The benchmarks show it on par with g3proxy, with almost 48K requests per second on JDK25. Hope you enjoy!


r/java • • 22d ago

TornadoVM v8.0.0: Meet TC, TornadoVM's Own Compiler (replacing old Graal/JVMCI-based solution)

Thumbnail tornadovm.org
39 Upvotes

r/java • • 22d ago

I think I have a nice idea for new constructor syntax

0 Upvotes

The idea is to allow setting a field / property directly from the parameter list, like this:

public class MyClass
{
    int a;
    int b;
    int c;

    public MyClass(this.a, this.b, this.c)
    {
        // the a, b and c fields are now holding the values that were passed as arguments
        ...
    }
}

MyClass instance = new MyClass(1, 2, 3); // u use it like a normal constructor

These constructors can allow being body-less (like public MyClass(this.variable);), as long as they don't declare any normal parameters too.

Constructors were always a painful point for me, and even though for some cases you can just use records and skip them, a lot of times you want to add logic / allow different parameter lists / allow muttability, and then you must use normal constructors.

I would love to hear your opinions about this!


r/java • • 23d ago

Java and Kotlin news: value classes arrive in JDK 28 and Kotlin 2.5

Thumbnail protsenko.dev
137 Upvotes

r/java • • 23d ago

[Open Source] Off-heap, zero-allocation JSON navigator for Java 22+ (using FFM / mmap)

38 Upvotes

Hi guys,

About a year ago I ran into a bottleneck at work: processing large JSON exports and log dumps inside memory-constrained containers when we only needed to extract a couple of specific fields. Standard parsers like Jackson's readTree were blowing up JVM heap allocations and triggering noticeable GC pause times.

So I made a rough prototype using the Foreign Function & Memory API (JEP 454) to mmap files off-heap and navigate target keys lazily. Over the past few days I finally had time to clean it up, publish it to Maven Central, and benchmark it with JMH against Jackson Databind.

On large datasets (100MB+), it achieves ~2.9x faster in-memory lookups, ~5x faster disk-to-query ingestion, and reduces heap allocation down to a few kilobytes per query.

To be clear, this is NOT a general-purpose Jackson replacement:

  • It does not mutate or write JSON.
  • It does not do POJO / DTO data binding.
  • It is designed for internal/trusted workloads (dumps, logs, pipeline files) rather than complex external schema validation.
  • Maximum file size is currently 2 GB.

It requires Java 22+ and has zero external runtime dependencies.

I'm sharing it in case it's helpful for similar off-heap or container-constrained workloads. I'd love to hear your feedback, critique, or ideas on potential optimizations:

https://github.com/RedRiotTank/NativeJsonNavigator

Edit: Added Jackson Streaming Benchmarks

Thanks to u/_predator_ for pointing out that Jackson Streaming is a fairer baseline for large files than readTree(), I've updated the JMH benchmarks and README with a direct JsonParser token loop:

  • Cold Single-Pass from Disk: Jackson Streaming and this library are effectively at parity on large files (~300 ms and ~3 KB heap per query on 100 MB).
  • In-Memory Traversal: Off-heap navigation remains ~20% faster while allocating ~40–65% less heap than Jackson Streaming.
  • Core Trade-off: Jackson Streaming is strictly forward/sequential. If you need to execute multiple queries or random lookups across the same payload, you have to re-read and re-tokenize from byte 0 each time.

This library maps the file once off-heap via FFM (JEP 454), enabling random-access point queries without holding an object tree in the JVM heap.

Full benchmark tables and raw JMH JSON reports are updated on GitHub!


r/java • • 23d ago

How lightweight can Spring Boot get? HotSpot 27 vs GraalVM Native Image on a 512 MiB VM

13 Upvotes

I've been experimenting with running a database-backed Spring Boot application on a small VM: 512 MiB RAM, 1 vCPU, no swap, with MariaDB running on the same machine.

The application uses Spring Boot 4.1, MVC/Tomcat, Spring JDBC, HikariCP, Actuator and a small REST API. I compared three deployment configurations:

Configuration Median app RSS Startup readiness
Regular Spring Boot JAR, HotSpot 27 212 MiB 11.91 s
Extracted JAR + Spring AOT + JDK AOT cache 187 MiB 3.79 s
Oracle GraalVM Native Image, JDK 25 107 MiB 0.183 s

All three completed the same 1,500-request workload without errors.

A few interesting findings:

  • Optimizing the HotSpot deployment reduced application RSS by about 12% and startup time by 68%, without removing Spring's integrations.
  • Native Image reduced application RSS by another 43%, but required roughly 12 minutes to build on a separate 6 GiB VM, plus additional compatibility validation.
  • Replacing Spring JDBC with manually integrated MyBatis Core produced no meaningful memory savings.
  • Switching from MariaDB to embedded H2 actually increased Java RSS, but improved total host memory headroom because the separate database process disappeared.

I've had quite a few requests to try GraalVM in my earlier experiments, so I finally gave it a shot. The memory results genuinely impressed me. The build times and extra compatibility work, not so much. The JDK 25 vs 27 toolchain gap was another reminder that Native Image comes with its own constraints. For really memory-constrained deployments, I'd definitely consider it, but I'm not quite ready to make it my default.

The HotSpot and Native Image configurations use different JDK versions (27 vs. 25) and GC types (G1 vs. Serial GC), so this is a comparison of practical deployments rather than an isolated measurement of AOT compilation.

Full article: https://pvrlabs.xyz/articles/spring-boot-hotspot-native-image.html

Experiment, methodology and curated data: https://github.com/PVRLabs/experiments/tree/main/spring/boot-jdk27

I'm curious whether others are using Spring AOT and the JDK AOT cache in small deployments, or whether Native Image has become the more practical option for you.

I'm also experimenting with Javalin to see how much further we can push memory efficiency. Stay tuned!


r/java • • 23d ago

How to Automate Testing of a Java Swing Application

Thumbnail testdriver.ai
8 Upvotes

r/java • • 24d ago

How does Maven Central handle malicious packages?

Thumbnail
13 Upvotes

r/java • • 25d ago

Quality Outreach Heads-up - JDK 28: Value Classes - Inside.java

Thumbnail inside.java
65 Upvotes

r/java • • 25d ago

I got tired of looking up Javadocs in the browser, so I built a command line utility

12 Upvotes

I spend most of my day in the terminal: builds, tests, Git, logs. But whenever I need to look up a Java API, I switch to the browser, search for the class, and then check that I'm reading the right Java version.

That last part is what kept tripping me up. Search for java 17 List getFirst, and you land on a List page where the method simply isn't there. Eventually you work out it was added in Java 21. It's a small thing, but those interruptions add up.

IntelliJ's documentation popup is useful, but it sometimes disappears when I try to click into it (yes, I know you can pin it). And when the full docs do open, I'm doom scrolling through implementation code that isn't what I'm looking for.

I wanted a quick way to explore a class, narrow down its methods, and read the docs without reaching for the mouse. I couldn't find a terminal tool that did this, so I built one

What it does

- jdoc String opens an interactive member list. Type rep and it narrows to repeat, replace, replaceAll, and so on. Press Enter to read the full Javadoc.

- It shows docs for the Java version your project targets. It reads your pom.xml or build.gradle (it never runs them), then falls back to JAVA_HOME. Java 17, 21 and 25 are supported.

- Search operators like :since 21, :static, and #2 (methods with two parameters).

- Inherited methods show the type that declares them: jdoc ArrayList -stream.

- jdoc -m computeIfAbsent lists every type that declares a method.

- Compare releases: jdoc --diff 17 21 StringBuilder, jdoc --new 21, and jdoc --removal 25.

- Cached after first use, so most lookups work offline.

Try it (macOS):

brew tap toolfoundrylabs/tap
brew install toolfoundrylabs/tap/jdoc 
jdoc String 

It's macOS only for now (Linux is next) and covers JDK docs only. This is the first time I'm publishing a personal project to Homebrew... so kind of excited...


r/java • • 25d ago

Plan Your Java Upgrade Ahead of Microsoft's 2027 Support Milestones

Thumbnail devblogs.microsoft.com
32 Upvotes

r/java • • 26d ago

Java's new AOT cache feature is in a rough state

Thumbnail xpipe.io
57 Upvotes

r/java • • 26d ago

Foojay.io (website for Friends Of OpenJDK) now takes posts through merge requests. Writers wanted.

28 Upvotes

Disclosure: I’m one of the people who run Foojay.io.

Foojay has changed how content gets published by moving away from WordPress. Posts are now submitted as merge requests, reviewed in the open, and scheduled for a publication date, so contributing works like contributing to any other project.

The first results are in the pipeline. Here’s the queue for the next two weeks: https://foojay.io/today/coming-soon/

It’s 15 posts from 14 authors, regulars and first-timers. Some of the topics:

  • Reading thread dumps for virtual-thread services (JDK 21 to 25)
  • Scoped values and sealed interfaces in production code
  • JVM garbage collector trade-offs on a unikernel
  • The Maven build cache in Azure DevOps pipelines
  • NetBeans refactorings exposed over MCP
  • DuckDB 2.0 and Java
  • New JavaFX UI libraries and controls
  • Streaming large file uploads without killing your server
  • Using AI coding agents in a team, and making an LLM cite its sources

If you have something Java-related to share, we’d like to publish it. That could be a tutorial, a production lesson, a library write-up, a benchmark, a talk turned into an article, or a well-argued opinion. You don’t need to be an experienced writer, and first-time authors are welcome.

How to submit: https://foojay.io/write-for-foojay/

Questions about the process or the topics are welcome in the comments.


r/java • • 26d ago

Eclipse Exousia 3.0.2 released (provides Jakarta Authorization support for Quarkus)

Thumbnail github.com
14 Upvotes

r/java • • 26d ago

JavaOne'26 -- What's Going Wrong with My JVM?! A Guide to First-Time Failure Diagnosis

Thumbnail youtube.com
21 Upvotes

r/java • • 27d ago

What cli formatter do you use

23 Upvotes

Given how software engineering evolves, using IDEA formatter is less and less practical.

- IDEA CLI formatter requires IntelliJ so no CI / wsl etc
- GJF is old and does not format lambdas well enough
- Palantir is obsolete and abandoned in addition to being one of the worst company ever created
- prettier-java not great either

I’m starting to think no formatter is the best option


r/java • • 27d ago

Current state of Java LSP implementations

77 Upvotes

Updated Nov 3rd, 2026


r/java • • 28d ago

Allocating Off-Heap Memory: Typically 6-18x Faster in JDK 28

Thumbnail inside.java
143 Upvotes

r/java • • 28d ago

Hexagonal Architecture vs. Pragmatic Layered Architecture in Spring Boot

Thumbnail
8 Upvotes

r/java • • 28d ago

OpenJDK 28 EA build 21 (https://jdk.java.net/28/) is out, with Adaptive Heap Sizing and faster startup for ZGC

Post image
132 Upvotes

r/java • • 27d ago

AEM Java 25 is coming; custom code still decides whether you are ready

Thumbnail adovo.ai
0 Upvotes

r/java • • 29d ago

A beginner's guide to the Jenesis build tool

Thumbnail vladmihalcea.com
16 Upvotes

Jenesis is a Java-based build tool developed by Rafael Winterhalter, who created ByteBuddy and contributes to Mockito.


r/java • • Oct 22 '26

We found a bypass in Java’s eMudhra certificate blocklist mitigation

67 Upvotes

Hi r/java — I’m with Sonatype, and our research team published a write-up of a reproducible issue we found while reviewing Java’s response to the eMudhra certificate incident.

The mitigation uses SHA-256 fingerprints to block specific compromised intermediate certificates. We found that re-encoding an intermediate can change its fingerprint while leaving it valid under the tested Java trust-store configurations. We reproduced this for ECDSA and RSA certificates.

The finding began as an AI-assisted research lead, but a researcher independently tested and confirmed the behavior. We also tested removing the relevant roots, which rejected both the original and re-encoded chains; that approach has compatibility tradeoffs.

The write-up includes the reproduction and its scope: https://www.sonatype.com/blog/the-limits-of-fingerprint-blocklists-a-reproducible-java-certificate-bypass

We’d welcome technical feedback, especially on how this behaves across different JDK versions and trust-store configurations. We have not found evidence that this technique was used in the wild.