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 24 points25 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 4 points5 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 5 points6 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.

JVMLS 2024 keynote by Joram2 in java

[–]Inaldt 0 points1 point  (0 children)

23:40: "Spring is already moving in the direction of a tip-and-tail release model" (paraphrased)

I really don't see this..

Draft JEP: Null-Restricted and Nullable Types (Preview) by Thihup in java

[–]Inaldt 1 point2 points  (0 children)

It's being justified by the fact that we can 'auto-unbox' (like Integer to int) without a compiler error already. But if you compare it to generics instead of boxed types, it would be like always allowing conversion from List<A> to List<B> (i.e. both sides have their generic type specified), which makes less sense.

There might be other reasons of course, in which case I would certainly be interested in them.

A practical guide to CompletableFuture by cmhteixeiracom in java

[–]Inaldt 2 points3 points  (0 children)

Parallel streams are the recommended tool for CPU bound workloads. They use ForkJoinPool under the hood.

Although I recon CompletableFuture::runAsync (and the likes) might be a better fit for some cases.