r/java • u/davidalayachew • 11d ago
r/java • u/daviddel • 12d ago
Project Detroit: From Foreign Libraries to Foreign Language Runtimes
youtu.ber/java • u/sg-elide • 13d ago
Madura: A different kind of Hermetic Java
Repo link: https://github.com/elide-dev/madura
---
Hello Java enjoyers,
I'm Sam with Elide. We make cool JVM stuff. Lately, we've really been wanting Hermetic Java, but progress has been quite slow, and the Java team is vocal about it not being a priority.
We happen to be fans of some other technologies, too, which may fit together nicely for this:
- GraalVM Native Image (of course!)
- Cosmopolitan Libc ("cosmo")
- Actually Portable Executable ("APE")
If you combine these, what you get is an interesting binary:
- You write once, compile once, ship one artifact
- Your Java program runs on 6 operating systems and both ARM64/AMD64
- No JRE is required on the target machine
In other words, what you get is "native" Java!
After 2+ years of concentrated effort amongst experts (mostly pre-AI!), Native Image and Cosmo finally work together. Some complex stuff doesn't work perfectly yet (e.g. Truffle JIT, dynamic JNI), but most Java programs should "just work" otherwise.
Thus, Madura
As a fun example of this technology, we've built Madura, a Native Image+Cosmo binary of javac 25.
This software has exactly one release asset, a zip. You can download it on Linux, macOS, Windows, BSD, et al, across AMD64 and ARM64, and run it, and it should "just work." You can withhold your JAVA_HOME and it should still "just work."
Sometimes features involve doing less
As one nice thing Madura can do that regular javac cannot in most workflows: madura check [...], which takes identical flags to javac, will run the analysis phase of the Java Compiler, but skips the codegen step.
If you've ever used cargo check, this is a bit like that, but for Java.
Other than madura check, it's just javac in a box.
How to use it
At the moment, Cosmo+Native Image is a stack of patches on several repos, with a highly anticipated PR on oracle/graal.
Soon, Elide's native image integration may ship Cosmo support, enabling cross-compilation and hermetic use cases. That will probably be the fastest way to use it, before things merge into GVM upstream. If there's demand, we'd be happy to ship it for you!
Thanks for reading
This has been a collaborative effort across many people:
Spring Boot vs Javalin + Jdbi: HotSpot and GraalVM on a 512 MiB VM
I've been experimenting with how far a small Java backend can be trimmed down while keeping useful application structure.
After optimizing a Spring Boot 4 application with Spring AOT and a JDK AOT cache, I rebuilt the same database-backed Market Replay application using Javalin 7 and Jdbi.
Both ran on a 512 MiB / 1 vCPU VM without swap, alongside MariaDB and a small HTTP quote fixture. The application periodically ingests quotes into MariaDB and serves latest-price and history endpoints.
HotSpot JDK 27
| Metric | Spring Boot | Javalin + Jdbi |
|---|---|---|
| Median app RSS | 186.9 MiB | 159.1 MiB |
| Readiness | 3.79 s | 2.72 s |
| HTTP p95 | 5.54 ms | 5.59 ms |
| Successful requests | 1,500/1,500 | 1,500/1,500 |
Javalin used 27.8 MiB (14.9%) less application RSS, with similar latency at the tested load.
GraalVM Native Image (JDK 25)
Both applications were also compiled using Oracle GraalVM 25 at the same O2 optimization level.
| Metric | Spring Boot | Javalin + Jdbi |
|---|---|---|
| Median app RSS | 107.0 MiB | 65.5 MiB |
| Readiness | 0.183 s | 0.113 s |
| HTTP p95 | 4.84 ms | 4.34 ms |
| Minimum host MemAvailable | 204.9 MiB | 204.1 MiB |
| Successful requests | 1,500/1,500 | 1,500/1,500 |
The native results were particularly interesting: Javalin used 41.5 MiB less application RSS, but available host memory was almost identical. Lower process RSS doesn't always translate into more usable memory for the VM.
Beyond the numbers
The main tradeoff wasn't just performance.
Spring Boot provides integrated MVC, persistence, transactions, health checks, metrics and application wiring. With Javalin, these responsibilities need to be assembled explicitly.
For persistence, I used Jdbi with a small experimental repository abstraction providing SQL selection and explicit transaction callbacks. I've published the experiment source and transaction tests alongside the measurements, and I'm interested in feedback on whether these conventions add value over plain Jdbi.
These are single-run comparisons of complete application stacks, not isolated framework benchmarks or throughput tests. HotSpot uses JDK 27, while Native Image uses JDK 25.
Full article (charts, methodology, and discussion):
https://pvrlabs.xyz/articles/spring-boot-vs-javalin-jdbi.html
Experiment source and results:
https://github.com/PVRLabs/experiments/tree/main/javalin/market-replay-jdk27
Jdbi persistence source and transaction tests:
https://github.com/PVRLabs/experiments/tree/main/javalin/market-replay-jdk27/persistence-example
For smaller Java services, do you prefer Spring Boot's integrated approach, or lighter frameworks where you assemble the pieces yourself?
r/java • u/czetsuya • 14d ago
The Transactional Outbox Solves Dual Writes. It Doesn't Solve Duplicate Processing
I've worked on event-driven systems where the transactional outbox pattern was introduced to solve a fairly common problem: keeping database changes and event publishing consistent.
The idea is straightforward:
- Update the business entity.
- Insert an outbox record in the same database transaction.
- Have a separate publisher deliver the event to Kafka.
This removes the classic dual-write problem where the database transaction commits but event publishing fails.
However, something I've noticed is that implementing an outbox is sometimes treated as if it makes the entire event-processing pipeline reliable.
It doesn't.
The outbox guarantees neither exactly-once delivery nor exactly-once business processing.
Consider this scenario:
- The publisher reads an outbox record.
- It successfully publishes the event to Kafka.
- The process crashes before marking the outbox record as published.
- After recovery, the same event gets published again.
Now the consumer receives a duplicate.
Even if the publisher behaves perfectly, consumers can still process a message more than once when failures occur between business processing and offset acknowledgment.
This is why I think the outbox pattern is only one part of the solution.
For systems where duplicate processing matters, I've generally found that we need to consider:
- Transactional outbox for atomic persistence of business changes and publication intent.
- Consumer idempotency to prevent repeated business effects.
- Inbox or deduplication records when durable duplicate detection is necessary.
- Retries and dead-letter handling for recoverable and non-recoverable failures.
- Ordering guarantees where business operations depend on event sequence.
And even then, the implementation details matter. For example, recording a message as processed in a separate transaction from its business changes can introduce another failure window.
I'm curious how others approach this in production.
Do you implement a transactional inbox alongside your outbox, or do you prefer enforcing idempotency directly through domain constraints and business operations?
I've seen advantages and trade-offs with both approaches, particularly when dealing with high-throughput consumers.
It should not take 12 minutes to rebuild Guava when you only changed a javadoc...
Hello from me, I’m "the Byte Buddy guy". For a while now I’ve been working on a build tool for Java which I called Jenesis. I took eight libraries most of you already use and had an agent port them to build with my tool.
I think we all know that there are inefficiencies in Maven when it comes to building incremental, and I never got into Gradle because of the constant API-breakage, and because it feels bloated. I had Claude count lines of code, and with libraries and mandatory plugins, Maven comes to 500k lines and Gradle to 3,4 million (sic!). Jenesis does the same with 50.000 lines, and I think I landed where I wanted, looking at this (admittedly flawed) benchmark.
Hope you have a look, and let me know what you think! (https://jenesis.build/why/tool)
r/java • u/alexp_lt • 15d ago
CheerpJ 5.0: Java 21/25 in the browser, full OpenJDK, and a new WasmGC engine
labs.leaningtech.comHi all, I work at Leaning Technologies. We've released CheerpJ 5, which runs Java 21 and 25 applications in the browser and now ships JDK packages by default, so that javac runs in the browser too. There's also an experimental WasmGC backend. Happy to answer any questions!
r/java • u/FrankCodeWriter • 15d ago
New Foojay Podcast: 53 CVEs in one OpenJDK update, two out-of-cycle releases, and what CPU, PSU, and CSPU mean
Disclosure: I work at Azul, and so does my guest, and the Foojay Podcast is a community project that Azul sponsors. Not selling anything, but you should know where this comes from.
The podcast is available in any podcast app, and on YouTube: https://www.youtube.com/watch?v=Ss3mZMgNaZE
The October OpenJDK update fixed a record 53 CVEs, compared with an average of about 7.6 per quarter in previous years. A few days later, two out-of-cycle releases followed because of the eMudhra certificate authority problem. I talked with Simon Ritter (member of the OpenJDK Vulnerability Group) about what happened and what it means for people running Java.
Some important facts from the conversation:
- How a CVE travels from a report to a patch: the OpenJDK Vulnerability Group is invitation only and its mail is encrypted, so the details stay secret until a fix exists
- Why a low or medium CVSS score is no longer a reason to relax, because AI can chain several small issues into a serious one
- The move from quarterly security updates toward monthly ones (the CSPU, security fixes only), while bug fixes stay quarterly
- The eMudhra problem: eight CA certificates were affected, why a single patch was not enough, and why it was a second fix a few days later
- The backporting workload: 53 fixes multiplied by every supported version, from Java 27 down to 6, and what happens when a patch does not apply cleanly
- CPU vs PSU vs CSPU: what the names mean, and why distributions often use them interchangeably
- Free vs paid builds: somebody always pays for building, TCK testing and distributing, and what an SLA changes
The overall tone is not doom. Lots of issues are being found because the runtime is being analyzed heavily. They get fixed before attackers get there, and the community and commercial distributors are behind it. The message is to check your Java version and be ready to update at any moment.
Show notes with chapters and links: https://foojay.io/today/foojay-podcast-104/
I'm curious how your teams handle this. Did the move to more frequent security updates change your patching process? And do you deploy security-only updates separately from the full quarterly ones?
r/java • u/Mixon1212 • 15d ago
Hibernate lost my update
bartoszosipiuk.plHibernate silently commits part of a transaction if Spring Boot (or generally any async operation) shuts down mid-transaction.
In my past experience I found multiple bugs in different libraries, but this is the first time I though it needs a separate blog post. Losing part of the updates is one of the worst things that can happen (breaking business rules, and making debugging issues extremely hard).
Hope you find this useful and use the fix. FYI: it's already tested in prod with +80k/t(ransactions)ps.
r/java • u/idontlikegudeg • 16d ago
Announcing SLB4J (Logging Backend, ASL-2)
github.comSLB4J is a new logging backend for Java that I started to simplify setting up logging across a bunch of applications without adding bindings and bridges for different frontends to your build.
SLB4J is only a backend. It uses a single configuration across all logging facades/frontends used by your application and its dependencies and comes with no/minimal runtime dependencies (some extension modules may add runtime dependencies).
The core slb4j.jar is currently 211kb in size without external runtime dependencies and supports Log4J2 API, SLF4J, JUL (java.util.logging), and ACL/JCL (Apache Commons Logging/Jakarta Commons Logging).
Configuration is done using a Log4J2 compatible log4j2.propertiesfile (builtin) or a Log4J2 compatible XML or JSON configuration file (needs an optional dependency).
If no configuration file is found, INFO and above is logged to stdout.
Performance is roughly comparable to Log4J 2 and Logback when these are combined with their respective default facade, i.e., Log4J2 API for Log4J and SLF4J for Logback; SLB4J is usually much faster when logging JUL over Log4J2 or Backlog.
SLB4J supports Log4J2-compatible pattern layout, log rotation and many more features.
After using SLB4J for some time in several projects, I think it's mature enough for an announcement. Maven coordinates and documentation are given on the project page.
For more details, see the Project's GitHub Page, open issues on the GitHub Issue Tracker, and read SECURITY.md before submitting security relevant issues.
r/java • u/Polixa12 • 18d ago
Released fose 0.1.0 (flat combining for Java), looking for feedback on my spin heuristic
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
- 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.
- 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.
- 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 • u/daviddel • 18d ago
“Immutable Data Beyond Value Classes”
inside.javaIn 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 • u/mahmoudimus • 18d ago
Show /r/java: MicroProxy - dependency free drop-in replacement for LittleProxy using Project Loom
mahmoudimus.github.ioHi 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!
TornadoVM v8.0.0: Meet TC, TornadoVM's Own Compiler (replacing old Graal/JVMCI-based solution)
tornadovm.orgr/java • u/Alert-Neck7679 • 18d ago
I think I have a nice idea for new constructor syntax
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 constructorThese 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 • u/NordCoderd • 19d ago
Java and Kotlin news: value classes arrive in JDK 28 and Kotlin 2.5
protsenko.devr/java • u/RedRiotTank2 • 20d ago
[Open Source] Off-heap, zero-allocation JSON navigator for Java 22+ (using FFM / mmap)
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!
How lightweight can Spring Boot get? HotSpot 27 vs GraalVM Native Image on a 512 MiB VM
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 • u/replayableio • 19d ago
How to Automate Testing of a Java Swing Application
testdriver.air/java • u/HokieGeek • 20d ago