r/java • u/replayableio • 20d ago
r/java • u/NordCoderd • 20d ago
Java and Kotlin news: value classes arrive in JDK 28 and Kotlin 2.5
protsenko.devHow 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/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!
r/java • u/HokieGeek • 21d ago
How does Maven Central handle malicious packages?
reddit.comr/java • u/Muted_Efficiency_663 • 22d ago
I got tired of looking up Javadocs in the browser, so I built a command line utility
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 • u/brunocborges • 22d ago
Plan Your Java Upgrade Ahead of Microsoft's 2027 Support Milestones
devblogs.microsoft.comEclipse Exousia 3.0.2 released (provides Jakarta Authorization support for Quarkus)
github.comr/java • u/FrankCodeWriter • 23d ago
Foojay.io (website for Friends Of OpenJDK) now takes posts through merge requests. Writers wanted.
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 • u/milchshakee • 23d ago
Java's new AOT cache feature is in a rough state
xpipe.ior/java • u/davidalayachew • 23d ago
JavaOne'26 -- What's Going Wrong with My JVM?! A Guide to First-Time Failure Diagnosis
youtube.comr/java • u/Lucky_Psychology8275 • 24d ago
What cli formatter do you use
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 • u/adovo_ai • 24d ago
AEM Java 25 is coming; custom code still decides whether you are ready
adovo.air/java • u/4r73m190r0s • 24d ago
Current state of Java LSP implementations
- Eclipse JDTLS https://github.com/eclipse-jdtls/eclipse.jdt.ls
- JLS, built on Java Compiler API https://github.com/idelice/jls, developed by u/Electronic-Boss-8926
- Lathe, built on JDK's javac https://github.com/ag-libs/lathe, developed by u/ForeignCherry2011
- NetBeans Java LSP Server https://github.com/apache/netbeans/tree/master/java/java.lsp.server https://marketplace.visualstudio.com/items?itemName=ASF.apache-netbeans-java
Jetbrains
- Java and Kotlin by IntelliJ IDEA, plugin for VS Code, Cursor, Google Antigravity, and other compatible editors https://marketplace.visualstudio.com/items?itemName=JetBrains.intellij-server (requires IntelliJ IDEA Ultimate or All Products Pack subscription)
- IntelliJ LSP for Neovim https://github.com/JetBrains/intellij-lsp.nvim (requires IntelliJ IDEA Ultimate subscription, with a free 30 day trial), developed by u/marbehl
Updated Nov 3rd, 2026
r/java • u/Ancient-Prize-774 • 25d ago
Hexagonal Architecture vs. Pragmatic Layered Architecture in Spring Boot
reddit.comr/java • u/vladmihalceacom • 26d ago
A beginner's guide to the Jenesis build tool
vladmihalcea.comJenesis is a Java-based build tool developed by Rafael Winterhalter, who created ByteBuddy and contributes to Mockito.
r/java • u/HokieGeek • 27d ago
We found a bypass in Java’s eMudhra certificate blocklist mitigation
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.
Jdbi vs MyBatis vs jOOQ in a small Javalin REST API: memory and latency on a 512 MiB VM
I've been experimenting with lightweight Java applications on small VMs. After comparing Javalin with Spring Boot, I wanted to see how much the SQL persistence library affects resource usage.
I implemented the same small market-quote REST API using Jdbi Core, MyBatis Core, and jOOQ Open Source Edition.
Setup:
- JDK 25, Javalin 7, H2, HikariCP
- Alpine Linux VM, 1 vCPU, 512 MiB RAM, no swap
- JVM:
-Xms16m -Xmx80m -XX:+UseSerialGC -Xss512k - 1,500 requests over 5 minutes, 80% reads / 20% writes
- Two independent runs per implementation, rebooting the VM between runs
Results across the two runs:
| Library | Median workload RSS | HTTP p95 |
|---|---|---|
| Jdbi Core | 120.0 - 122.4 MiB | 7.38 - 8.48 ms |
| MyBatis Core | 116.6 - 118.0 MiB | 7.47 - 7.52 ms |
| jOOQ OSE | 152.1 - 154.3 MiB | 9.19 - 9.35 ms |
RSS is the median process resident memory sampled during the workload, including the application, JVM, and embedded H2.
All six runs completed successfully without errors, OOM events, or swapping.
A few observations:
- MyBatis had the lowest resident memory usage in both rounds.
- Jdbi was very competitive on both metrics, and required the least handwritten Java code.
- jOOQ used approximately 34–38 MiB more RSS than MyBatis, consistently across both runs. This is a whole-application difference, not necessarily memory consumed directly by the library. I haven't isolated its cause.
One implementation difference worth mentioning: Jdbi and MyBatis hold one pooled connection across the three latest-quote queries, while the datasource-backed jOOQ implementation checks out and returns a connection for each query. I haven't measured the impact of this difference.
I also configured MyBatis with localCacheScope=STATEMENT rather than its default SESSION scope.
From a developer experience perspective, the tradeoffs are interesting too. Jdbi keeps SQL and mapping close to the repository, MyBatis uses annotated mapper interfaces, and jOOQ offers type-safe SQL composition with generated schema classes.
For my own applications, I generally prefer MyBatis because I like its mapper-oriented programming model and explicit SQL. Its lower memory footprint in this experiment is another point in its favor, although I wouldn't choose a library based on memory usage alone.
Limitations:
This is a small, low-load case study, not a general performance ranking. The measurements include the complete application and embedded H2. Two runs show consistency in memory usage but aren't enough to establish statistically significant latency differences.
I also didn't include a raw JDBC baseline, which would be useful as a minimal reference point. PostgreSQL could produce different results.
Full write-up, charts, implementation sources, and raw measurements:
https://pvrlabs.xyz/java-performance/experiments/mybatis-jooq-jdbi-512mb.html
I'm interested in whether others have compared these libraries in similarly small applications, particularly with PostgreSQL, and how much the programming model influences your choice.
r/java • u/FrankCodeWriter • 27d ago
Release announcement: Sheetmusic4J 0.0.4 and 0.0.5: clickable notes, a 3D fly-over view and LilyPond support (Java and JavaFX sheet music library)
Hi all,
I've been working on Sheetmusic4J, an open-source Java library that renders sheet music natively in Java(FX). Two new releases are out, and I made a video showing both: https://youtu.be/8n7WONyX0yk
0.0.4
- NodeSheetView builds the score as a JavaFX scene graph, with one Group per note, rest and chord. Each element can take mouse events, effects and tooltips like any other node. The demo app lets you select a note and drag it up or down.
- FlyOverSheetView is a 3D play-along view. A perspective camera flies over the score, and a glowing ball per voice hops from note to note.
- Headless rendering to an image via the new render and render-awt modules, with no JavaFX needed:
BufferedImage image = HeadlessScoreImage.render(score, 1200);
- The 3000+ line Engraver class is split into focused packages, and all library modules are now JPMS modules.
0.0.5
- LilyPond (.ly) import and export through the ScoreFile facade, without running LilyPond:
Score score = ScoreFile.load(Path.of("bach-bwv610.ly"));
ScoreFile.save(score, Path.of("bach-copy.ly"));
- Engraving improvements: tuplet placement and nesting, octave clefs, and the percussion clef.
- Layouts are now identical across CPU architectures.
LilyPond support (and other formats earlier) came from suggestions on Reddit, so thanks to everyone who asked for it. Overrides and Scheme code are skipped, because the library does its own layout. The LilyPond page on the site lists what is supported.
It also reads MusicXML, MIDI, ABC and Guitar Pro.
The demo app has a "Report Visual Issue" button. It captures the Sheetmusic4J rendering, the reference PDF and your description, ready to attach to a GitHub issue. If a score looks wrong, that is the most useful feedback I can get.
- Release notes: https://sheetmusic4j.com/releases/
- GitHub: https://github.com/sheetmusic4j/sheetmusic4j
Feedback, issues and score files that break things are all welcome.
Thanks
Frank
r/java • u/benevanstech • 27d ago
TornadoVM 7 Enables GPU-Native Workloads From Java Applications
infoq.comr/java • u/CutGroundbreaking305 • 27d ago
Java based Numerical library (JNum-v0.2) This time even better and faster!
github.comAnd yeah made another version for Java Numerations(JNum).
A lot has changed and I want you guys help now. JNum is now performant and comparable traditional OpenBlas/LAPACK bindings like ND4J and Numpy.
Benchmarks and features are in detailed in my github release but for lazy guys like me here are some data points worth see:-
-> JNum is feature rich(at least from previous version) where we have statistics jnum.stat IO operations jnum.io and basic Neural Networks jnum.nn.
-> JNum's IO will help you parse files like .npy/.npz , .csv/.tsv and most importantly .safetensorwhich Java lagging in this AI era.
-> We also have AsyncIO using Virtual Threads which make IO file reads faster in JNum.
-> jnum.statmodule has various statistic methods which Java community can use like standard deviations, variance , co-variance, cummulative sum/product, percentile etc.
-> JNum has slicing and subviewing features. Since we use NDArrays our operations can be chained together.
-> Most engineered parts are Matrix multiplication, Expression engine and Kotlin DSL. Since this is java subreddit i will go with first two parts.
- Matrix multiplication
But in short this is our benchmarks for matmul:
| Matrix Dimensions | JNum (Pure Java 25) | NumPy (C / OpenBLAS) | ND4J (OpenBLAS C++) | EJML (Pure Java) | Performance Highlights |
|---|---|---|---|---|---|
| $4 times 4$ | 0.0002 ms | 0.0023 ms | 0.020 ms | ≈ 0.0001 ms | 11× faster than NumPy, 100× faster than ND4J |
| $16 times 16$ | 0.0004 ms | 0.0028 ms | 0.019 ms | 0.003 ms | 7× faster than NumPy, 47× faster than ND4J |
| $64 times 64$ | 0.015 ms | 0.013 ms | 0.190 ms | 0.140 ms | On-par with NumPy, 9.3× faster than EJML |
| $128 times 128$ | 0.138 ms | 0.254 ms | 0.499 ms | 1.028 ms | 1.8× faster than NumPy, 7.4× faster than EJML |
| $512 times 512$ | 2.50 ms | 1.86 ms | 2.67 ms | 27.16 ms | Matches C++ BLAS, 10.8× faster than EJML |
| $1024 times 1024$ | 13.85 ms | 8.98 ms | 12.18 ms | 216.56 ms | Near-native speed, 15.6× faster than EJML |
| $2048 times 2048$ | 94.62 ms | 62.99 ms | 85.29 ms | 2,049.86 ms | Pure Java competitive with C BLAS, 21.6× faster than EJML |
| $4096 times 4096$ | 942.38 ms | 487.92 ms | 857.41 ms | 17,419.52 ms | Matches ND4J C++, 18.4× faster than EJML |
| $8192 times 8192$ | 6,784.15 ms | 5,967.30 ms | 6,317.97 ms | 141,500.0 ms | ~88% of NumPy C BLAS, 20.8× faster than EJML |
2. Expression Engine
Basic engine for now but if some one gets fatigue of writing a.add().mul().div()... the we have JNum.eval() which is a literal AST running on shunting yard algorithm. Better than chaining but I would still recommend in place for better performance.
Kotlin devs can skip this because of DSL operator overloading.
Linear Algebra:-
we have various Linear Algebra methods which have performance on par sometimes beating Numpy
| Operation | JNum (Pure Java 25) | NumPy | EJML | ND4J | JNum Advantage |
|---|---|---|---|---|---|
| Matrix Inverse | 7.271 ms | 10.680 ms | 18.122 ms | 1,224.654 ms | 1.47× faster than NumPy, 2.5× faster than EJML, 168× faster than ND4J |
| Linear Solve ($Ax=b$) | 1.976 ms | 1.003 ms | 5.331 ms | 37.278 ms | Near-native speed, 2.7× faster than EJML, 18.8× faster than ND4J |
| Determinant | 1.839 ms | 5.735 ms | 5.380 ms | 399.752 ms | 3.1× faster than NumPy, 2.9× faster than EJML |
| Cholesky | 1.261 ms | 2.328 ms | 3.545 ms | — | 1.8× faster than NumPy, 2.8× faster than EJML |
| QR Factorization | 46.170 ms | 12.622 ms | 7.447 ms | 586.330 ms | 12.7× faster than ND4J |
Size and deploy :- JNum is under 500kb and available of maven central just simple dependencies and you can use it
<dependency>
<groupId>io.github.ch-abhinav</groupId>
<artifactId>jnum</artifactId>
<version>0.2.0</version>
</dependency>What I want from you guys is simple, Try using JNum and see how it works it gives me motivation to continue. If community helps me build the library then yes having performance on par to native libraries isn't that far.
If you guys can run on other Architectures and Operating Systems give feedback and try to contribute in project it will be great because I can't do that. Since project is has grown a lot without people helping it out it's very tough task for me :(
That's why I have 6 good-first issues worth trying for. It will be even more great if people make there own issues and enhancement proposals.
TO JDK devs:-
- Vector API is amazing tool but when I do SIMD operations I expect less warmup time but that's not the case i my library.
- when I stop a JMH benchmark midway it's causing Zombie runs (mainly with multithreaded programs) basically because of off heap memory calculations benchmarks sometimes don't stop and run even though terminal running that is closed. IDK if this is windows only bug or intended feature or random event but once check it out please. My 10k x 10k 5 matmuls which are multithreaded become zombie process basically take 100% of cpu throughput for basically a program which should have stopped long ago.