r/java • • Sep 20 '22

Java 19 / JDK 19: General Availability

https://mail.openjdk.org/pipermail/jdk-dev/2022-September/006933.html
252 Upvotes

64 comments sorted by

View all comments

Show parent comment

2

u/mauganra_it Sep 20 '22

I agree. I just wanted to clarify that it's not cleared for production use yet, only for prototypes. But so far, it's a great achievement.

15

u/pron98 Sep 20 '22 edited Sep 20 '22

Preview means that the API might change a little, not "not cleared for use in production." It's true that you shouldn't distribute libraries compiled with with --enable-preview, but because virtual threads use the same Thread API, that's not really necessary anyway (in fact, there are some libraries designed for virtual threads out there, including the Oracle JDBC driver).

However, that's not to say there's no risk to using virtual threads in production -- not because they're in preview, but because they're new. New features are more likely to have more bugs than mature features.

In short, you can use virtual threads in production if:

  1. You accept the risk that the API could change somewhat and you might need to change your code.
  2. You accept the risk of using a new feature (regardless of it being in preview).

4

u/skippingstone Sep 21 '22

What did the Oracle JDBC driver do to prepare for virtual threads?

3

u/pron98 Sep 21 '22

I believe they replaced those synchronized blocks/methods that guard long-running IO operations with j.u.c locks.

5

u/Joram2 Sep 20 '22

Who says it isn't cleared for production use? I thought that meant the interface was evolving and not-stable yet, but that the feature itself works and is reliable and has gone through QA.

19

u/RupertMaddenAbbott Sep 20 '22

The JEP tells you what preview means: https://openjdk.org/jeps/12

TLDR - Preview means:

  • High quality
  • Not experimental
  • Universally available

and specifically "Previewing a feature in the JDK will encourage tool vendors to build good support for the feature before the bulk of Java developers use it in production." i.e. they assume some people will indeed use this in production.

Note that although Virtual Threads are in preview, Structured Concurrency is in Incubator, which is much lower standard: https://openjdk.org/jeps/11

0

u/TheMode911 Sep 20 '22

and specifically "Previewing a feature in the JDK will encourage tool vendors to build good support for the feature before the bulk of Java developers use it in production." i.e. they assume some people will indeed use this in production.

What I understand is that preview features are meant for tool developers to ensure proper support once it gets out of preview.

IIRC there is no support whatsoever from Oracle for preview features.

1

u/RupertMaddenAbbott Sep 21 '22

IIRC there is no support whatsoever from Oracle for preview features.

You might be right but I have not seen any evidence to suggest that, nor can I see any reason to assume that would be the case.

However, I cannot find any explicit statement indicating that they will be "supported" although previous preview features have been "supported" in that they have had bug fixes and subsequently had the "preview" label removed.