Virtual threads delivered. They are like Goroutines but the Structured Concurrency API really makes it better. Will any of this be out of preview for the next LTS release?
Amber is making amazing progress. The exhaustiveness checker still needs improvement, but great job.
Panama looks awesome for projects that have to interop outside of the JVM
If Valhalla really delivers in Java 20 or 21 and value/primitive types provide performance improvements, that will be a home run for the Java team.
AFAIK, preview features are production ready, but APIs are evolving and not stable. You can use virtual threads in production Java apps now, with Java 19. Major frameworks will want to hold off until the feature is out of preview and is stable. But for small teams, evolving APIs aren't a big deal, virtual threads are ready to use.
The preview features JEP says not to enable preview features and let your jars escape into the wild, which for many people "put into production" would qualify as.
Even if a small team wants to use the preview feature now, they likely won't be able to unless they can guarantee that their software will run on exactly JDK 19. Keep in mind that the code won't run on JDK 20 without a recompile, even if the API doesn't change, due to the special bits set in the classfile versions. If you're delivering a jar to someone else to run, that's unlikely to be acceptable.
So I guess you could deploy the new features into production if you were making a saas thing and control the environment your code runs in? I think for most people it makes more sense to treat preview as "ready to try out in a testing environment/on a branch", instead of "ready for use in production".
The preview features JEP says not to enable preview features and let your jars escape into the wild,
That's true in general, but more relevant to language preview features. Because virtual threads use the existing Thread API (for the most part), you don't really have to compile many libraries that are designed for virtual threads with --enable-preview. Only thread creation needs to use new APIs, but that could be factored out to a ThreadFactory provided by the application. In fact, there are already some libraries designed for virtual threads out there, including the Oracle JDBC driver.
The downside is you lock whoever is running your application to running on JDK 19 forever. If that "whoever" is you, then go for it. If it's someone else, they might not be cool with getting a jar that won't run on the JDK releasing in 6 months.
Noob question, can you simply not upgrade to JDK20 when it comes out? If the API is changed, a few code changes have to be made. But other than that, why are you stuck with JDK 19 for ever?
You have to draw a line between the developer and customer here. The developer isn't stuck on JDK 19, but the customer might be.
Let's say I enable preview features in JDK 19 and build a jar. That jar's class files are marked as requiring preview by having all bits set in the minor_version. The way I understand JEP 12, a particular JDK such as 20 should only support the preview features of JDK 20.
This means that the jar I built should only run on JDK 19. When JDK 20 comes out, I need to recompile my code to be compatible with that JDK, even if the preview feature hasn't actually seen any changes.
So yes, I (the developer) can just upgrade to JDK 20, adjust and recompile, but my customers will be stuck on JDK 19 until they get a new jar from me.
For the customer, this puts a 6 month expiration date on the jar you gave them, and also commits them to upgrading the JDK every 6 months until the next LTS release if they want security fixes, and also means they have to hope you're still around to provide a recompiled jar in 6 months.
That's fine for some types of customer, and not acceptable to others.
These class files are special; they should not be distributed beyond the control of the developer who chose to use preview features.
about files you generate with --enable-preview.
Also putting preview features into production is impractical unless you control the production environment yourself, since your code will now have both a minimum and maximum JDK version of 19.
90
u/Joram2 Sep 20 '22
Congrats Java team!
Virtual threads delivered. They are like Goroutines but the Structured Concurrency API really makes it better. Will any of this be out of preview for the next LTS release?
Amber is making amazing progress. The exhaustiveness checker still needs improvement, but great job.
Panama looks awesome for projects that have to interop outside of the JVM
If Valhalla really delivers in Java 20 or 21 and value/primitive types provide performance improvements, that will be a home run for the Java team.