treeno
treeno

Reputation: 2600

How to update sources of a library to a modern java version while still being compatible with java 8?

We are maintaining a java library and the majority of our customers is still using java 8. Since java 8 is getting a bit rusty, we would like to be able to use new language features of newer java versions, say java 17, at compile time, without shutting older customers down. Is there any possibility to achieve this?

To be precise: I only want to use new language features like var, not new APIs.

How do library-owners usually deal with this?

Upvotes: 4

Views: 1469

Answers (1)

gjoranv
gjoranv

Reputation: 4721

One solution is to release a new major version of your library for JDK 17, and keep the current major version for clients using JDK 8. You would then have to maintain both versions for a while, until your most important customers have migrated to JDK 17 themselves.

When you want to release new features, you would then use a new minor version for each of the two major versions.

Upvotes: 2

Related Questions