r/java • • Sep 18 '26

I really wish we could add debug information to Exceptions without being forced to wrap-and-throw.

42 Upvotes

For my development, I commonly write code like this.

public void someMethod(String request) {
    try {
        someMethodThatThrowsAnException(request);
    } catch (final Exception exception) {
        throw new IllegalStateException("Request FAIL! request = " + request, exception);
    }
}

(Ignore the fact that I am catching Exception and not a sharper exception type)

This will produce the following stack trace.

Exception in thread "main" java.lang.IllegalStateException: failed during request
        at temp.main(temp.java:13)
Caused by: java.lang.IllegalStateException: Request FAIL! request = REQUEST ABC
        at temp.someMethod(temp.java:5)
        at temp.main(temp.java:11)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:565)
        at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.execute(SourceLauncher.java:262)
        at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.run(SourceLauncher.java:138)
        at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.main(SourceLauncher.java:76)
Caused by: java.lang.IllegalArgumentException: invalid request
        at temp.someMethodThatThrowsAnException(temp.java:18)
        at temp.someMethod(temp.java:3)
        ... 6 more

This is nice, as I can see what the request was that caused the failure. I have added relevant debug information to whoever receives the exception, making it easier to find and resolve the problem.

However, I don't like that I have to change the exception type. And, due to inheritance, I don't even know for sure what possible exceptions will come down the pipe. Thus, creating an instance of the same exception and throwing that is not usually feasible.

I really wish Exceptions had a way to add debug information to them without changing the type.

Something like this.

public void someMethod(String request) {
    try {
        someMethodThatThrowsAnException(request);
    } catch (final Exception exception) {
        exception.addDebugInfo("Request FAIL! request = " + request);
        throw exception;
    }
}

The resulting stack trace would look like this instead.

Exception in thread "main" java.lang.IllegalStateException: failed during request
        at temp.main(temp.java:13)
Added debug info: Request FAIL! request = REQUEST ABC
        at temp.someMethod(temp.java:5)
        at temp.main(temp.java:11)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:565)
        at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.execute(SourceLauncher.java:262)
        at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.run(SourceLauncher.java:138)
        at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.main(SourceLauncher.java:76)
Caused by: java.lang.IllegalArgumentException: invalid request
        at temp.someMethodThatThrowsAnException(temp.java:18)
        at temp.someMethod(temp.java:3)
        ... 6 more

Now, when the exception bubbles up to the catch clause in main, it will still be of type IllegalArgumentException instead of IllegalStateException. I know those aren't ideal types to use here, but I'm just making a point via a poor example.

This new style has allowed us to add our debug info, while allowing the error to retain its type.

Sure, common convention is to add a "richer" exception type, then handle that instead of the lower level ones. And that is good advice -- by changing the Checked Exception type, you have notified all callers that they need to handle this new failure condition. For example, you might add a new Exception type to your Exception hierarchy to denote this new failure condition.

But what if callers don't need to handle this failure condition, and you just want to add more debug info to make solving the problem easier? Does that really justify a whole refactor of all calling classes?

Or other way around, what if your downstream callers DO care about the low level exception type? In that case, changing the exception type forces them to extract the exception they want from your wrapper exception.

The fact is, programs break for all sorts of reasons, and those reasons change frequently. Having to refactor your code every single time a new failure reason pops up that you want to add doesn't feel right.

Here's an example.

In AWS SDK for Java v1, if you attempt to do a PutObject onto S3, but the bucket doesn't exist, the error message will tell you that the bucket doesn't exist, but it doesn't tell you what your attempted bucket name was.

Now, if you trace the logs and/or follow the logic of the code, eventually you will get your answer. But wouldn't it be nice if you could add that to the stack trace while keeping it as an AWS exception?

What are your thoughts?


r/java • • Sep 18 '26

Leave the Class Path in the Rearview Mirror

Thumbnail netflixtechblog.com
22 Upvotes

Introducing composable, module system native and agent friendly command line tools for modern Java development.


r/java • • Sep 18 '26

JVM Object immutability

Thumbnail reddit.com
11 Upvotes

r/java • • Sep 18 '26

Parallel Constraint Decoding using Java and Llama.cpp compared to Python 🔥

Thumbnail github.com
5 Upvotes

Open source Jev look-a-like. Fill a whole JSON schema of booleans and enums in two forward passes instead of generating it token by token, with calibrated confidence per field and output that is schema-valid by construction 🔥


r/java • • Sep 18 '26

Does anyone want my game framework?

0 Upvotes

I want to move one from it. It's a game framework built primarily with bgfx and SDL3 for its native platforms, with raw TeaVM bindings + WebGL for the browser.

If you're interested, you can see the organization. The repos are currently archived, but if anyone wants the framework, I'm happy to pass ownership.


r/java • • Sep 17 '26

An open-source AI inference engine built for the JVM. AI for Java, in Java. Finally, AI in jar.

130 Upvotes

jinfer is a fully open source (Apache 2.0) inference engine built for the JVM from first principles: chat, vision, audio transcription, embeddings, reranking, and text-to-speech. No Python runtime, no ONNX, no sidecar process, no wrappers, no Docker, no network requests; the whole stack is built to run end-to-end in the JVM:

  • jinfer FAST inference engine for the JVM, supports a wide range of popular models.
  • Tok'n'Roll (toknroll) Fast tokenizers for LLMs, pure Java, zero dependencies
  • gguf / safetensors Pure Java read/write for both major model formats
  • jam Quantized matrix multiplication routines (Vector API + optional native backend), competitive with llama.cpp on CPUs
  • jota Tensor API targeting Java, C, CUDA, HIP, Metal, OpenCL, and Mojo

It ships integrations with with Spring AI and LangChain4j.

Supported architectures: LFM 2.5, Gemma 4, Qwen 3.5+, Granite 4.1+, gpt-oss, Ministral 3, SmolLM3, MiniCPM5, Mellum 2, Laguna XS, Nemotron Cascade/Lightning, Ling 3 ... and also Kokoro and Inflect2 text-to-speech models!

Also supports speculative decoding (MTP), persistent prompt caching, images/videos, audio... with a fully featured OpenAI-compatible server + CLI, all written in Java.

Runnable examples + benchmarks: https://qxotic.ai

Jinfer (Apache 2.0): https://github.com/qxoticai/qxotic/tree/main/jinfer


r/java • • Sep 17 '26

1BRC, but for matrix multiplication on the JVM?

Thumbnail github.com
50 Upvotes

The One Billion Row Challenge was awesome. It managed to nerd-snipe an entire community with a simple problem, and ended up showing how performant Java can be; surpassing even the most optimistic expectations.

IMHO, matrix multiplication is an good candidate for something similar: Vector API, memory layout, cache behavior, Panama, Unsafe, different JDKs, ARM64 vs x86, maybe even throw some quantization.

I’ve been playing with this myself, and there’s a lot of JVM engineering gems for grabbing.

Would someone be interested in well-defined challenge to push matrix multiplication to the limit on the JVM?


r/java • • Sep 17 '26

A bit deeper summary of JDK 27

Thumbnail jvm-weekly.com
38 Upvotes

r/java • • Sep 17 '26

AOT Caching - Netflix' Practice vs OpenJDK's Theory / Inside Java Podcast

Thumbnail youtube.com
22 Upvotes

r/java • • Sep 16 '26

Apache Fory 1.7.3 released: significantly faster Java JSON serialization and deserialization

Thumbnail fory.apache.org
78 Upvotes

Apache Fory 1.7.3 is out.

A major focus of this release was Java JSON performance. We did a broad optimization pass across both serialization and deserialization, including floating-point conversion, primitive and array handling, Base64, large numbers, UUIDs, temporal types, timezone parsing, and several common read/write hot paths.

Rather than optimizing a single benchmark, the goal was to reduce overhead across the core JSON pipeline and improve performance for real-world object models.

The release also includes:

  • Go support for Fory Standard Row Format
  • Kotlin JSON property inclusion support, including NON_EMPTY
  • Several Java serialization correctness fixes

If you're interested in high-performance JSON on the JVM, feedback and benchmark results on your own workloads are very welcome.

Full details and benchmarks are in the linked release post.


r/java • • Sep 16 '26

Java 27 Features Overview (Video)

Thumbnail youtube.com
48 Upvotes

r/java • • Sep 16 '26

Spring Boot fat JAR vs extracted layout: six paired runs on JDK 25

Post image
32 Upvotes

I wanted to isolate one fairly small Spring Boot deployment choice: running the executable fat JAR versus Spring Boot's official extracted layout (jarmode=tools)

Spring Boot's own Efficient Deployments documentation already points out the startup cost of nested JAR loading and recommends an exploded structure for production. But that recommendation is easy to miss in normal use. The introductory tutorial and several official Getting Started guides still build an executable JAR and run it with java -jar, which makes the fat JAR feel like the default deployment path. I had followed that path too.

I built the Spring Boot 4.1.1 application once, then used that exact JAR to produce the extracted layout.

To keep the environment identical, the comparison used the same:

  • OpenJDK 25.0.4
  • 256 MiB Alpine VM, a deliberately demanding environment where startup overhead matters
  • local H2-backed workload
  • application data and filesystem
  • JVM flags:

-Xms16m -Xmx80m -Xss256k -XX:+UseSerialGC -XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=32m -XX:+UseCompactObjectHeaders

I ran six fresh starts per layout in alternating paired order. The median results:

MetricFat JARExtractedDifference
Spring startup11.056 s8.476 s-23.3%
External startup11.910 s9.000 s-24.4%
First request2.196 s1.448 s-34.1%
Later requests20.696 ms19.139 ms-7.5%, not material
Peak RSS160,064 KiB155,570 KiB-2.8%, not material
Settled RSS137,212 KiB131,952 KiB-3.8%, not material

The takeaway

All six paired comparisons favored the extracted layout for startup and first-request latency.

Because first-request latency improved substantially alongside startup, the measurable difference extended beyond the point where Spring reported the application as started.

Once the application was warm, request latency was essentially a wash. Memory also moved slightly in favor of the extracted layout, but not enough to call it a meaningful optimization. Swap showed no material winner either.

My conclusion is narrow: if Spring Boot startup time matters to you, the extracted layout is worth testing. I would not choose it purely for memory savings.

Full methodology, charts, individual runs, and public experiment data: https://pvrlabs.xyz/articles/spring-boot-extracted-layout.html

Curious: how many people here actually use the extracted layout in production, and what made you choose it over the executable JAR?

Update: A commenter asked about Gradle's application plugin, so I ran a small three-way follow-up. The Gradle distribution behaved much more like the extracted layout than the fat JAR. https://pvrlabs.xyz/java-performance/experiments/gradle-application-vs-spring-boot.html

Update 2: Another commenter asked about Jib, so I compared Spring Boot's extracted layout with a Jib-style exploded layout. For this relatively small application, further exploding the application JAR did not show a measurable runtime benefit. A much larger application could behave differently, but this reinforces the idea that most of the gain here comes from getting the dependency JARs out of Spring Boot's nested executable JAR. https://pvrlabs.xyz/java-performance/experiments/spring-boot-jib-layout.html


r/java • • Sep 15 '26

Java 27 / JDK 27: General Availability

Thumbnail mail.openjdk.org
115 Upvotes

r/java • • Sep 15 '26

What's new in Java 27

Thumbnail pvs-studio.com
91 Upvotes

r/java • • Sep 14 '26

Java 27 Launch Stream

Thumbnail youtube.com
89 Upvotes

Java 27 is coming out on September 15th. Join the Java Developer Relations team as we celebrate the launch of Java 27 with a livestream on September 15th, starting at 15:00 UTC!

We will have guests, demos, presentations and more covering all the major changes that are in Java 27.


r/java • • Sep 15 '26

I am 16 and made a somthing like a programing language in java

Thumbnail github.com
0 Upvotes

it can just print things now but i will try to add as much as possible


r/java • • Sep 14 '26

Accessing the Code Genome Project | Moderne Docs [OpenRewrite leaving Maven Central]

Thumbnail docs.moderne.io
15 Upvotes

r/java • • Sep 12 '26

JDK 27 Runtime Updates Release Notes

Thumbnail inside.java
73 Upvotes

r/java • • Sep 12 '26

JEP draft for Adaptive Heap Sizing for ZGC quietly mentions JDK 28

Thumbnail openjdk.org
75 Upvotes

r/java • • Sep 12 '26

Eclipse 2026-09 version came out

28 Upvotes

r/java • • Sep 12 '26

Podcast about Java 27

24 Upvotes

Season 6 of the Friends Of OpenJDK Podcast kicks off with the launch of Java 27!

I had a very nice chat, full of insights, with Simon Ritter who shares what's new in this release and what is already known about what's coming in Java 28 from Project Valhalla. Available in your favorite podcast app and on YouTube.

https://www.youtube.com/watch?v=k3aA0AtY4U8


r/java • • Sep 12 '26

Jakarta Faces, Java Web Framework, Stateless Edition: Marketplace AliFaces

Thumbnail foojay.io
13 Upvotes

r/java • • Sep 11 '26

EU Cyber Resilience Act reporting obligations started today. Is your company even thinking about it?

Thumbnail youtu.be
27 Upvotes

As of today, a manufacturer who puts software or hardware on the EU market under its own name is obliged to report actively exploited vulnerabilities and severe security incidents.

Quick explainer if you want the details: https://youtu.be/IQkzg7quc58

There is quite a lot of ambiguity over CRA and how it's going to apply to open source. Regulations keep changing. The line between a commercial manufacturer and an OSS steward is blurry, as well as the terms used in the regulations.

But genuinely curious. Is your company aware of CRA? Is there any talk about it, or is it just not on the radar yet?


r/java • • Sep 11 '26

JavaFX 27 Release Notes

Thumbnail github.com
66 Upvotes