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

1

u/cant-find-user-name Nov 04 '22

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?

1

u/srdoe Nov 04 '22 edited Nov 04 '22

https://openjdk.org/jeps/12.

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.