About this talk
This talk covers the latest features and improvements in Java versions 25 and 26. The speakers, both Java Champions, discuss developments such as pattern matching, structured concurrency, and enhancements to the Vector API. They emphasize the importance of upgrading Java versions for better performance and security, particularly highlighting the benefits of the new LTS releases. Practical demonstrations showcase coding updates that utilize these new features, enabling more concise and efficient Java code. The session also addresses the significance of being aware of dependencies and ecosystem updates that accompany new Java releases.
Full transcript
Okay. I kindly ask you to take your seats because the new session is starting. And uh yes, please join us. Just 1 second. Yeah, he just wants to say something. Go ahead. Okay. Some preparation happening now, so please take your seats. Once again, there are a lot of free seats over this direction, so please don't stand. And um okay, the first session is going to be really
really awesome. There will be a lot of new features, and there will be a lot of action happening on the stage. So, please welcome my amazing friends. Should I say Bulba, or I should not say Bulba? No, it's Piotr and Marek. So, welcome. >> [applause] >> Hello. Uh we are still waiting for the video signal uh to be shown. Uh it's almost Okay. >> Yeah. So, how
do we normally start this talk, lovely people? Is that we have some meme show. We didn't select this, you see. It's like uh it's switching uh revolving. But apparently >> It's running from IntelliJ IDEA, just FYI. When was the last time you saw memes served from IntelliJ IDEA? >> Um exactly. >> Right now. >> Oh, I and >> This is my favorite because it's a programming joke
and a language joke, and also very very true. >> Yeah, for the reference, Marek is Dutch. I'm I'm Polish. Um but, you know, folks, life writes the best memes. Uh so, can we close this, and could you open a um a browser for me? >> A browser? >> A browser tab, yeah. >> Any random browser? >> Yeah, just like a new one. it's it's happening literally after
this. Yeah, he he would just open a new new tab. Can I? Yeah. So, let's go a gprime.io/app as advertised before. Um right, this is like so you can create No, I don't want to install it. How can I open it just to so I see it? Oh, it's loading. Cool. So, as you can see uh they said it was like a live coding 30 minutes around
it using test 10 minutes and I can tell it it has zero tests because the first talk has two speakers, not just me, okay? >> Or you know, I don't have to do anything. >> Uh well, I hope you you do. So, I I'm going also going to check this apps from the hackathon. I'm going to make sure if that they have two speakers to our shown
up, okay? Yeah, so see, testing is important. You can't just say make no mistakes, right? It won't work. So, maybe we should start with the slides proper. >> Yes. >> Um cool. So, this is us. There was a hint with this meme, okay? >> Yeah, if you did not like the memes that we were showing just now, you're in the wrong room. >> feel free to leave.
We don't want to waste your time, but we definitely don't want to get a comment that there were silly jokes because you we've been warned there will be silly jokes. >> Yes, we are dad jokes. I at least I am dad joke aficionado. >> Is mom jokes a thing? I don't know. >> I guess, yes. So, it's not written here, right? So, this is Martijn van Dijk
as I said from Netherlands working for JetBrains. >> And with me, Kasha Kubowel from Poland working for Elastic. >> But more important, we are both Java Champions. >> As the Polish can tell. >> Yes, and also we are friends. So, if we are goofing around together, it's okay. This man is allowed to annoy me in ways that you are not. So, we want to ask you, who
are you? Who is using Java 26? >> In production. >> A very few hands. Oh, immediately the hands went down. Okay. >> Come to me after the talk. I have an extra swag for you, okay? Uh we brought stickers for every one of you. >> over there and there are more uh JetBrains stickers downstairs at reception, I was told. >> Yeah, for extra swag, please come and
I'll I'll share something extra. >> So, who's using Java 25 then? Uh a few hands, okay. In production? Keep your hand up in production. Okay. >> Nice. >> That's nice. Java 21? More hands. That's about half the room. 17? Also, I see 21 and 17. That's slightly less. 11? A few. >> Shall we ask >> Eight? Oh, a group over there. And over here. I'm sorry. Older
than eight? >> I'm so sorry. >> Come for the extra swag. >> in the right talk. We're going to show you all of the nice things that you can have if you're moving up. We have some swag if you want, you know, as consolation prizes. So, who recognizes themselves in this meme? >> Some of you? And I mean, we understand that moving to the latest Java versions
can be painful. It's work. You might not be allowed to spend time on that work. Uh but some of us don't have the option of putting it off. Uh if you're using IntelliJ IDEA, you'll know that we always support the uh with hopefully also helpful features. We'll show you some, but that's actually work for us to, you know, add those features to the IDE. >> Yeah, it's
also work for Elastic folks because we make sure that Elasticsearch runs on the latest JVM version and this is because it's gets better, right? It has hopefully fewer bugs, but also it's it's faster, right? And more robust. So, that's why we're using it. And like sometimes issues like hiccups like security manager got removed in Java 24 and there were two pieces of technology using it, Apache Tomcat
and Elasticsearch. Um so, the agenda for today. >> Quick agenda. So, we'll show you various features from recent Java versions, but obviously not all of them. Uh and if you know us, there will be demos obviously. So, with that so, Java 26 is the latest Java release currently. So, it adds more Amber like pattern matching. Loom is maturing, which is exciting. So, structured concurrency and scope values
will show you. Uh Panama and Vector API progress, although still in incubation. We'll show you Vector and groundwork for Project Leyden like startup and smaller footprint. >> Where's Gerrit? Yeah. >> Gerrit just left. No problem. And stronger security defaults and more. So, even for a boring release, still pretty good. Uh and then in Java 25, which is the latest LTS release. >> Uh yeah, I'll I'll skip
that round for now. There are changes or improvements to performance. Right? So, compact object headers were introduced and now in Java 27 they will be on by default. Huge change. There are of course more concurrency goodies. show you some like structured concurrency for example. There's better observability and profiling thanks to JFR for example. There's also what I like really a lot, stuff for newbies and all prototyping.
We'll show you that. And there's of course more stuff because as you can see this is just a huge wall of text, right? So, uh, we would need like a whole day training to like bring us all up to speed more or less. This is just going to be a crash course, right? Over 50 minutes. >> Here you go. >> There I go. Uh, who's uh, who's
programming in Java and Java is their first programming language? Exactly. So, you you are a proof, right? That actually one can start programming in Java, but many people say, "No, you cannot start teaching people programming in Java because it's a it's too difficult and so on and so on." So, let me ask you a question. >> right? Yeah. >> Yeah, verbose and it's always dying. Yeah. Anyway,
do you do you know what programming language this is? Who said that? Okay, uh, it comes with the extra swag. Yeah. This is Java as of Java 25, yes. And some people say, "Yeah, but this other language, right? It's better because it doesn't have semicolons, so it's shorter." >> Well, neither does Kotlin. >> Yeah, okay. Uh, but just, you know, to things in the full picture, to
have this other language called the main function, you also have to toss these. So, turns out that Java is now more concise and shorter if you want to prototype or write hello world than this other language, okay? Just saying. Um, yeah, and this is part of this >> Part of compact source files and instance main methods, which was uh, a standard feature in uh, Java 25. Uh,
so making it easier to uh, get started with um, Java. Not just for newbies, but also for prototyping. If you want to try out stuff, you can create a compact source file. IntelliJ IDEA supports that. Uh, so you don't have to use JShell anymore. You can if you want to. Uh, and uh, you don't need classes, so that solves one of the hardest problems in computer science,
which is naming things. >> That there are two problems in computer science, right? Naming, cache invalidation, and off-by-one errors. Thank you. Um okay, so >> Just one more thing, if I may. See, there is this addition of IO. Of course, you can go for static import, although I would suggest please don't, because in my opinion it's good it explicitly says it's IO happening when you read something
or you write something, right? To the terminal. >> Yeah, so it makes it more explicit what's going on. With that, it's demo time. You know, what could possibly go wrong? Um he wanted to add this slide. Of course, the first time we did this talk the demo immediately failed. Um thank you. So, because it's a demo and stuff might blow, uh we brought some lab coats. >>
You know, safety measure. >> Yes, we didn't bring any goggles. We also didn't bring any lab coats for you all, but you know, just pretend that we are in a like a scientific mindset. We're going to try some stuff. >> Yeah, and >> And we're going to have fun, right? >> You're not a proper scientist if you don't have a pocket in your chest Sorry, pens in
your chest pocket. Only then you're a true scientist. Uh yes. >> for our experiments. >> Fingers crossed or thumbs squeezed, things won't explode today. >> Praying to the demo gods. >> Uh yeah. >> So, let me explain what our code is doing. So, we took some stock images. because unfortunately we can't show you a proper application, like a real real, because NDA. So, we created one. >>
a demo application. And what our demo application does is we used a multimodal encoder, which is something that can encode different types of input, in our example images and text, and generated vector embeddings for those images and text. The idea being that the text that describes an image has a vector embedding close to that image, so you can use the text to find the images. Uh and
to prepare we did the indexing for our images already and we stored the vector embeddings um with the file names in Elasticsearch, you know, for search. >> Thank you. >> You're welcome. Um and then when we search by text, it will generate the vector embedding for our search term and then find use a hybrid search, so different modes of searching, both the classic search by text and
the vector search uh and combine the results from those using RRF, so if you can stop playing with the selfie stick, you can explain RRF to the people. >> yes, RRF is um is a one way to do hybrid search. It stands and the the hardest part is the explanation of the acronym. It stands for reciprocal rank fusion. Uh the algorithm is quite simple, it's like two
pages. Uh how to explain it? Do you know Formula One races? Okay, so in theory >> I'm nodding. >> you can like uh be second or third in every race, like you win no single race, but then you get the trophy at the end of the season, right? Because how the others scored in individual races. So this is basically the the idea, like there are different search
mechanisms, it's just like a race and then the results are combined. Yes. >> Exactly. Um so that's what we're going to do. >> After we take this lovely selfie with all these lovely people. >> Oh, okay. Cheese. >> Cheese, smile, wave, whatever. Um okay. >> Let's actually run the code, make sure that it runs. >> Yeah. Oh. >> Uh what should we look for? >> Fruit? >>
Yeah, let's look for a fruit. >> It's going to take a little while. Can you read this by the way or should zoom a little? Zoom. >> Okay, yeah. So we did zoom. So it just we kept typing for a search term or search phrase, right? And then it gives us the results, the the images. So, it found us the fruit because see this is like the
text search and then it found found us apples and plums because the model understands that the apples and plums are also fruit, right? So, the app is working. So, now the whole idea is we'll be going through this app and try to refactor and modernize it with the latest greatest Java stuff, right? So, what's the stuff? >> So, because we built the app in like Java 8
11-ish code, so one of the first things we wanted to show you is records that have been a standard feature as of Java 16. Who's using Java 16 and up? >> And records? >> using records. I see some hands going down. So, for the record, you should be Um sorry, there will be bad puns as well. So, records are immutable transparent data carriers. Um and to show
you what that looks like, let me look for query with vector. So, here we have a class which is quite long, right? This is why people think Java is verbose. Uh but we can convert this to a record class and now it's much shorter. Um and if we use records, it will actually generate us the equal and hash codes etc. uh methods and the two string as
well. Uh that that means that you can't make bugs in your equals and hash codes methods, which is good, right? Uh unless you want to override them. So, in this case, instead of printing the entire what was it? A thousand >> Yeah, a thousand dimensions. Yeah, because how it works is just we maybe I'll show them to you. >> yeah, we forgot to show them. >> Uh
yeah, it was the Kibana to the right. So, uh we have them we index these 12 images into uh Elasticsearch that's running locally uh Mariet's machine, right? And how you can do that easily if you have Docker or something we can just go and elastic >> Start local. >> Thank you. Start local and that gives you this nice repository. This is not for production by any means,
right? But it gives you just one line of script like this. You run it, you paste it and you have like elastic search and Kibana running in your machine like this. So let me now just go and discover what we have here, what data. We have only one index, this catalog. It has 12 documents. Let's discover what's inside and let's open a random one like this one.
And it shows you that it has like the full name which is important, right? So your file name and also this vector embedding which is basically 1,000 1K floating point numbers, right? So this model understands the like puts the meaning in these numbers. Right? What do what do they mean? So >> Exactly. So we didn't want to print the thousand floating point numbers every time. So we
print only the first and the last. So if you want to override the two string method >> or any other method that generated yeah. >> You can. So you have the flexibility but you don't have to. So another thing that was introduced in Java 25 is module imports. >> But no tariffs, sorry. >> You had to really? >> Okay. So if we go all the way to
the start of the class >> There's a big list of imports. >> So we have quite some imports. What we could do instead is we can import module Java base which will import like the basic stuff that you need if you want to get started with um Java and then we can optimize imports. There's a shortcut for that but I always forget. So instead I'm using a
new feature which is called command completion which will give you all of the relevant commands right where you are in your editor. And we are currently using the EAP for the upcoming release uh where you can also just start typing uh the command that you want and apply >> I don't know this. Yeah. >> Yeah. So, if you're using uh the current version of IntelliJ, you can
use dot dot >> Yeah, the IDE >> get the the commands. So, if we um optimize our imports, we see that we have a lot less imports. If we prefer to have single class imports uh in case of your static uh analysis tooling prefers uh you can uh do that as well. >> So, this is great for prototyping, but this is also the default if you have
this uh compact file without class. If you If your file starts with just void main, right? Uh Java uh uh base module is imported by default. So, we don't need any imports for I don't know uh Java util list and such stuff. >> Right. So, if you're starting a prototype, you don't have to be hunting down the right uh imports even though, you know, your IDE can
do that for you, but it will save you uh some time. So, next on the list is stream gatherers. Uh wait, stream gatherers. >> Which are a standard future as of Java 24. And I know that you can talk about that for at least an hour because because you have Did Did you do that talk here? So, you can probably catch that on the YouTube. Uh but
can you recap it briefly this time for the audience today? >> Yes. Okay. So, who's using streams for data processing in Java? >> I mean, who's writing apps where you're basically moving data from A to B? >> Yeah, basically. >> Like all of us, right? Because the many applications are just about like shoveling pile of data from Sorry, data from one pile to another pile, right? And
the the thing with streams until Java 24 was we were able to create our own collector, right? But we weren't able to create our own intermediate operation. Think our own custom map or filter or something. So, when when the the ones that are already in the API aren't suitable for you, you you're just basically screwed, right? And then we have weird workarounds. And now we have like
this method which is called gather, and we can chain them, and this is basically custom intermediate operations. Yeah, there's Maybe there's a recording is even from here. I don't know. I would need to check. Let me just quickly show it in the code what can we do about this because this in my opinion one great collector which is sort of like undersold. And I guess it's it's
>> favorite features, right? >> Yeah. [laughter] So, now let me ask you, what is this code doing? In three, two, one. Exactly. So, let me >> ask AI. >> Yeah, we could ask AI, but we could also check the history for selection. So, in the beginning it looked like this, and it was using the parallel streams. And of course, like you can't use parallel streams in your
critical path because reasons, right? So, let me now sort of like roll it back this part. And now instead of having this parallel streams, instead of map, let me just go and say gather. Cool. And here we let's go for the undersold embedded one which is gatherers map concurrent. Let's say up to five workers, and then let me go to the end, close it. And the code
compiles. Let's see if it runs. >> Make sure it still runs, yes. [clears throat] >> Yeah. So, maybe instead of going for this like asking for the queries each and every time, let's let's just go for some predefined ones. So, we will be looking for orange apple Hexen Waschanlage. >> Bless you. >> Thank you. Computer and Jabuka. Who who speaks German? Wer spricht Deutsch? Okay, please don't
spoil it for the lovely people, okay? >> It's Do you want to explain Heckscheibenwaschanlage? >> I guess I have to. I owe it to the people. Okay, you have a car, okay? You have a rear window, and there's a lever by your uh steering wheel. The when you pull it, it just sprinkles some fluid on the rear window, okay? This is the device that sprinkles fluid on
the rear window, Heckscheibenwaschanlage. Um in German. >> Flashes. Uh Gesundheit. >> Uh danke dir. >> [laughter] >> Um yeah, so let's uh let's run it uh let's run this thing um and let's see if it works. Uh fingers crossed, yeah. Fingers crossed. >> It takes a while. Just to give me a small heads-up. >> because we're running this on CPU not on GPU and stuff. Okay, uh
sorry, wrong wrong window here. Um yeah, and as you can see, it gives us for Apple and uh Yabloko, it give us gives us somewhat different uh results. Uh why? Well, I mean, it understands that this is an Apple and understands this is an Apple, right? But somehow here is an Apple and it's missing here. Why? Because this one uh let me open it. >> expensive Apple.
>> Uh that's an expensive Apple. Let me open it uh and show you the image uh to prove uh >> Center. >> This Okay, because it's an Apple computer. Right? So, it Exactly, yeah. I loved you. Aha, yeah. So, it did the uh the like the classic match, right? Classic text search match because the Apple is in the file name. But it when we ask like in
in your own language about the content as well, then it understands it's something different. Right? So, as you can see, this is uh uh what I'm showing you is the uh Gina uh multimodal encoder. Gina is now part of Elastic and it does this great stuff uh especially for us Central Europeans. So, finally, it's not only English or Deutsch, right? It also speaks our languages, and I
would say pretty well. Uh yes. So, uh that's that. Um what it comes >> to show them stream gatherers. >> Yeah, uh so to to make sure it runs. Okay, yeah. But I I did this, right? I I have shown this to gatherers. Uh um Yeah, so now, as you can see Oh, one more thing. This is using under the hood virtual threads. Right? So, okay, maybe
streams aren't the best feature to just do do like the you know enrichment of your data, calling third-party services, but in theory, it's it's it's doable. How do we >> forgot to to ask them, do you think that the code is clearer now? Do you understand what's going on? >> In three two >> I see nodding up front. Thank you. Thank >> Exactly, that's the point, right?
Now, it's a data processing, not like a silly uh >> And the the code expresses what it does, which is what I like. You still read your code, right? >> Maybe. So, uh next we want to look at some preview features. Uh the first one That is not a preview feature. Anyway, so compact source files comes with some simple IO that we mentioned. >> Yeah, we must
have moved the slide, and that explains it. Okay, yeah. >> yeah, yeah. So, we have to fix the order of the slides. >> You fix the code. I asked them, "People who are learning Java, have you suffered from scanner when you had to type something from the keyboard with the scanner class?" And they are like, "Yeah, we did." Yeah. >> Yes, same. You know, with the stupid
>> Yeah. So, now the this like there's also this IO thingy from compact files, right? Comes with this IO, and now we IO read line or IO print line, which means no scanner. And Marit is demonstrating this. We have to flip >> Yes, except for if we have to flip it back. Um >> We flipped the slide, and that's why it ended up being here. >> Let
me run it again. So, let's look for orange, for example. I hope I wrote that correctly. Yes. So, then again, we find fruit apple apples. >> But, why fruit? >> Why fruit? the fruit image is an orange and it's orange. So there's that. >> Yeah, so if you need to read or write something to terminal it's not no no more system.out.println. I mean it still exists but
you can go just io.println. Yeah, more convenient. >> clearer and also it's overloaded so it can print to the to the console. >> So there's that and then we go to the preview features. One is a structured concurrency that I'm actually quite excited about. I like it a lot. It's in preview in Java 26. It will still be in preview with some minor changes in Java 27.
>> Yeah, Jonas. Mhm. >> But it will give us better idioms for multi-threaded code. As you'll see it makes it easier to understand what's going on. It actually expresses the synchronous way of thinking in ways that we can't currently in our Java code and it will help eliminate thread leaks and cancellation delays. >> Mhm. >> So where might you use structured concurrency? So you'll remember that we're
using hybrid search where we're firing off different search tasks and then combining the result. So anywhere where you have this pattern where you're firing off different tasks and then combining the results would be a good place to try structured concurrency in your code. So obviously we have that in our example so if we go to the execute search which >> Crawl it, please. >> Yes, so we
have the KNN search feature, the classic search feature and then we combine the results. >> And here's this part. Can I This is important, yes. This is this is this part which is often forgotten by like unexperienced junior developers or poor AI coding agents, right? It's the cancellation thing. So let's say in our business requirements we have the following one that we need to have both search
results in order to display something, right? So, we need to get we need to fire like classic search, we need to fire hybrid search, and then we get the results, we combine them using this RRF. The thing is, if one of them fails, right, the the the there's no point in waiting for the other. We can we can we could cancel or basically abandon this search hybrid
search all together. >> Exactly. If the requirement is that you want the results from both, then if one fails, you need to cancel it, and if the other fails, you need to cancel it. I mean, this is this is not the requirement of RRF or hybrid search. They're perfectly fine with with just one one like source of results. I just did it here because first I wanted
to show you the free version of elastic search feature, right? That's the reason. The second like we maybe strengthen this a little bit. Anyway, we have to cancel this. So, with two completable futures, right? >> Uh one has to cancel the other, and the other has to cancel the first, okay? With three completable futures, how many cancellations do we have? Anyone good at math? >> bank, insurance,
no? >> Come on. How many? Nine? No, wrong. >> Nine? >> Six. Who said six? Okay, you'll get extra strike. Exactly. With four, right, completable futures, what you can do basically is I say to you here >> Interpretive dance. Yes, thank you. >> Uh exactly. So, we want to get rid of >> Yes, let's do that. So, what we can do instead um >> is enable this
preview features and go for structured concurrency. >> Yes. So, you might think we have a live template for that, and we do. You can search the list of live templates. So, you can quickly scaffold structured concurrency and your structured cast task scope. Uh so, what happens is everything will be inside a scope. Let me correctly type a arrow. Uh let's assign that to a var. Um So,
one will be KNN and the other will be classic. And we can reuse the search methods that we have here. So, let me copy paste them. So, we'll perform the classic search and or the KNN search and the classic search and assign them to the right variables. Uh then we combine the results. Where do we do that? Here. Copy that. Uh after the join uh and if
you miss the join, then it will complain. Uh so, instead of arrays as list, let's use the very nice list of and get the result of KNN and of Uh then of course you don't have this in your code, right? >> I need to ask them >> to do. >> Have you ever seen in your code base a catch statement which says this has this comment will
not happen? Okay, on my behalf, you're free to put there system exit one. It won't happen. >> happen. And now we get to my favorite part of the demo, which is where we delete the I love deleting code. How about you? Meow. Anyway, so let's make sure that this still runs. or do we did we have the Yes. It takes so long on my machine. Every time
I have a small heart attack. so now we've written the same code that we had previously where it was multiple screens, but we see that we have one scope, we fork the tasks, we join them and combine the results. Is this much clearer to understand? And we don't have to cancel cancel the tasks because they will be cancelled when the when the scope runs >> With this
default, right? Because we can also have this other approach. For example, it's about, you know, like you go through the world, you see feature requests and you see patterns. If you have this pattern that the the task you have can be divided into smaller tasks, two or more, and they can happen at the same time concurrently, regardless the result, like all of them have to be like
successful. Or let's say you have to hit the cache and hit the database, right? And whatever response faster, you just happy with the first result you get. You don't wait you don't have to wait for the other one, right? This is great candidate for structured concurrency. The compiler is our great friend, right? It will help us if you forget about the going, for example, it it will
yell at you. If you try to leak this scope, it will yell at you, and so on. >> Exactly. And as mentioned, so by default it will have the wait all wait all successful or throw, but you can configure the structured task scope, so you could have a joiner method, like, you know, whichever one is first and then go. We can and add a name to our
scope, which I'm doing right now, so that when we run it through the debugger we get a thread dump we should be able to see our virtual thread here. And we also see our and the two threads that are running inside of it, the the classic search and the KNN search, right? So, the debugger also puts the structure in structured >> See, so it's not the only
the structure in code, but also structure in the runtime in the threads, which by default are virtual threads. So, that structured concurrency, I like it a lot. I hope it will land soon. >> But there's a bit more. What I love about this is that you can like go for variants of this open method, right? And you can toss this joiner config like Mary did, and you
can do other stuff. For example, you can change the time time out if the default is if it's not working for you. You can even go for a your custom thread factory. Let's say you want to have like a good old classic platform threads. That's also doable as well, right? So, you can configure it, and we'll see that pattern soon. This design pattern is somewhat unnamed yet,
right? >> Because naming things is hard. >> Yeah, naming is hard, yeah, as we know. >> Like our friend Dr. Venkat says, completable future has no future. And we agree. >> Right, so >> Also, custom memes for the win. >> Anyway, another feature we want to show you is lazy constants, which is also in preview in Java 26. And they are immutable, thread safe, and lazily evaluated.
So, instead of having final variables that are instantiated when you create the class, which will make it slower to instantiate, lazy constants are evaluated only when you use them. So, here we could replace our object mapper and our HTTP client with lazy constants. I'll do only and I'll remove the or I'll update the HTTP client to a lazy constant of HTTP client. lazy constant of takes a
supplier as you can see. So, we'll pass it a supplier. We can actually use the method reference. So, now we see that IntelliJ warns us that we have an error somewhere. So, if we go to the error, we need to first get the HTTP client because before we can do something. And that's when it's actually instantiated. So, >> Once this makes class loading faster, >> it's only
instantiated when you need it on demand. >> Exactly. Let's say you have two methods in your microservice. By the do you know the definition of microservice? Microservice is what the team that maintains the microservice can rewrite in 2 weeks. Okay? If it's longer than this, it's just a service. It's not microservice. Okay? So, it might be that when you like put your >> least it won't be
a monolith. >> I mean, module monolith bueno, I would say. Anyway, the thing is like with this object mapper, right? You put yet another instance, right? And then it makes the whole process faster and these things get initiated only when the first request hits, right? For example, right? And maybe that never even happens. See, so you're saving Yeah, so you can get it do or else or
check if it's initiated. Good stuff, I would say. One more thing, it's very important. You need to use them as final fields or class fields. If they're not final, you just, you know, throw >> You lose the benefits, yeah. Okay, so again, what does this slide >> Folks, do you like reading documentation? >> Who reads documentation? >> And not your agent. >> Only a few of you.
Okay, who actually writes the documentation? >> Even less. >> me. >> Yeah, folks, I have to tell you, reading documentation, okay, for like 2 hours can save you the whole week of coding. >> Yes, or the other way around, weeks of coding can save you days of reading, anyway. >> So, basically, there's this great addition to Java 23, which is markdown documentation comments because HTML is so
1999. >> Yes, so markdown is easier I mean, we are all writing markdown for our skills >> yes, exactly. >> Or having the agent do it. >> easier to write, and write. Uh there's a >> blog post by by Mala. Uh if you want to read more about it. Um >> we have in our operations class, we have uh documentation. That's if someone writes the documentation, of
course. Um which is nicely rendered in the IDE, >> And Javadoc tool will also render proper HTML pages, right? >> Yeah, so for our current code, we don't have documentation, but we can have um AI generated for you. So, no more excuses not to write documentation. >> But, it's the old format. It's not markdown. >> That's okay. >> We can easily >> me. Okay, that's actually sane
and and good use of AI, I would say. Uh yeah. >> And and nice quick fixes. >> No more excuses for no Javadocs, right? On public API. >> So, uh you know, renders nicely in the IDE, as well. Uh and then we want to stay up to date uh hopefully, we showed you some nice features of Java and why you might want to update your Java versions.
Uh but, you also want to stay up to date with the ecosystem. Uh other uh tool libraries and frameworks that you're using are updating their baseline versions. So, who's using Spring? Like looks like about half of you. So, Spring uh is now using Java 17 as their baseline. The upcoming, hopefully, Maven 4 will require Java 17 to run. Uh and other libraries and frameworks are also updating
their baseline. That means if you want to go to the latest versions of those libraries and frameworks, you have to go to the latest versions or newer versions of Java as well. Um >> Yeah, but it also requires like you know with this lambda configurer what we what do we call for for structured concurrency that we start thinking in new ways. We abandon old ways of thinking
and all design patterns and we adopt new ones and I have a great example to show you about that and it's the new client new Java client of Elastic Search. So this is the old way. I'm sorry. I I hope I won't get rift because of this this is the old way because you know of this string concatenation and so on and you build the intermediate objects
and I think >> It's all of the the boiler plate >> Yeah, exactly the ceremony >> to do anymore. >> is is killing me softly. Exactly. So what I'll try to do instead is go for the I bumped the the dependency. Let's me go to Elastic Search off. Right, let's close it here and open this here. Let's create a variable, call it ES client and now I'm
able to configure it just as the structured concurrency fun fact these things happened independently. So I can go and say the toss the the host. Right, I can also toss the API key. And for the >> Please don't hardcode your API keys. >> Like never ever, okay? >> Did you all read that story about the AI agent that found an API key somewhere and then used that
for stuff it wasn't supposed to do and deleted the production database? I guess that AI I guess that AI agent is now a senior developer for having deleted the production database. >> Uh maybe. Let me now try to do your thing which is let me try to delete >> It's the best. >> see and now it is way more concise, and I would say it's only like
the the the the the uh message to signal is absolutely great because you just configure host, you just configure API key, and everything is done uh under the hood, right? Uh we shall also do the same for the test. Time for my favorite uh shortcut, command shift T, which opens the the tests uh right? And here the list was even or is that still even longer because
uh I have the Elasticsearch uh container container, so it has custom uh SSL certificate or TLS certificate. I have to like do a lot >> Configurations for the test. >> Uh we have this pre-prepar >> Custom live template to save you a bunch >> you get to do the favorite part, which is deleting >> Delete. Uh even this. Haha. Lovely. Uh see, and again >> Shorter. >>
Yeah, just tossing host, uh username and password in this case, and and SSL context, and that's it. Uh right? So, this this this new way, it's not What I want to say it's not just bumping the numbers in the pom.xml or or build.gradle, right? It's >> Also updating the idioms and the how we use the language. >> Uh yeah, in our heads. Uh left. So, with that
Oh, yeah. Quickly >> have quickly uh pattern matching with primitive types. So, uh this is also still in preview in Java 26 and will be again in Java 27. Uh but it will allow all primitive types in pattern context like uh instance of and switch. Uh which means that if you have these long if else if else if else if else where previously you couldn't use a
switch uh statement, now you can. And also you can use multiple cases that might lead to the same result. Uh and you can use guard clauses, uh and uh it will make sure that it's exhaustive. So, if you're missing the default, it will actually Uh so, that's just a nice thing. So, please know the difference between uh the if statement and the switch case. I thank you
very much. Uh which brings us to our next demo with the gold dragon. Please explain them the >> Do you know the gold dragon in this Do you recognize the gold dragon in this picture? I bet you have them in your company. So, the golden dragon is this creature that keeps all the gold, sorry, pictures. Uh that it keeps all the gold and you need to give
the the dragon a nice and shiny piece of machinery doing something useful so they can toss you some gold on modernizing it, okay? >> Yeah, because we looked at all of the things that make the language nice for us as developers to use. Hopefully, you work somewhere where they care about developer experience. But, you might need some arguments to convince the people hoarding the budget to let
you upgrade to later Java versions. So, we hope to give you some ammunition for that discussion. >> Using the vector API. >> API, which is still incubator and will be in Java 27. It's like bold and beautiful. This will be in incubator >> so many seasons. It will be 11 or 12, I think. >> Something, but there are good reasons for it. Okay. we have a demo.
Can you please run the demo? This is operations demo. Let's see how fast it can run. >> not >> filing? yeah, organize the imports, sorry. Uh optimize, I would say. Optimize system organize, sorry. >> Uh that's okay. Operations, so let's >> Run it. >> Run the operations. >> And show them the result. >> Some of the implementations are way faster. >> But, I'll show you why. >>
It's because it's not doing anything. It's not doing anything super fast. So, I'm also efficient at doing nothing. >> See, I suck at doing nothing. [laughter] >> Uh yeah, so how about like okay, question is who knows the of Victor API by heart? >> And can help us implement this? Giggling, okay. >> There was one guy one conference ago. I swear it. Again, so >> So instead
we'll have our lovely intern turn as our friend Kuba calls them or AI assistant so we can use different agents from IntelliJ IDEA and different models. Should we go with Juni today? Let's see how that works. Um, yes. So we'll ask Juni to implement these functions for us but in the meantime maybe you can explain to them what it's doing. >> I will do it just quickly
over here. You see we have the interface of math ops and it has two implementations. One is the scalar op scalar ops and the scalar and the other is the vector. And now why it is why is that? So no graphic designers uh >> Or harmed in the making of this. No graphic designers were used. >> I made it myself. So let's say you have this task
that there are two arrays of integers array A and array B and the task is the following. Take the first elements from here and from here, add them up, summarize them and store in array C let's say this one. So how do we do this? Intuitively we just go for some form of for each loop, right? We just iterate through just take nth element here and element
here, sum them up and store the nth result. you can check maybe what it says. The thing is let me ask you this question. What is the size of integer in Java in bits? 32. Very good. We have math expert here. You'll get extra swag. Okay. [laughter] And what's the size of the registers of your CPU? It depends on your CPU. Let's say yeah, if even like
cheap desktop machines like these have 128 bits, which means in such a register you can squeeze four integers right one after another. So if you put if we put just one, we're wasting three quarters of this register, right? So how about instead of using like just one quarter, we put four integers, right? Like this exactly. And no, thank you. Yes. And then we have one CPU instruction
not like here. So we had like four CPU instructions, right? So of course it won't be four times faster because there is still like you know, we have to load this from memory. This this CPU instructions probably more cycles and so on, right? But the thing is it will be faster. It wasting this. And fun fact, if your registers are longer, let's say 256 bytes or 512,
it will put accordingly more integers, right? G G will do this for us. It will recognize at runtime, hey, this is the register size I have. So how about using more Yeah, let's let's So we see that the speed up is about one and a half. But we can do better. I think we can do better. Use mall Yeah, and it's because there are also I mean
this vector API comes like in different shapes and it it abstracts to certain degree the CPU architecture you have, but it helps to know it. For example, when we run it on Mac, right? We can prompt it that use certain kinds of operations or methods instead of other other ones and >> Yeah, so it will the vector API is so that you can write the Java code
and it will generate the native code for you. But the proper native code does matter on what you're running it on. So you do have to know how to implement it and now we see that by using a different part of the vector API we're speeding up twice as much instead of one and a half times. >> Yeah, exactly. So the dot product dot product got twice
as fast on this like M1 machine if I'm not mistaken, Addition time is roughly the same and Euclidean norm is also twice as fast and why these operations? Because they are used under the hood for example by elastic search and Lucene to calculate vector distance to find for example these matching images for your prompt, this is this API to express vector computations and >> will have different
performance characteristics on different hardware as we've told you. Also you can't do badly at a benchmark if you create your own. So this was another proper benchmark. This was us playing around and just illustrating that it can be faster. >> And now like people like say because if chances are if you are running the latest elastic search in production, right? You are also running the latest Java
which is Java 26. Why? When when a new version of elastic search is released in this docker image that has everything, it's also shipped with the latest open JDK for example this improvements from this vector API but also other other things. So uh >> Because you're actually using the the vector API in elastic search, right? >> Also for ES QL which is this new programming language sorry
query language which stands for elastic search pipe >> query language. It's like a offspring of bash and sequel. Anyway, as you can see it it tells it's going to be used Java 26 and it enables this incubator module. Even though it's incubating, it's already so useful. So maybe if you are crunching a lot of numbers it may be useful for you, too. And there are other things,
right? Like this run your stuff on latest JDK and for example with you enable compact headers, right? In Java 27 G1 garbage collector will be the default for like every scenario. So yeah. >> Yep. So even the runtime is faster if you upgrade your your JDK. So even without updating the language features >> and the recompiling the jars >> it will get faster. So that saves cycles,
that saves money. That's how you convince the gold dragons, right? So we played with a bunch of features. We hope you like them, too. Each new Java version is easier, faster, better >> scooter. Okay, sorry. >> every time. And guess what? It's still free. >> I need to ask this question. >> So why not use it? >> Who's using LTS versions because they are LTS? Okay. Who's
paying for support? >> All hands went down. >> Again exactly. Do you know >> the S in LTS stands for? >> Support. >> Support. So if you're not paying for the support, you don't have to stick to LTS >> Because you don't get the support. >> So you have to bump your Java version, let's say in your in your docker files and and so on every quarter
because security fixes, time zone changes and so on. So why not bump it to like 26 or 27, right? Maybe not the 000. >> just yet. >> Yeah, but 27 or >> already try that out. You can even download it from inside IntelliJ IDEA if you want. >> So with all of the features, you know Java is still not dead. We're quickly skip past this because we're
running out of time. If you want to let us know what you thought about this talk, uh you can use the QR code on the left. Um >> And if you have also great dad jokes >> to that that will open a form that will go to us. So, if you have any good dad jokes or mom jokes, uh you can share them with us there. >>
Try jokes. In Poland, they say try jokes. >> Do you know how a joke becomes uh a dad joke? >> Uh when it becomes apparent. >> Yes. Thank you. Uh the QR code on the right will take you to my website, and that will have uh all of the relevant information about this talk, lots of links, uh previous recordings. Slides will be uploaded shortly. Um so, with
that, we hope that you were entertained and or learned something. >> Bog >> Please come for the extra swag, you >> And if you have more questions to ask, we'll be here for until lunch. >> Yes. But unfortunately, we have to go. >> Thanks for having us. >> Have a great conference, folks. >> [music]
More from this event
See all 29 talks →
Agents With Seatbelts: Practical Ways to Keep AI Code Gen Under Control, Jonathan Vila López
41:46
Practical MCP Security in Action, Willem Jan Glerum
43:59
Kotlin for Normal Brains (Without Jets), Nayden Gochev
59:30
Beyond the LLM API - What Developers Actually Need to Know About ML, Milen Dyankov
54:58