Language selector

Java

Recently, somewhere on social media, I saw a code snippet. I guess the intention was to show how “Java is bad and dead”. I think it’s a good time to focus on some claims, falsehoods and half-truths that appeared in the comments, which I found pretty amusing. It also answers some of the criticisms raised in conference talks in autumn (checks the calendar) of 2026!

TL;DR: compact source files are already here, value objects from Valhalla are coming, you can keep your head in 2005, but be aware what year it is now.

Streams were a very nice addition to Java 8, based on lambdas. They allow streamlined data processing without side effects, taking us gently towards functional style. With newer additions to Java, like records and pattern matching, they shine even more in data-driven flows. However, they don’t come without flaws. For starters, the only available extension point was collectors: if your needs for gathering data weren’t satisfied by the whole Collectors ZOO, you could always fall back to creating your own Collector. However, if map, filter or flatMap weren’t enough, you couldn’t add your own intermediate operation. Secondly, parallel streams were limited to ForkJoin pool, effectively rendering them unusable for scenarios involving any IO. Since Java 22, Stream Gatherers are our extension point for intermediate operations in streams. If you’d like to comprehend how they work, find nice use cases and hunt for more performance, this talk is for you.

Integration tests are nice. We all know that and love using them, don’t we? It’s just using all those databases, message brokers and other things as real dependencies, only wrapped by Testcontainers, might result in a really heavy CI/CD pipeline and developers’ attitude to never run them locally, because they’re so slooooooooooow. What if I could show you a number of techniques, mindset changes and tricks to get your integration tests shortened from quarters to seconds? Would that be interesting for you, to benefit from the confidence integrations tests give you, before you’re able to brew a fresh coffee? It’s really not about re-inventing the wheel, but using it the smart way.

Java 22 is about to be released tomorrow. There are many super nice things in this release. I suspect making Project Panama’s native/foreign calls will make many people’s life easier, as well as ongoing changes to concurrency, string templates and finally being able to call something before super. However, there’s one thing I guess is going to be my (almost) hidden hero of Java 22. Folks, I introduce to you Gatherers.mapConcurrent!

Let’s talk about Java 21 and have a sneak-peek into Java 22, and things like: Java was supposed “to be slow”. However, Java turns out to evolve so fast, that next releases aren’t just version bumps, but might significantly change the rules of the game. That’s a good reason to check out what’s new in Java. To name a few changes:

  • Virtual Threads (and some traps),
  • Pattern Matching and Record Patterns,
  • Structured Concurrency,
  • String Templates,
  • Stream Gatherers,
  • changes around main() method,
  • what’s gone and what will be gone,
  • and other things. If you find them interesting, let’s dive deep together into new interesting stuff!

This talk has been given for Silesia JUG only, no recording.

In the past I wrote two posts about Java sripts and their portability using shebang.

As far as I can tell everything in these two installments is still valid, only now, in Java 21, thanks to JEP-445 things can be even simpler. In this post I’ll try to describe fist the changes introduced by this JEP, then go deeper on how they relate to the “scripts in Java”.

I’m going to cover how you can simplify your main method, get rid of the class surrounding it, and even show you when it won’t work.

As I wrote in my previous post I had issues running code using JEP 443 using tools like Maven, Gradle or IntelliJ IDEA. Thanks to the one and only Tagir Valeev the solution is quite simple.

Upgrade to JDK 21.0.1.

And that’s it ;-)

No need to touch anything else. If you fancy more explanation, please follow on this Twitter thread.

And we shall all remember that upgrading is a good thing, because we’re not going to stay on Java 8 forever, right? ;-)

Update

The issue has been solved, please go to the post with solution.

Note: I’m leaving the original post below in case someone bumps to a similar issue in the future. Sometimes it’s easier to search using the problem ;-)

While preparing my Deep Dive talk on Java 21 for friendly Java User Groups, I’ve noticed a curious case of JEP 443: Unnamed Patterns and Variables (Preview). I’ve managed to create a reproducer, so I’d like to share the findings here.

Java™ 21 is real now. And so are virtual threads. Everyone got excited about them, yet you prefer to keep your Java 8 job forever, and you already have a nice plan to “accidentally” derail the migration to 21 by using virtual threads in a very, very unfortunate way. What a pity…

So you decided to come for this talk to look for some inspiration ;-)

Okay, please join us to learn how NOT to use virtual threads, and see the potential performance pitfalls of using them the wrong way.