• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Java 21 LTS

 
Ranch Hand
Posts: 61
Mac Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello you all,

has anyone already tried the new LTS Java 21?

What are your impressions?  Do you think of any new feature as particular cool?

I use Java 8 and Java 17 for my projects and I am wondering whether to give 21 a try.

Thank you!

Peter
 
Saloon Keeper
Posts: 15727
368
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The biggest changes are:

  • Javadoc @snippet tag
  • Sequenced Collections *
  • Record Patterns *
  • Pattern Matching for switch *
  • Virtual Threads *
  • Key Encapsulation Mechanism API


  • The following incubator and preview features are also available:

  • Structured Concurrency *
  • String Templates *
  • Foreign Function & Memory API
  • Unnamed Patterns and Variables
  • Unnamed Classes and Instance Main Methods *
  • Scoped Values *
  • Vector API


  • The features that I've annotated with an asterisk are the ones that to me personally are the most exciting. In particular, I'm very happy about Virtual Threads and I can't wait for Structured Concurrency to come out of preview.

     
    Peter Schuster
    Ranch Hand
    Posts: 61
    Mac Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hello Stephan!

    Thank you for your recommendations!

    Peter
     
    Sheriff
    Posts: 22815
    132
    Eclipse IDE Spring Chrome Java Windows
    • Likes 2
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I've become a bit of a fan of @snippet. Before I used a combination of pre and code HTML tags. While that worked, it allowed any code to be included in documentation - even code that didn't even compile. With @snippet I've been able to link to (parts of) actual classes, that I've added to the test source path using Maven. The end result are code snippets that actually compile.
     
    Peter Schuster
    Ranch Hand
    Posts: 61
    Mac Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Rob Spoor wrote:I've become a bit of a fan of @snippet.



    That feature also caught my eye. Thank you.

    Peter
     
    Sheriff
    Posts: 28323
    95
    Eclipse IDE Firefox Browser MySQL Database
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I would use String Templates, if the Eclipse version of Java 21 supported it. But it doesn't -- it's a preview feature so that's okay. It's supposed to be final in Java 22.

    I tried Virtual Threads but it just made my many-threaded application hang. But that's okay too because the pre-release writeups said that virtual threads weren't suitable for heavy threads which did a lot of work. So what they said was correct. But I might well look at Structured Concurrency to try to tame the many threads a bit. Although it's a preview feature so I haven't even looked to see if Eclipse supports it.
     
    Saloon Keeper
    Posts: 10929
    87
    Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Paul Clapham wrote:I would use String Templates, if the Eclipse version of Java 21 supported it. But it doesn't


    I was really disappointed in Eclipse on this one. They usually support preview features and this is one that could clean up a bunch of code. Oh well, March isn't far off.
     
    Stephan van Hulst
    Saloon Keeper
    Posts: 15727
    368
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Paul, would you have the time and the inclination to share an SSCCI of your hanging threads issue?

    I'd be very interested in debugging it so I can learn where the pitfalls in using virtual threads lie.
     
    Paul Clapham
    Sheriff
    Posts: 28323
    95
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Stephan van Hulst wrote:Paul, would you have the time and the inclination to share an SSCCI of your hanging threads issue?


    I don't think I could do that. When my application loads an entity, it has to load about 15 other entities to support it. Each of these loads in a separate thread but not all at once, there's a network of dependencies which controls when the entities load. And behind it all is a JDBC connection pool which uses its own threads. It would be very hard to reduce that to something short and simple.

    What I did was only to change my ExecutorService to use virtual threads. This caused the loading process to hang. There were no threads waiting on locks, just no activity. I found a system property which claimed to allocate more threads to the application but it didn't make any difference. I wasn't particularly driven to get this working so I reverted the changes.
     
    Peter Schuster
    Ranch Hand
    Posts: 61
    Mac Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Are there books yets on the novelties of Java 18, 19, 20 and 21 LTS?

    Thanks again.
     
    Saloon Keeper
    Posts: 28319
    210
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Paul Clapham wrote:When my application loads an entity, it has to load about 15 other entities to support it. Each of these loads in a separate thread but not all at once, there's a network of dependencies which controls when the entities load. And behind it all is a JDBC connection pool which uses its own threads. It would be very hard to reduce that to something short and simple.


    Ouch! And you think JPA is bad???  

    I inherited an app once kind of like that. The original author effectively loaded the entire database into memory at application start-up. Every time I ran a test is was 20 minutes or so to get to where I could do anything.

    I got fed up, re-did it to do incremental fetch-on-demand with caching and dropped startup to 30 seconds.

    When I design a JPA-based system, I deal with "working sets". Say, for example, the bus-route system I once worked on. Entity types included physical buses, logical buses, routes, stops, schedules and so forth. If I want to work on a route,, I'd fetch the route record and the collection of stop records and detach them from the database, returning them as a subset data graph of the whole. Everything I needed and nothing I did not. I'd do my dirty work, then pass the graph back to the business persistence level, which would wrap the update process in a transaction and invoke the lower-level DAOs to handle pushing the updated components back to the database. I didn't have to keep redundant stuff hanging around, because in most cases, JPA's own internal caching kept popular items in memory without me having to track them manually. This is especially important for systems that want to keep session-scope memory usage minimal or non-existend (ReST).

    For really large jobs ORMs have been clocked at double the throughput of raw JDBC because even though JPA is built on JDBC, it can work smarter, not harder. Plus most of the grunt code is pree-debugged and Someone Else's Problem.

    To me JDBC is like assembly language. In my mainframe days, we had virtually no choice but to use assembly language. C wasn't available and the stock high-level languages demanded a runtime support infrastructure that simply could not work in OS-internal code. We hated it, and I saw more bubble-sorts and short-but-ugly solutions than I want to think about. We agonised over every microsecond and were almost never able to re-use code. Virtually no support libraties.

    I can still do assembly on about 5 different hardware platforms. I almost never do, because in most cases it's more efficient both in my own and CPU resources to work with higher-level mechanisms.

    So I bet I could snippet my database code without much trouble,
     
    Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic