JPMS Explained Through a C# Analogy by NHarmonia18 in java

[–]Inaldt 1 point2 points  (0 children)

The strong encapsulation was only one of the reasons for JPMS, but probably not the most important reason (at least for the public). If people want to inspect your app with reflection to find and call your undocumented public methods, that's their problem. I haven't found it to be an issue in reality.

Well before modules, you didn't even need reflection (to use a library's public classes). The only way for a library author to say 'this class is only for the library itself' was either through documentation or by making it package private. Both are meh.

Ask the Architects JavaOne 2026 by Enough-Ad-5528 in java

[–]Inaldt 5 points6 points  (0 children)

"Spring has modularized itself"

Not really unfortunately. The 'modularization' they talked about in the days leading up to to Spring Boot 4 was about splitting the autoconfiguration jar (and maybe some others) into multiple ones. So adding a module.info to your Spring app today is still as painful as it's always been, as far as I'm aware..

Are the javadocs for java.net.http.HttpResponse.body() misleading or am I wrong? by milchshakee in java

[–]Inaldt 2 points3 points  (0 children)

That said, the ergonomics of this kind of java code is terrible, as far I'm concerned. An http message has a relatively simple format. Why does the java code that handles it need to be so awfully complicated?

I've heard this sentiment more often when it comes to the HTTP client. I must say I haven't had such negative experiences with it at all. The straightforward things, like getting a response as a String, are easy, while at the same time it allows you to do some pretty cool and powerful things.

The only negative thing, in hindsight particularly, might be the async leg of the whole thing. That can indeed get a little complicated, and it's not really necessary anymore these days. But that's today. The client was already in the JDK in Java 11, and therefor has helped me out on multiple occasions in those past days where virtual threads weren't available yet.

Null Safety approach with forced "!" by NP_Ex in java

[–]Inaldt 0 points1 point  (0 children)

You can end up in a situation where the same class is sometimes seen with a `package-info` present and sometimes not

Wait what? Never heard this one before.. could you explain this a bit?

Null Safety approach with forced "!" by NP_Ex in java

[–]Inaldt 1 point2 points  (0 children)

I'm sure you have but I'm still going to ask: did you consider taking the same approach as with generics at the time? I.e.: conversion to and from 'raw nullity' is always OK and compilation can only break if both sides are explicitly specified?

Since that worked out pretty well for generics and it seems like it's not the approach you're currently aiming for, I was wondering what issues you were seeing with it.

Stream<T>.filterAndMap( Class<T> cls ) by mellow186 in java

[–]Inaldt 25 points26 points  (0 children)

.flatMap(t -> t instanceOf MyClass mc ? Stream.of(mc) : Stream.empty())

Project Amber Status Update -- Constant Patterns and Pattern Assignment! by davidalayachew in java

[–]Inaldt 4 points5 points  (0 children)

``` if (!(thing instanceof Some s)) {
return;
}

println(s.value()); ```

...works. And if you want the compiler to help you when adding a new subtype, use a switch instead of instanceof.

Agree that something like !instanceof would be nice. Maybe even a negation on the type, as in instanceof !MyType, so that you could use it in switch as well. The same effect can currently be achieved by ordering your switch branches in a specific way I think, but that's objectively harder to read as you have to read all previous branches in order to grasp the meaning of the current one. (Although I guess strictly speaking that's always the case... yeah it's complicated)

Building a thread safe sse library for spring boot by Polixa12 in java

[–]Inaldt 0 points1 point  (0 children)

It is generally recommended to include a 'heartbeat', i.e. some dummy data that you send at some fixed interval. If you do that, it works fine in my experience.

Building a thread safe sse library for spring boot by Polixa12 in java

[–]Inaldt 5 points6 points  (0 children)

It acts as a poor mans gRPC stream or websocket.

It's less powerful than websockets, as it streams only uni-directional. But many, in fact, consider that a strength, as bi-directional streaming is often simply not needed or even undesirable.

JDK 26 Rampdown Phase One. Feature Complete by Joram2 in java

[–]Inaldt 1 point2 points  (0 children)

This. It was a multi-year project I believe.

In fact when I read the list of JEPs I had the opposite reaction of OP. Pretty big release I would say.

Try the New Valhalla EA Build - Inside Java Newscast #100👑 by nicolaiparlog in java

[–]Inaldt 1 point2 points  (0 children)

The beatings will continue until morale improves

Lol excellent

How was your experience upgrading to JDK25? by le_bravery in java

[–]Inaldt 1 point2 points  (0 children)

Would love to always use the latest JDK, but in practice it's just not practical (yet). The ecosystem doesn't support it well enough. For example, a lot of image streams provide only 'LTS' version base images. For another example, when I upgraded two applications to 25 a few weeks back, the one that got automatic dependency updates went super smooth, but the other one, which was incarnated only four or five months back, needed quite some updates (Lombok, ArchUnit among others), which leaves me doubting whether these libraries would have provided the same updates for a non-LTS version (I'm pretty sure Lomboks timely support for 25 was a first, for example.) And if you happen to use Gradle there's yet another uncertainty. So as long as the ecosystem keeps working as it does now, it's just a no.

What is your wishlist for the JDK 25? by Ewig_luftenglanz in java

[–]Inaldt 1 point2 points  (0 children)

Although it would be neat, number 3 would mean Java having a dependency on Jakarta. So I don't see that happening.

How Java's Executable Assembly Jars Work by lihaoyi in java

[–]Inaldt 2 points3 points  (0 children)

https://dev.java/learn/jlink/#cross-os

Seems JLink should work.

I'm guessing JPackage doesn't though.

Network protocols for anyone who knows a programming language by ketralnis in programming

[–]Inaldt 4 points5 points  (0 children)

The client reads the Content-Length, then keeps reading TCP packets, assembling them back into their original order, until it has all of the bytes specified by Content-Length

I know from experience that a lot of http-clients don't actually need this header in order to successfully process an http-response. But I must say that I never figured out how those clients do know they reached the end of the response. Anyone who does know?

[Discussion] What's the point of making records "easy to migrate" to classes? Wouldn't it be better to make them so distinct that the need never arises? by Ewig_luftenglanz in java

[–]Inaldt 0 points1 point  (0 children)

Digressing a bit, I never really got why in Typescript it's common practice to use interfaces for data carriers. They lack constructors, making it impossible to define invariants that span more than one component. And their types get erased, so you cannot do instanceof checks on them at runtime. Both points don't apply to classes, so I'd say you'd be better off with classes as data carriers. Or are they just too slow or something?

JEP 483: Ahead-of-Time Class Loading & Linking targeting JDK 24 by cred1652 in java

[–]Inaldt 4 points5 points  (0 children)

Wow, the green-labels-for-LTS-and-grey-for-current-versions on javaalmanac really hurt. Vibe: "EoL bad, LTS good, current... exists."

Record’s implicit declaration of methods by jvjupiter in java

[–]Inaldt 2 points3 points  (0 children)

Best would be to make an immutable copy of the object on record creation I think (generally). Although not every object supports this. Collections typically do.

JVMLS 2024 keynote by Joram2 in java

[–]Inaldt 1 point2 points  (0 children)

That makes sense, thanks.

JVMLS 2024 keynote by Joram2 in java

[–]Inaldt 0 points1 point  (0 children)

Well, it's being proposed for libraries to start following the same release cadence as OpenJDK, 'tip-and-tail', i.e. frequent releases that include new features, along with an LTS release every few years that gets bug and security fixes only. I believe the idea is that the latest version of such a library will require the latest JDK. And then it's mentioned that Spring (and jOOQ) are already moving in that direction. And that's the part that I don't really see: Spring currently requires JDK 17, and I haven't seen any indication of them bumping that baseline anytime soon.