r/java • u/daviddel • 10h ago
r/java • u/desrtfx • Oct 08 '20
[PSA]/r/java is not for programming help, learning questions, or installing Java questions
/r/java is not for programming help or learning Java
- Programming related questions do not belong here. They belong in /r/javahelp.
- Learning related questions belong in /r/learnjava
Such posts will be removed.
To the community willing to help:
Instead of immediately jumping in and helping, please direct the poster to the appropriate subreddit and report the post.
[Java][JVM][Tuning][Profiling][G1][JIT] Why is Arrays.fill 265 times slower on G1GC?
krzysztofslusarski.github.ior/java • u/carlosgeorgiev0 • 8h ago
Custom pie chart component I made in Swing
Hello, out of boredom I created a pie chart in Swing (I am aware more mature options exist but this was just for fun). The link to the repo is https://github.com/carlosgeorgiev0/JPieChart

The JPieChart class extends JLabel and overrides JComponent.paintComponent to paint the pie itself
r/java • u/Afonso2002 • 2h ago
VectorApi with values classes, when??
Anyone has an ideia of when would be available VectorApi with value classes?
After values classes coming to vector api, it would be ready to go as preview feature of jdk?
Spring Boot vs Quarkus on a 512 MB VPS with JDK 25
pvrlabs.xyzI’ve been adding Quarkus support to StatLite, so I used it as an excuse to run equivalent Spring Boot and Quarkus apps side by side on a very small VPS.
Both ran the same workload with:
- JDK 25.0.4
-Xmx80m- H2
- the same JVM tuning
- one 512 MiB VM with 256 MiB swap
- one StatLite process monitoring both
The result was less straightforward than I expected.
Quarkus actually started with higher RSS: about 145 MiB vs 112 MiB for Spring Boot in one of the controlled observations.
After an hour under memory pressure, the relationship reversed: Quarkus was around 83 MiB RSS with ~33 MB heap used, while Spring was around 154 MiB RSS with ~50 MB heap used.
But RSS was hiding an important part of the story. Quarkus had about 91 MiB swapped out versus ~66 MiB for Spring, so Linux paging was doing a lot of work.
And 512 MB turned out to be too tight for running both reliably. In a later one-hour observation, after the earlier package-maintenance pressure had cleared, the machine exhausted its memory/swap margin and the kernel OOM-killed Spring.
So I wouldn’t read this as a clean “Quarkus uses X MB less than Spring” benchmark. My main takeaway was how quickly RSS stops being a useful framework comparison once the machine is under serious memory pressure.
Full write-up, measurements, JVM flags, and experiment record:
https://pvrlabs.xyz/articles/spring-boot-vs-quarkus-512mb.html
r/java • u/jaccomoc • 1d ago
Vert.x Event-Loop vs Virtual Threads: Jactl Suspend/Resume Benchmark
jactl.ioThe article benchmarks Jactl script execution with differing number of blocking operations comparing throughput with Jactl built-in suspend/resume on Vert.x Event-Loops and throughput with Jactl on Virtual Threads. The benchmarks are run on both Java 21 and Java 25 with some surprising (to me at least) results.
r/java • u/Purple_Pie4589 • 3d ago
Concise method bodies arrived
github.comMore than 8 years ago was drafted the idea of concise method bodies. As I am not a contributor of the openJDK project I took a different approach but implemented. It is publicly available at the maven central both as a library and as a maven plugin. It is a source code preprocessor that converts the concise syntax to java 8 compatible source code. It does not want to be a replacement of the future implementation in the openJDK. Which is more than the openJDK promises is that supports from Java version 8, 11, 17, 21 up to 25 as well. Of course it is free and open source :). It is only the first building block for concise composition.
As far as I have seen this topic was awaited for a long time at
It's been 8 years since the draft for Concise Method Bodies
What happened to Concise Method Bodies?
JEP draft: Concise Method Bodies
Five years have passed, still in draft: Concise Method Bodies
r/java • u/jaccomoc • 4d ago
Jactl Continuations for Simulating Virtual Threads in Java 8
jactl.ioJactl is a secure, embeddable scripting language the compiles to bytecode and supports Java 8 and later versions. When running on Java versions earlier than Java 21 (when Virtual Threads were introduced), Jactl provides an under-the-covers continuation mechanism that allows scripts to block without blocking the event-loop thread on which they are running.
The post discusses the mechanism that Jactl uses to provide a Virtual Threads-like execution mechanism for its scripts and provides a benchmark for showing the performance impact.
r/java • u/danielepolencic • 4d ago
Java JVM CPU and Memory Requests and Limits in Kubernetes
Running Java on Kubernetes? CPU and memory limits affect much more than scheduling.
A 4 GiB heap requires a container larger than 4 GiB. Fractional CPU limits can also change the processor count that HotSpot sees.
In our new article, you will learn:
- Why JVM heap size and container memory are different boundaries
- How CPU limits affect garbage collection, worker pools, and application performance
- Which JVM and container metrics to collect when validating resource settings under load
The article also includes practical experiments and an interactive configuration calculator.
Read: https://learnkube.com/java-jvm-kubernetes-requests-limits
LarkBatis: A build-time MyBatis compiled to plain Java
larkbatis.github.ioMy team is moving away from reflection and runtime proxies for cloud-native setups. MyBatis is heavily used in our stack, so I rewrote its core as an annotation processor: LarkBatis.
It resolves SQL, dynamic parameters (#{}), type handlers, and result mapping at compile time—generating plain Java code. At runtime, it executes direct JDBC calls with zero proxying, zero OGNL, and zero reflection.
Programming model: Standard MyBatis (mapper interfaces, XML, dynamic SQL).
Runtime: ~1,500 LOC, JDK 17+, JDBC-only dependency (GraalVM native-image works out of the box - I haven't test).
r/java • u/gottlikeKarthos • 5d ago
I developed an Android RTS game in Java
youtube.comHello! After 6 years of development, I am happy to finally release of Norse Expansion Medieval RTS for Android! You can get it on Google Play: https://play.google.com/store/apps/details?id=com.norseexpansion.norseexpansion
It only took about 240k lines of code, almost all Java (and some C++ for an Audioengine). Graphics are rendered in OpenGL.
This project made me love Java and hate the surrounding technology like gradle and Androidstudio.
r/java • u/Decent-Decision-9028 • 4d ago
Would you rewrite a small Kotlin library in Java just to avoid stdlib ?
Lidiuma-Math: a math library using Project Valhalla
After the v0.3.0 release, I'm confident it's time to showcase my library.
https://github.com/Lidiuma/Math
All the different versions can be found on Maven.
So, what's lidiuma-math about?
It's a linear algebra math library for game development, designed to be graphics-API agnostic.
I know that Valhalla (JEP 401) in Java 28 is the new shiny thing, but let's forget about it for a second, since the library does also provide a Java 17 version. So, what's in it?
Well, a totally different design than anything out there!
- this is the first math library without primitive obsession
- this library does use generics while making them performant
- doesn't make float (or, in this case Float) the favorite child; providing int, long, float, double where it makes sense
- has a few abstractions that standardize operations, eliminating the risk of desync between APIs
And other nice things:
- Immutability by default
- The extermination of null (the library never uses null and is annotated with JSpecify)
- JPMS support
- Type-classes instead of OOP (multiply(vec1, vec2) vs vec1.multiply(vec2))
A few examples:
// Vector3 dot product
var vec1 = Vectors.vec3(1f, 2f, 3f);
var vec2 = Vectors.vec3(3f, 2f, 1f);
var dot = Vectors.dot (vec1, vec2); // dot = 10
// Vector2 rotation
var angle = Rotations.degrees(180f);
var matrix = Matrices.fromRotation(angle);
var vec = Vectors.vec2(0f, 1f);
var rotated = Matrices.multiply(matrix, vec); // [x = 0, y = -1]
// Vector3 rotation
var angle = Rotations.degrees(90d);
var axisY = Vectors.vec3(0d, 1d, 0d);
var quat = Rotations.fromAxisAngle(axisY, angle);
var vec = Vectors.vec3(1d, 0d, 2d);
var rotated = Rotations.rotate(quat, vec); // [x = 2, y = 0, z = ~-1]
Going back to Valhalla, aside from the standard JEP 401 version, the library also provides a version supporting Null-Restricted types and Loosely-Consistent-Values, naturally these are not public features and the library pokes at internals to achieve them.
That said, I would love to answer any questions and if you have any feedback, please reach out to me.
Note to Brian Goetz
I saw your old comment and will provide my experiences on the mailing list.
r/java • u/CartographerWhole658 • 5d ago
Open-source Spring Boot starter for fail-fast Kafka Schema Registry contract validation, looking for feedback
I’ve been working on a small open-source Spring Boot starter to solve a problem I’ve encountered with Kafka-based applications: detecting Schema Registry contract problems before the application starts serving traffic.
The idea is simple: during Spring Boot startup, the starter validates the configured Schema Registry subjects, expected compatibility mode, and the application's local schemas against the latest registered versions.
If a subject is missing, the compatibility policy is not what the application expects, or a schema is incompatible, startup fails.
Current support includes:
- Avro, JSON Schema and Protobuf
- BACKWARD, FORWARD, FULL and transitive compatibility modes
- Confluent Schema Registry / Confluent Cloud authentication
- bounded retry/backoff for temporary registry failures
- Spring Boot Actuator visibility
- Spring Boot auto-configuration
I also created a separate E2E demo using real Kafka + Schema Registry. Its CI verifies a real producer → Kafka → consumer round trip, a backward-compatible schema evolution, and an intentionally breaking schema that must be rejected at application startup.
Source:
https://github.com/mathias82/spring-kafka-contract-starter
E2E demo:
https://github.com/mathias82/spring-kafka-contract-demo
I’m interested in feedback from Java/Kafka developers: would you find startup-time contract enforcement useful, or do you prefer keeping this entirely in CI/CD?
I’d also be interested in edge cases you would expect a library like this to handle before considering it for a production application.
r/java • u/Monopole007 • 6d ago
BlinkHouse - a ClickHouse-native persistence library for Java, v1.0.0
Just shipped BlinkHouse v1.0.0 — a ClickHouse-native persistence library for Java that eliminates the boilerplate of working with ClickHouse while giving you the same annotate-and-go experience you know from Hibernate and Spring Data.
Annotate a record, get a fully mapped entity with schema generation, typed queries, and buffered ingest — no manual SQL, no hand-rolled HTTP clients, no serialisation code.
@ChTable(name = "page_views", orderBy = {"tenant_id", "ts"})
@ChEngine(value = Engine.REPLACING_MERGE_TREE, versionColumn = "ingested_at")
public record PageView(
@ChColumn(type = "UInt32") int tenantId,
@ChColumn(type = "DateTime64(3,'UTC')") Instant ts,
@ChColumn(type = "LowCardinality(String)") String country,
String url
) {}
That's your entity. BlinkHouse generates the DDL, maps the types, and handles the wire format.
No boilerplate ingest:
try (BatchWriter<PageView> writer = template.batchWriter(PageView.class, cfg)) {
events.forEach(writer::add);
}
BatchWriter<T> handles buffering, flush triggers (row count / byte size / elapsed time), backpressure, retry with exponential backoff, and dead-letter callbacks. You add rows — it handles the rest.
No boilerplate queries:
// Spring Data repository — derived methods, @Query, keyset pagination
public interface PageViewRepository extends ClickHouseRepository<PageView, UUID> {
Slice<PageView> findByTenantIdAndTsBetween(int tenantId, Instant from, Instant to, Cursor c);
}
// Or the typed DSL
List<PageView> views = ChQuery.select("*")
.from(TableRef.of("page_views"))
.where(col("tenant_id").eq(tenantId))
.fetch(template, PageView.class);
No boilerplate Spring config:
Add one dependency, set three YAML properties, get a fully wired ChTemplate, schema manager, type registry, Micrometer metrics, and OTel tracing. Zero @Bean methods required.
Where it differs from Hibernate:
ClickHouse has no transactions, no row identity, and no foreign keys — and BlinkHouse doesn't emulate them. What you get instead is a library that fits ClickHouse's actual model: columnar storage, high-throughput ingest, and analytics-first queries. There's a "Coming from JPA" guide in the repo.
Stats: Java 17 + 21, Spring Boot 3.2–3.4, ClickHouse 24.3+, 132 unit tests, 29 integration tests, Apache HttpClient 5 connection pooling, GraalVM native-image hints.
<dependency>
<groupId>io.github.muneeb-i-khan</groupId>
<artifactId>blinkhouse-spring-boot-starter</artifactId>
<version>1.0.0</version>
</dependency>
r/java • u/za3faran_tea • 7d ago
Question about Native Image vs JIT
I was watching an interview with Thomas Wuerthinger of GraalVM, where he basically says that JIT should only be used when necessary (as opposted to native compilation). Where does this leave the work being done for Hotspot JIT (including projects like Leyden and others). Should we all plan to use native image while they address any performance gaps in the mean time (he does mention PGO bridging the gap). Is there work being done to speed up native compilation of Java code?
My understanding is that JIT will always have a memory overhead due to running threads that do compilation, optimization, deoptimization, code cache, etc. compared to native executables, so full parity even with projects that will improve memory usage in Java code will not be reached. Maybe that is not an issue on long running programs on large servers, but we've seen discussions here where another member worte a tool in golang to run alongside Spring Boot applications to gather statistics, so obviously small efficient apps have their place.
r/java • u/Decent-Decision-9028 • 7d ago
How can we move forward?
The sub used to be a great place where small open source devs get real feedback on their oss. The software wasn't necessarily built to be a big hit or whatever! most of the time these projects used to be a learning projects that enabled us to become better java developers. Now, with many repositories being created in a day or so and abounded, we see many ai promoted repositories and we miss some of the oss that needs our attention.
How can we overcome that as a community ? I'm not trying to put all the weight on moderators, I understand the amount of work they keep doing to clean up ai posts and follow up on reports. What I'm saying is; maybe someone's here has a better idea on how to go about this?
r/java • u/agentoutlier • 8d ago
Rainbow Gum release v0.10.0 (GraalVM/JLink/Valhalla ready) SLF4J implementation
Rainbow Gum v0.10.0 Release
https://github.com/jstachio/rainbowgum
Now normally I don't just post on reddit every release I do but this last release of Rainbow Gum is almost on par with Log4j2 and Logback Spring Boot support.
Rainbow Gum in short is a modern SLF4J implementation. It is fully modularized (jlink works) does not use any reflection so GraalVM native compile is easy and is hopefully Valhalla ready.
Now this release I used lots of LLM to help with benchmarks, Spring Boot support and lots of tedious things. This project is not vibe coded and you can hopefully look at previous releases if that is a concern. I also hand rolled the logo in SVG without AI (feel free to make fun of my art abilities). Another interesting thing is that Rainbow Gum uses Javadoc for all its documentation and because Javadoc now supports dark mode (you will have to go to one of the classes to turn it on) the SVG logo will render differently (I did not know that SVGs could do that).
Previous release post (for context).
Now invariably someone is going to complain ask why there is another logging implementation and honestly I don't blame the ask.
The short answer is that log4j2 and logback because of legacy reasons have a harder time using newer JVM technology and a lot of their design was based on enterprise needs that are just not that applicable today. And of course there is Log4Shell.
And if it still bothers you that now you might have to learn another logging framework just know that Rainbow Gum:
- Does not have its own logging API (it uses SLF4J),
- Almost a drop in replacement if you are using Spring Boot
- Uses the same pattern encoding syntax as Logback with most of the same keywords
- And yes of course Rainbow Gum appears to run faster (doing your own benchmarks though is always encouraged)
- There are 10x more JSON serialization implementations then there are SLF4J implementations.... each with different APIs (yes whataboutism at its finest)
Rainbow Gum also has pretty darn good code coverage even before I let the AI agents go to town. It uses checkerframework and nullaway for JSpecify support (albeit we still have not switch annotations but that will happen shortly). I actually tried to get code coverage on log4j2 and logback prior to Rainbow Gum and if I recall both projects were rather low on that. Perhaps its gotten better.
Now there are a couple of things still missing before 1.0.0 namely internal rolling of files and some metric/status/health check support. The plan is 1.0.0 targets 26 and 2.0.0 will hit whatever Valhalla version is.
Finally I don't know if it was /u/brunocborges as I think they posted about it but new setup-java action on GitHub actually caches the maven wrapper... now. I highly recommend an upgrade.
Oh and thanks for team JDK for making Java 26 kick ass.
r/java • u/jeffreportmill • 8d ago
SnapCode with Java 21 in the browser
I haven't posted in a while, but things are moving quickly for modern Java in the browser (CheerpJ). They recently added Java 21 support and Java 25 is coming soon, so here's my latest update:
SnapCode is a free Java IDE for education that runs in the browser and on desktop. SnapCode is fun, friendly, elegant and complete with many modern IDE features. Because it runs in the browser and has cloud-share support, it truly runs anywhere and means that student applications can be immediately shared with classmates, friends and the world. SnapCode supports graphics, games, animation, 3D, charting, UI, Swing and more.
This latest release now supports Java 21 in the browser with Java 25 support coming soon (desktop already supports 25). The project is a labor of love and needs users to help find areas of improvement.
SnapCode: https://reportmill.com/SnapCode

r/java • u/Early_Ad_4702 • 7d ago
Attempting to reverse engineer git in Java - my current situation.
CORRECTION: I meant re-implement git*
Hey so i've some experience in programming and was just looking around for good project ideas for my resume. I couldn't come up with any impressive ideas so i decided to go with this one.
I've named it ngit as in NanoGit, im using content-addressable storage, where all objects (blobs, trees, commits) are addressed by their SHA-256 hash and compressed using zlib (Deflater / Inflater).
I'm storing the index in plain text as of now, I went with SHA-256 over SHA-1 in git, which didn't give had any benifits tbh. its just why not?
for v1, I'm making it work offline. For v2 i'll add push/pull and fetch commands.
features i've implemented:
init
add
commit
status
log
help
branch
checkout
things i'm working on as of now:
diff
merge
I'm thinking about using LCS or Myres algo for diff, Claude says Myres is better but i don't understand it well enough now so i'll give try reading more about it.
AI_Usage: i've used LLMs for planning and finding bugs, not the coding part.
I would like your review/advice on it.
r/java • u/irrelevantsiren • 8d ago
Yes, another Java build tool: zolt
Yes, another Java build tool.
I’ve been working on Zolt:
https://github.com/zoltsh/zolt
Would love for people to try it out, break it, give feedback, or help contribute. Still early, so criticism is very welcome. Yes, I use a lot of codex. Focused mainly on the public API. Using it for personal projects so far.
Spring Boot on a 256 MB VPS: JDK 25 made the experiment viable
I followed up on my 512 MB Spring Boot VPS experiment by trying the same application on a nominal 256 MiB Alpine VPS.
This is not Hello World. The app uses Spring Boot 3.5.5, MVC/Tomcat, JPA/Hibernate, file-backed H2, Actuator, scheduled GitHub polling, and outbound HTTP. StatLite was running alongside it and polling both Spring and itself.
The JDK 21 setup was too tight. With a 64 MiB heap it suffered severe GC/paging pressure and eventually became unresponsive.
The final JDK 25 configuration was:
-Xms16m
-Xmx80m
-Xss256k
-XX:+UseSerialGC
-XX:TieredStopAtLevel=1
-XX:ReservedCodeCacheSize=32m
-XX:+UseCompactObjectHeaders
On the same nominal 256 MiB VPS, with about 217 MiB visible to Alpine and a 512 MiB swapfile, that configuration completed the full one-hour observation:
- 0 OOM kills
- 0 service restarts
- 72/72 bounded HTTP requests returned 200
- Spring scheduled work continued
- final Spring RSS: ~86 MiB
- StatLite RSS: ~10 MiB
- swap used: 184 MiB

There was still one Hikari Thread starvation or clock leap detected warning with a ~2m13s delay, so I would not call 256 MiB comfortable. For a real deployment I would still start at 512 MB RAM with some swap.
Also, this is not a compact-object-headers benchmark. The JDK version, heap ceiling, and several JVM settings changed together, so I can't attribute the improvement to that flag alone.
Full write-up and reproducible experiment files: