Foojay Podcast #45: Welcome to Java 22
JavaJava Beginner

Foojay Podcast #45: Welcome to Java 22

Last September, we got Java 21, a Long Term Support (LTS) version with eight new big features and seven incubator or preview features.

Does Java 22 also bring that much innovation, or is it just a bug-fix release?

And what needs to be done to get such a release published on time? Let’s find out…

Video

Podcast Apps

You can listen and subscribe to the Foojay Podcast on:

Speakers

Loïc Mathieu

Simon Ritter

Podcast Host: Frank Delporte

Content

00:00 Introduction of the topic and guests

00:52 Highlights of Java 22

01:43 How the 6-month release cycle is achieved

04:14 How to follow changes in OpenJDK

07:43 New features (JEPs) in Java 22

08:33 JEP 423: Region Pinning for G1

10:37 JEP 454: Foreign Function & Memory API

15:43 JEP 456: Unnamed Variables & Patterns

20:33 JEP 458: Launch Multi-File Source-Code Programs

24:15 Incubator and preview features

25:00 JEP 461: Stream Gatherers (Preview)

28:53 JEP 447: Statements before super(…) (Preview)

32:02 JEP 460: Vector API (Seventh Incubator)

35:29 Difference between incubator and preview feature

36:53 Who decides what will be in Java 23?

37:28 JEPs grouped per project

38:47 How Loïc creates his blog posts about new Java features

41:54 Over 3000 Jira issues handled in Java 22

42:32 Should we update all our production runtimes?

47:10 JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview)

49:38 JEP 462: Structured Concurrency (Second Preview)

52:10 Conclusion

Music

Transcript

Automatically generated from the audio, so it can contain errors in names and technical terms. Suggest a correction.

[0:00] Right on schedule Java 22 is available on the 19th of March let’s discuss what this new version brings welcome to the f j podcast all your news about OpenJDK last September we got Java 21 a long-term support version with eight new big features and seven incubator or preview features does Java 22 also bring that much Innovation or is it just a bug fix release and what needs to be done to get such a release published on time let’s find out with these guests hi I’m Simon R I’m the deputy CTO at Azor hi I’m L matchu I’m a software engineer atra thank you both welcome in this podcast I’m Frank Lor creator of the Foojay podcast before we dive into the details are you excited about Java 22 yeah I’m not sure excited would be the right word but I think it’s an interesting release which has a number of new features which will be of benefit to developers but I guess obviously because it’s not a long-term support release adoption is going to be a little bit lower than like JDK 21 yes at first I was thinking that Java 22 will be a stabilization release but in fact there is a lot of interesting

[1:25] New new functionality in it so yes I think it’s very interesting release but as Simon said usually the release that are not longterm support less used in the community so we will see now the releases are very punctual they’re very on schedule more punctual than the Belgian trains I would say H how this is achieved who is driving this is this the community how does this project keep on track and keeps following the schedule of the six-month releases well this is something that changed with jdk9 because prior to jdk9 we had a feature-based release schedule and the idea was that the developers the OpenJDK would come up with a list of features that they wanted to add to the next version of java and then they would work their way through that and only when all those features were ready would they make a release and if you look at pre jdk9 what you’ll find is that we had anywhere between a little over 2 years and almost well over four years between releases so the JDK 6 to jdk7 was over four years between releases so they had to delay potentially the release

[2:43] Because a feature wasn’t quite ready what they did from jdk9 was move from that feature based release schedule to a Time based release schedule so it will come out on specific dat in March and September and only what is ready will be included and if the thing isn’t quite ready rather than delaying the releasee they delay the feature to the next release and again because it’s only six months it doesn’t really make that much of a difference so it’s it’s a much more controlled way of doing things so I guess there’s a bit more pressure when we reach a long-term support version and some features should really be included then now for instance with the 22 release well no you see that’s one of the things that there’s a bit of a misunderstanding and certainly if you ask the OpenJDK developers and people from Oracle they they’ll be very clear about this which is that although the LTS releases are considered you know the ones which have extended maintenance and extended support all of the other versions are also quite available quite useful in terms of deployment there’s no reason why you can’t use JDK 22 in

[3:51] Production it’s not like a sort of intermediate Beta release or anything like that it it’s all about being able to use those releases if you want to in production but obviously the LTS ones are the ones that typically people will rely on so we do need to be careful about thinking about features going into an LTS release versus a non-lts release so people can see on OpenJDK needs to be done how should people follow Evolutions in OpenJDK should they be on the jira of the project or should it be on the mailing list or just keep an eye on OpenJDK or follow on Foojay or this podcast what is the best way to know what’s happening there personally I use the multiple source of update around OPD key I have follow some mailing list not the one you talk about but the open mailing list are really high high number of messages so it’s not very easy to follow them but I really appreciate the Ming list because the project is really shaping the future of java it’s very interesting to follow the discussion here I try to follow the car Dev mailing list

[5:23] This is the main mailing list about development inside the GDK but it’s really too there is really too many messages for me the best way to follow open GDK if you are not actively working on op GDK but want to know what go going on the Java language is to follow some people working on it because they usually tweet if if you follow them on Twitter or on other social media to listen to some podcast for example Foojay podcast but in France we have other podcast and also inside Java is very interesting unfortunately I don’t know why there they didn’t have a Twitter account where they post the messages they add in their blog in their website I found it more easier to follow people that talks about open GDK than directly follow a mailing list yeah I agree I mean very much the Amber mailing list is great because that obviously tracks the new features being developed and proposed for the language specifically I also follow the JDK dev and the JDK discuss aliases because they’re not too high traffic

[6:55] I mean I again I agree that some of the aliases can be very high traffic and trying to work your way through all of the discussions is like a full-time job and I think the other thing that I would always come back to is if you go to the OpenJDK website you’ll find that for each version of java there’s a page for the project and that will give you details about the schedule as in you know when the lockdown is happening when the release is coming out and so on but it also lists all the jeets which are proposed to include on that so you’ve got a clear list of the things that are actually going to be in that release and that will be added to over the six months of development so that that’s always a good way of doing that and obviously jeets are the way that we propose and include new features into Java at the moment and that brings us perfectly back to Java 22 release because I will add to the show notes a link to project JDK 22 which is the one being released this week when we publish this podcast and I see there are four jeps as new features and one the eight

[8:03] Jeps even are preview and incubator features how should we handle these in this podcast so I think the four which are really new features are the important ones so it’s a region pinning for the garbage collector forign function and memory API unnamed variables and patterns and loue multifile source code programs anything you want to say about one of these or all of them well I could talk about all them perfect go ahead yeah I mean region pinning for G1 is a fairly sort of small thing it’s designed to reduce latency associated with the garbage collector and it when I say it’s a fairly small thing it more relates to when you’re using jni because jni is obviously for interacting with systems outside of the JVM and that can have an impact on the way that the garbage collector works because of the fact that some pieces of memory can be shared through jni I and G1 has to make a decision about how to treat that because you can’t relocate objects in the Heap whilst jni thinks they are in a particular place because then you’ve got a dis you know disturbance between

[9:14] The two so it’s a fairly small thing because if you’re not using jni it won’t have any impact on your code so that’s that’s region paining for G1 it’s always good to know that the open GDK Team continue to improve the garbage collector because for a developer point of view having a garbage collector is really great because you just don’t care about your allocations so that’s that’s the only thing I love is this kind of changes that it allows me as a developer to not take care of memory because garbage collectors keep keep improving over time and not only the last kutting age garbage collector because there is a lot of garbage collectors inside the DDM but also all garbage collector if you if we can say that G1 it’s starting to get a little hold by the way I will also add to the show notes a link to blog post I wrote about all the different garbage collectors because indeed there are a lot of them and you’re definely right that they are further maintained and have specific use cases also some better than others some better than others and

[10:28] Some companies even have others like aul so yeah it’s a long list of garbage collectors totally right okay the next one is foreign function and memory API JEP 454 what can you tell about that one this one is interesting because we usually said that to attain the last last bit of performance of a program better to write it in C and there is a lot of languages that basically are using C libraries to offer a good performance Java and the have a good performance thanks to Jet and garbage collector that are very efficient but there is still some some some time that you want to access for Library there is still usage in Native libraries and this chap is all about providing a better interconnection with foreign languages and it’s it’s good that Java can still be on the ede of interconnection with foreign foreign language for the for memory it’s just yeah being able to easily access foring memory it’s linked to the fing Library also so it’s it’s the these two new API yeah it’s great that there are no finalized I

[12:07] Think this is what’s most important yeah because the whole Forum function and memory API is part of a larger project called panar and Panama is all about replacing jni so it kind of comes back to what we were talking about on the G1 side of things and as as we said you know it’s the idea of being able to interact with foreign libraries and for a memory so sort of two distinct things here first is if we look at the memory side of things that’s because we need some replacement for things like sunis unsafe some of the functionality that gets used in there so that we can still get access to Native memory without having to go through the undocumented unsupported API of unsafe I mean there are other things that unsafe does as well but there’s some of that functionality that’s being replicated here in a standard API the other thing is the foreign function API Pi which is obviously to enable you to access libraries which are written in other languages this is quite an interesting thing because I remember that as as a replacement for jni you think well why do we need to replace jni but if you’ve

[13:11] Ever used jni you’ll know why we need a replacement because it’s it’s a difficult to use sort of interface and I remember when I worked at Sun using jni and then thinking oh this is really hard work you know I’ve got to like generate my header files I’ve got to generate my stub I’ve got to make sure I get my library Linked In the right way and all of that sort of thing and I remember talking to one of the developers of J and I at the time and saying this is really quite hard to use and he said yes we designed it that way I was like what it was like to discourage people from using it so I think the idea of having a more formal easier way of doing things is very interesting one sort of small note on this that I will say was that one of the most useful tools in this is a thing called J extract and what that allows you to do is to sort of generate the necessary interfaces and so on for an external library in a very simple and straightforward way but interestingly it’s not been included in the JDK so you have to do it as a separate tool and I did kind of question this with I think it actually was

[14:18] Brian gz I asked about this and he said that actually the problem is it’s quite big and when we look at the size of the JDK they don’t want to add sort of bloat to the JDK and that makes perfect sense to me because there aren’t going to be a lot of people that use J extract so they’re keeping it as an external tool rather than bundling it with the JDK so it’s just interesting in that kind of respect so yeah that’s kind of the for function of memory API used to be two separate things and then they kind of brought it together in one am I correct that I’ve seen a lot of talk about this related to AI machine learning Lang chain for J that they want to make it use of this these improvements yeah yes absolutely I that’s one of the main sort of uses I would expect to see of this is the linking to those machine learning you know llm type libraries is going to be a big thing for Panama yes there is also one thing that brings this new jet is that you canot directly access the standard library from java there is no need to use a GX trct for example because it’s already integrated into the GD key so which

[15:28] Brings new capability it’s it’s cool for example if you want to have time stand in microc you can have it easily which is not possible with plain Java okay the next JP is I think 456 more about developer improvements and making code more readable and that’s unnamed variables patterns I think we’re going to see a lot of underscores correct yes so it’s underscore forbidden keyword for some releases now and it allows using underscore as name and use the variables and the pattern in case of pattern matching for example in a switch or even in variable names in a method I think if you call method yeah and you don’t need that variable you can still have the underscore there something like I’m a little disappointing is that you can choose underscore when you override a method for example to say that this parameter is not using ofden meod which is something that is quite usual you know maybe for next phase yes because this is one of those get little interesting sort of pieces of information because prior to jdk9 you could use a single underscore

[16:51] As a variable name if you really wanted to you could from jdk9 it became the reserved word the single underscore so you couldn’t use it as a variable name anymore however the good news is that if you want to use two or more underscores that will still work as variable name so you can replace your single underscore with a double underscore or more and the reason they made a single underscore into a reserve word is because they wanted to use it in the future initially the idea behind this was to actually for Lambda Expressions where if you had a Lambda expression and the number of parameters that you had there you didn’t need all the parameters on the right hand side of the arrow operator then you could effectively say I don’t care about this but I need to indicate that there is a variable there and I’ll use an underscore to match the signature of the method and then not bother using it on the other side so they haven’t actually implemented that yet but what they have done is allow you to use that in the U record patents so the deconstruction pattern and various other places as well

[17:55] But take the record pattern as an example if you’ve got a record pattern you want to do deconstruction on that I’ve got a good example in one of the presentations I’ve done where you can actually have a number of Records sort of embedded in each other and when you get into the situation where you’re taking one particular variable out of an embedded record then it becomes very complicated because you’ve got all these variables involved and even if you switch to using VAR to hide the types of those variables it still gets quite unwieldy so by using a single underscore you don’t have to have any kind of type information any variable information and it does make it much more clear and readable as to what it is you actually want from that deconstruction in the body of what you’re going to where you’re going to use it and you can use it in the patent matching for switch as well so if you’ve got a variable that you don’t need on the other side of the switch because you’re just doing a print statement or something you can use in that kind of place as well you just mentioned very briefly

[18:53] They reserved it in Java 9 because they thought of using it in a different way later so now we are in 22 and now it becomes so that really shows that there is a big master plan behind Java am I correct or was it just yeah one day we will use it but or were they really convinced we will need this later if you want to do this well it like as I say the initial reason for making a reserved word in jdk9 was because they wanted to use it in Lambda expressions and so Lambda Expressions came in jdk8 there was a piece of functionality that they created which was called Lambda leftovers and there were a number of different pieces that they wanted to include to sort of move lambdas forward a little bit and take off some of the rough edges again sort of project Amber style interestingly this was one of the ones that they had planned for in that but they’ve never actually implemented it and so when they came to do the pattern with this idea of unused variables in patterns it was very easy because they’d already done the work back in jdk9 to make this available so they could do it that way in fact and

[20:02] This is what is interesting when you read the list is that there is a lot of functionality they want to add to the ja language but there they need to prioritize them and using underscore as un variables they think about it since multiple years but I they start working on it only recently because there is more there is yeah there is some other features that appears to be more more urgent to do then we have the fourth new feature which is JEP 45h launch multifile source code programs so I know since I think Java 11 you can just execute a file. Java and actually Java compiles it and then runs it executes it but now you can do that with multi files what is the IDE behind this is the part of a again bigger sort of project which is to make Java more approachable so for people who haven’t written Java before the amount of what they describe as ceremony is very heavily involved there there’s a lot of it and so this is one of the things that they did as you said back in jdk11 they introduced this idea that rather than having to create a Java file which had your source code in

[21:21] It and then run Java C to compile that file and then run Java with the JVM to actually execute that file will make it a little bit simpler and take out one of those steps so that you can simply write your Java in a source code file and then execute that which allows the underlying JDK to say right we’ll compile that and then run it so it’s really just taking out a small step and in fact when we come back a little bit later on we will talk about one of the sort of new features which is still in preview which is jet 463 about implicitly declared classes and instance main methods which is also related to this but the idea behind Jeet 458 which is launch multifile source code programs is extending that idea of taking a single source code which allows you to then have the compiler run automatically and then execute and do that for multiple files it was a limitation that was on the initial way of doing this is you could only do it for one file you could bring in you could add things to your class path as compiled code but now what you can do is you can have several files which

[22:29] Contain different classes and you can do it that way and then you can still run that and have the compiler do that MH I do love to use jbang for projects like this where you run something very briefly I think main difference is that you still cannot Define dependencies no with just Java and you can do that with there are still limitations on this as I say the big thing here is it’s trying to make it easier for people who are starting out with the language so it’s not designed for complex situations as you say I mean jbang is a good example of how you can do things for sort of prototyping jshell is another approach for making life simpler if you just want to test a piece of code in isolation I always do it in jshell just to make my life easier but yeah yeah and what what’s interesting is that it compiles in memory what’s needed so you can have a bunch of java FES and it will not compile everything it will just compile what’s need it and I think the idea also is to say you can start simple and start to complexify your program without needing to add too much complication it’s just to be

[23:43] Able able to evolve your program step by step you know continue to don’t need don’t don’t run a compilation step if you don’t need it because Java doesn’t have a butin dependency system like you said but doesn’t have neither a buil-in buil system you know you need to call Java before launching there is nothing that do it automatically for you so this is really being able to evolve your program step by step okay so this concludes all the new features there are four new of course there are also bug fixes I guess and other small improvements which are outside of the Jets but we also have eight preview and incubator features so for people who are new to this so these are included in release but you need to use an extra flag to use them when you compile your code or execute your application you mentioned one JEP 463 which is removing some of the ceremony around the main method and stuff like that which are the important other ones that we should know of all of them stream gatherer for sure stream gatherers is really are the biggest new features of this Java version

[25:10] It’s it allows to have to add maory steps in a stream processing in a stream byeline today the stream API that was added in Java 8 as a buil-in step you know you use map you use filter and there is one terminal operation for example collect or for and for the terminal operation you can enhance the stream API with your own terminal operation because collect allows to you to create multiple collectors but if you want to en end the stream API with intermediate operation you cannot and this is what Str gatherers bring us is a way to end the stream API with custom intermediate operation what interesting that when they add the stream gatherer capability they also add new intermediate operation so this allows to so we know as B map conference scan window fixed window sliding intermediate operation that are new in this video so they brings both capability for us as developers to add new intermediate operation and they brings new intermediate operation into gtk yeah I absolutely agree stream gatherers is a very interesting new feature as you say

[26:47] It’s it’s about enhancing the ability to sort of add more intermediate operations and Define your own ones so yes it does provide us with a lot more sort of possibility because the thing with the stream API is that obviously we’ve got a rich set of intermediate operations but people are always coming up with new ideas for things that they could include and if we added all of those to the standard API it would become completely unwieldy so and you’d find that a lot of those would be very kind of Niche and only apply in a very small number of situations so by making it flexible that you can Define your own it really adds that power so you just say okay well if I don’t have exactly what I need in terms of those intermediate operations I can create my own use it for my code and then yeah sure if I want to make it available I can you know publish it as a library but most of the time you just go right I do what I need to do in my code and I get exactly what I need out of that so it’s it’s a very good addition to the streams API so it’s making the streams even better and I have to

[27:46] Say that is the most important change in Java for me as when I do development to produce clean code readable code I think streams are crucial in the Java that we know today it’s fascinating isn’t it because it’s the whole idea of adding a functional style of programming to you know an object-oriented language and I have to say you know I I’m always a very big fan of people like Brian gz and Stuart marks and the people who kind of worked on this I have to say I really think they’ve done a fantastic job of adding that functional style of programming to the language without making it overly difficult without breaking things without kind of changing things in a very strange and unfamiliar way so they’ve done a fantastic job of adding that and as you say you know loads of people that really kind of made jdk8 very appealing as a new platform because of the inclusion of streams and Lambda Expressions so we could do all of these things and this is just making it that little bit better more flexible another one preview feature is Jeb 447 statements before super that’s really I think for a lot of

[29:00] Developers a big change that you can put something before Super Why is this needed it’s not needed it’s again a new capacity so before you cannot do anything in a Constructor before calling the super Constructor so this leads sometimes to situation where you call the super Constructor then you for example do some check on the parameter of your Constructor and for example through an exception because you validate the parameter and validation didn’t pass in this case you could have done a potion potentially un necessary work in the per Constructor but also this sometimes prevent reusing a super Constructor because there is a something that you need to do before calling it and it’s not possible so the this allow more flexible Constructor implementation yes it’s it’s one of those things you think to yourself well okay Java is going to be 30 years old next year so we’re actually coming up to 29 years of java and we haven’t had the capability of putting code before super calls up until now so it’s not something that has been absolutely desperate for the

[30:26] Language but it is something which is there are plenty of cases where it would just be really nice if you could do that you need to read the jet carefully because there are quite a few restrictions on what you can and can’t do in terms of using that so you can’t just simply you add whatever code you want before the call to the super Constructor so you do have to look carefully at what you’re doing so that you’re not stepping outside the rules because there’s there’s a lot of the way that the JVM builds objects and the fact you’ve got super classes that need to be populated in terms of instance fields and so on you do need to be careful about how that works but yes it for certain situations this is going to make life again it’s just taking those rough rough edges off the language which is what project Amber is all about and that’s just one of those things where they they’ included this feature and said y you know we know that there are situations where people would like to be able to do this we will add that feature okay but again I’m just going to make

[31:23] One more point about that which is again they’ve done it in a really good way because it’s backwardly compatible doesn’t break an existing code everything still works in exactly the same way which is key factor for Java yes and during the development of the this CHP they also add new warning in the comper to detect misusage of Constructors and it’s very interesting also because it will catch up more implementation issue when especially when you Escape inside the Constructor the instance being constructed Simon you’re my returning guest for this podcast about Java releases if I remember correctly last time 21 you said the vector API could be a release in the next one but I see it’s in the list of the previews no it’s a seventh incubator yes right and I got to say that this is now the record holder in terms of how many it’s been through incubator and preview because what let me just check Vector it is an incubator yes right subtle distinction between incubator on a preview feature so yes it’s still an incubator and they’re still

[32:41] Working through things but there wasn’t really that many changes there’s only one minor change that they made between what was in JDK 22 and sorry JDK 21 and JDK 22 which is where you’re using a memory segment the backing store that you have behind that in previous releases it was had to be an array of bytes and now you can use any primitive that you want in terms of that backing store so it’s it’s a fairly sort of I’d say it’s a little bit esoteric in terms of the change but it will be useful for certain people yeah the vector API is one of those things which it’s an interesting approach what they’re trying to do is help people to get better performance for numerically intensive code and it allows you to tap into the ability to use the single instruction multiple data features that are common across you know any modern processor so your vector which is a very wide register you can then populate that with a number of elements for an array and you can have the same operation appli to all of those elements in a single clock cycle which is very very good the thing is that when

[33:52] You look at this in a bit of detail what you’ll find is that there are you’re not going to use this in every situation and the reason I say that is because the compiler the jit compiler already knows about single instruction multiple data Vector operations so it will apply Vector operations where it can and there’s lots of situations where it does that if you’re using a simple Loop and you start to you know do things in that where you’ve got processing an array and you’re doing the same operation on that what you’ll find in terms of the code that’s generated by the jit compiler is it will use those those Vector operations so you won’t get any benefit from writing IIT code using the vector API to do that the situations where it will become useful is where the compiler can’t recognize the situation as one and it can apply Vector operations to typically that’s anywhere where you start using a conditional so if you’ve got an if where you do a branch based on what you’re trying to process then that’s where the compiler starts losing the ability to apply Vector operations to that there’s

[34:55] Some interesting writeups on this if you look at various blog posts that people have written they’ve done sort of analysis on the performance of using the standard jit compiler versus the vector API and for simple situations you’ll find that it the jit compiler will perform just as well as the vector API so it’s for those more complex operations that this will be much more valuable How we’ll get to the you know hopefully we’ll get to the final version fairly soon yeah hopefully it’ll be JDK 23 but I it’s not in the list yet there’s only one in the list it’s now an incubator does it mean it still has to become a preview feature be before it can be part of the next release no this is where things get a little bit complicated so incubator modules are for Library features and the some of the distinctions are really quite subtle and I don’t even actually understand that myself because my thought was that incubator modules apply to libraries so apis preview features apply to language features but preview features can also apply to apis if they’re part of

[36:07] The core classes which relate to a language feature so if there’s an API that needs to be included as part of that language feature then that would be part of the preview feature but there are some some more subtle distinctions and I know that things that I thought would have been an incubator have been made a preview feature and I thought not quite sure why that’s preview feature rather than incubator Jeep 11 and Jeep 12 I believe are the two jeets that describe preview features and incubator modules specifically and one thing I will say is that this is another benefit of the six-month release cycle is that we can do this we couldn’t have done this with two three four years between releases with only six months we can have preview features and then move the forward and then finally make them finally make them part of the spec you mentioned briefly Java 23 so September there’s only one Jeet yet defined to be there who decides this and when will we know what will be in 23 it’s people high up in the OpenJDK so you’ve got Mark Reinhold who’s the chief architect of the OpenJDK he will obviously have

[37:10] Input on that you got Brian gz who’s the Chief Architect of the Java language who will also have input on that and there are other people involved as well like John Rose who covers the JPM side of things so there’s a number of people within the OpenJDK who are the top level people make those kind of decisions I found a nice overview of all the jeets which are now in 22 that you can also group them by project so you mentioned already project Amber we have project glom we have project Panama we’ll also include links to each of these projects so for instance project Amber is oriented to productivity make Java more developer friendly readable code stuff like that so these projects they live for a very long time correctly because they have Jabs in nearly every release for the last years it depends if your project is a large project like for example project number maybe it will never die it will never end and some project are more narrowed and so that ends when the features are integrating into the GDK so it’s really depends yes because because the jeets JDK enhancement

[38:20] Proposals are specifically designed to be smaller pieces of work so it’s sort of like a three month kind of well ideally three month yeah three Monon kind of time frame for development of those those Japs whereas the projects like Lum and Panama and Valhalla valhalla’s you know one of those ones that’s been going on for a long time are much more overreaching longer planning kind of thing multi-year L already early January you posted a detailed blog post about the new features which are in Java 22 you give examples for that will also of course include the link to that blog post you’ve written a similar blog post for all the previous releases so when do you decide now I know enough to start with it I start working those articles for Java 9 because at this time I was very yeah very there was a lot of changes in Java 9 and javine also starts to work with the so at the Javan withas time they start talking about six months with this and so I want this for ex this first article and never stop so I usually build my article in steps first I wrote

[39:46] Everything about the new JP inside the release I add a small section about the existing jets that have that the existing functionality that have a new JB for a second preview second or incubator stuff like that and then I also use the Java Almanac website to see if there is my mying functionality because not everything is in the J for example for Java 22 we have a list format that is a new format and there is no jet for that because it’s really a small addition so I also use a Java version Almanac that lists all the new API yeah so the information comes yeah for the people I flow around the GDK from reading the project page that we already discussed so G GDK 22 protect Peach and yeah using tools like the Java version Alman allows me to F the Gap but yeah reading the JP it’s really the main way to know what’s in a new version and when I start writing the this article this soon becomes my article that is most read on my blog and a lot of people I know said okay your article are really cool please keep doing this

[41:26] This so I keep keep doing it and transl in English because at first it was an article only in French because I’m French and at that time most of my followers are was French but no my blog has views from over world so I always try to give a translation in English also you mentioned about all the new changes next to the jeps I’m working on the release notes for our aul Zulu 22 I think there are over 3,000 jeta items which are included in this so indeed every new release is a lot of changes improvements fixes all handled by the community I guess or for a big part by the community yeah it’s certainly the case that you know Java is not a language that’s standing still or a platform that’s standing still yeah and it’s both the language and runtime people forget that actually Java is two things okay so Java 22 is here this week should I move my production system no not what is the main conclusion here why should people decide to upgrade or not upgrade to 22 from my perspective it depends on what you’re doing because if you’re running systems in production and you want want them to be

[42:57] Maintained with highest level of security highest level of stability then yes you can move to JDK 22 that’s there’s nothing that would stop you from doing that and as I say one of the key things to get across here is that JDK 22 even though it’s not a long-term support release it is still production ready and can be used without any problems what you need to consider though is are you in a situation where you can move to JDK 22 now and then in six months time be ready to move to JDK 23 and then in six months time move to JDK 24 because that’s what you’re going to have to do if you want to maintain the maximum level of security and stability because jk22 will only have updates until the release of JDK 23 and then they stop whereas JDK 21 has updates for much longer so if you’re running on JDK 21 at the moment you can continue using it for several years before you need to worry about updating to a newer version so it depends of what you’re working on and how you manage your upgrad for example in my prev job I work on a small platform when we wegr on each Java

[44:11] Version because we have with do set of libraries because there is also always the issue with the libraries you use because some may not support Java 22 or some may support it but not very fully tested and so on my PR jobs we mve to each each Java version and also because I was very U Enthusiast about Java and test versions but on my current job we are still running Java 17 for now I know that we have plan to switch to Java 21 but what is sometimes hard it’s really all the ecosystem that needs needs to be on the that needs to work with the new version because for KRA KRA is a data so we have plugins we have 400 plugins so we have hundreds of libraries and there is sometimes one functionality in one Library that’s not fully worth for example when we migrate to Java 17 we add to the come on line some ad opens directives to be able to use some libraries that uses reflection in a in not not not any more compatible way so yeah for Java for example for Java 21 there is changing in the security manager so we will again need to add some

[45:54] Flags in the command line and it’s not always easy it’s not always possible to handle new changes so for complex project yeah it’s better to stick to LTS version and especially for us because we offer a solution that our users are running they will maintain the Java virsion machine that runs cast but if you really want a new feature which is there in Java 20 2 23 and you for sure can go to that version and run it in production that’s a bit IDE yeah yes as as Simon said there is no fundamental differences between Java 21 and Java 22 in terms of quality in terms of what’s integr in it when on the mailing list they discuss about integrating a new JP they don’t say no we’re not to get it because it’s it’s an LTS and so we will switch it to the next version it’s not like that it’s just that their flag as longterm support One release in force that’s all I think we have handled most we cannot handle all the jeets is it something you still want to add actually I I’ll just briefly mention because I did mention it as a sort of forward reference earlier on which is the

[47:16] Implicitly declared classes and instance main methods and this is again the sort of second iteration of something that was introduced in JDK 21 and this comes back to that idea of reducing the amount of ceremony that’s involved in getting started with a Java application so in addition to this idea that you can take a source code file and then run it without having to compile it explicitly they’ve tried to reduce the amount of boiler plate code that you need to get to that you know hello world application that just prints out hello world and this reduces the requirement to Define an explicit class and then you can have a main method you know which is simplified as well it’s one of those things and I think I may have mentioned this in the last podcast we did when this feature was introduced in that I think it’s a nice idea in principle but I really don’t see that it has huge benefit because if you’re going to learn Java you’re going to have to learn all the features of it so once you move Beyond hello world you’re going to have to understand about objectoriented programming you’re going

[48:22] To have to understand about the structure of classes methods instance fields and so on so making it simpler to get to the point where you can write hello world application is good but you’re then going to still have to learn all those things to get past that and then start writing a real application so it’s it’s one of those things that yes helpful but I don’t know of how much value it really is I’ll probably get criticized for that yeah we had this discussion last time indeed I’m a big fan because I want to have as much people into Java as possible and then on the most easy way but indeed you have to get beyond that step of Hello Walls and then yeah see because I can see that like you know if if you look at what you have to do the simplest possible application that might dissuade people from getting started with jva so if you make that simpler you’re saying yes more people can write a hello world application but the moment they want to do anything beyond that they’re still going to have the same step up that they would have had if they did the first program that way

[49:24] Just my opinion but it’s it’s one of the many new things that’s there so yeah we can keep discussing it but we’ll discuss it time as well I love it you you’re not that big of a lover yes one of the features that are in this release and that are really nice also it’s a structured concurrency and I really love this new new features I hope it will be soon finalized because there was this wonderful new thread you know thread implementation that are vual threats that are in finalized I don’t remember where I think it’s jav 19 but in fact working with threads directly it’s not very convenient and through concurrency it’s really a way to nicely work with multiple threat and saying okay I will start tasking different sweat then I wait that all sweat and then I can wait on multiple condition likeing I wait where the I wait until the there is an exception or I wait until all ends so this is really a nice addition to the Java language and there is a second preview yes because this is one of those things where writing reliable concurrent

[50:53] Code is difficult there’s just no way around it and it’s great to see that we have seen over the lifetime of java numerous different introductions of various techniques to make life simpler because if you go right back to the very beginning of java you know we had threads built into the language which was different to other languages like C and C++ you need a library to do that in the past and it was a core part of the language but you really had to work hard with the thread class because you really only had wait interrupt sleep and notify as a way of coordinating your threads and locks of course but then we obviously had the jsr 166 which was the concurrency utilities then we had the fork join framework lambdas and streams also introduced a way of doing things in a little bit better way because you could do a parallel stream without having to worry about any of the underlying code and then we’ve got as as L said about the introduction of virtual threats is another thing that makes life a lot easier for scalability of applications and structure con concurrency is also

[51:57] Very useful because of this ability to sort of manage a number of different things and have them group together in the same way that we do somewhat with the try with resources so it’s a similar kind of approach to that so yeah it’s all good stuff so a lot in this Java 22 that we can experiment with that we can use that we can build applications if we want and run them in production we can already start looking forward to September for the next one we’ll see what includes it in there thank you very much for joining this podcast Simon and LU thank you also very much to all the listeners of this episode keep an eye on Foojay for future articles and podcasts about development and everything related to Java World thanks a lot give me a give me a j give me the friends of OpenJDK

Found a mistake, or something to add? Edit this page on GitHub

Written by

Frank Delporte

Frank Delporte is a Java Champion, Java Developer, Senior Technical Writer at Azul, Blogger, Author of "Java Programming for Raspberry Pi - A Hands-On Guide to Electronics and IoT Projects", and Open-Source Contributor for Pi4J, Lottie4J, Sheetmusic4J, …

Written by

Loic Mathieu

Lead Software Engineer at Kestra.io | GCP GDE | Quarkus contributor | Book Author

Written by

Simon Ritter

Simon is Deputy CTO at Azul.

Related posts

Join the discussion