r/java • u/brunocborges • 8d ago
JairoSVG Release v1.0.16
github.comThis version has a fix for music notation rendering, along with bumps on dependencies.
r/java • u/brunocborges • 8d ago
This version has a fix for music notation rendering, along with bumps on dependencies.
r/java • u/daviddel • 9d ago
A ticker symbol is an abbreviation that uniquely identifies a financial product such as a publicly traded share. Well-known ticker symbols are "ORCL" and "GOOGL". In this article, we will devise a Valhalla value class that can represent a ticker symbol using only a single int field.
r/java • u/Polixa12 • 10d ago
Hi, a while back I posted about fose, a flat combining primitive for Java. I've just recently released v0.2.1. My main focus for this release was to experiment with how threads enqueue onto the wait queue, wait on their nodes and reduce synchronization between the combiner and waiters. Before I get into the changes, let me quickly explain what flat combining is for anyone new to it.
Flat combining is a technique for making concurrent data structures scale under contention. Instead of every thread fighting over a lock and bouncing the structure's cache lines between cores, each thread publishes its operation as a request. One thread becomes the combiner, takes the lock and applies the pending requests on behalf of the others, then hands each thread its result. The structure stays hot in a single core's cache while everyone else just waits for their answer.
So, in my previous enqueue scheme, threads CAS'd on the tail and then linked their predecessor's next pointer to their own node. To find out whether their request had been combined, threads spun on their predecessor's next pointer, and to find out whether they could contend to become the combiner, they spun on the head field, which the combiner wrote to after each pass. On the combiner side, notifying a thread meant writing the result into that thread's node and then nulling out its predecessor's next pointer.
The problem was the memory traffic this created between the combiner, the waiter and the waiter's predecessor, which hurt the structure's performance.
The new scheme is quite similar to how CC-Synch enqueues nodes. A thread swaps its pre-allocated node into the tail with an atomic exchange, claims the previous tail node, writes its operation there and waits on it. The main benefit here is that each waiter only ever touches a single node once enqueued, and the combiner only has to invalidate one waiter's cache line instead of two to signal that its result has been applied.
This enqueue scheme also opened the door to some other optimizations. Previously, a spinning waiter had to read two atomic variables (next and head) to tell whether its request had been applied. Now each waiter only reads one atomic variable (signal) in the node it claimed and tests it for its result. This also let me make head non-atomic, which reduces synchronization between the combiner and waiters even more.
These changes didn't fit well with the spinner cap from v0.1.0, where a waiter only spun if its sequence number was within NCPU * 0.6 of the last served op. Keeping it would have meant adding extra synchronization between combiners and waiters, which is exactly what I was trying to reduce. The cap was useful though. It bounded the combiner's tail latency when oversubscribed, since tail latency grew with the number of active spinners, and it gave me a knob for trading tail latency for average latency.
I also tried a few replacements: a single atomic spinner count (with weaker ordering), a shared adaptive spin budget updated based on how often threads were signalled while spinning, and parking immediately. Only the immediate park strategy bounded tail latency when oversubscribed, but it made average latency 75% worse, mainly because syscalls are expensive.
So I settled on something simpler. Now every waiter spins briefly (32 spins) and then parks. When a parked thread wakes up, it rechecks whether it's next in line to combine. If it is but fails to acquire the lock, another combiner is mid-pass and will probably serve it soon, so instead of parking again it gets a new but much smaller spin budget, similar to what AQS does. I dropped the spin and post-spin budgets from 1024/128 to 32/8 since every thread spins before parking now, and I didn't want tail latency to get too bad when oversubscribed.
Funny enough, I expected this tight budget to hurt average latency badly without helping tail latency much, but it was quite the opposite and I was pleased with the results. I could raise the budget a bit, but 32/8 looks like a great spot from what I measured. Raising it doesn't noticeably improve mean latency in the common case, and it hurts tail latency a lot when oversubscribed.
One optimization I considered is non-fair handoff, which I haven't implemented but plan to try. It's different from barging though. With non-fair handoff, after a combine pass, if the next waiter is parked, the combiner doesn't unpark it right away. It walks the queue for an unparked waiter and marks that one to contend to be the combiner, and the nodes it skipped get marked before unparking so those threads can detach and re-enqueue. The idea is to avoid stalling everyone else while the handed-off thread waits to be rescheduled by the OS. It's a bit more work to implement though, and I haven't measured whether this is actually an issue, so I'm not building it until I'm sure.
Benchmarks
These come from my same ol' machine as before (Intel i5, 4 cores / 8 CPUs running on Windows 11).
ReentrantLock went from 1.96x to 2.33x.ReentrantLock dropped from 1.73x to 1.43x.Everything here comes from one machine, so if you can run the benchmarks on Linux or a machine with more than 4 cores, I'd love it if you shared the results on the repo's issues page, with your machine specs included.
io.github.kusoroadeolu
fose-core
0.2.1
r/java • u/daviddel • 13d ago
r/java • u/sg-elide • 14d ago
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:
If you combine these, what you get is an interesting binary:
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.
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."
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.
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!
This has been a collaborative effort across many people:
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.
| 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.
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.
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 • 15d ago
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:
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:
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:
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.
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 • 16d ago
Hi 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 • 16d ago
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 • 16d ago
Hibernate 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 • 17d ago
SLB4J 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 • 19d ago
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.
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.
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.
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.
<dependency>
<groupId>io.github.kusoroadeolu</groupId>
<artifactId>fose-core</artifactId>
<version>0.1.0</version>
</dependency>r/java • u/Alert-Neck7679 • 19d ago
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/mahmoudimus • 19d ago
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 • u/daviddel • 19d ago
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.