The place where random ideas get written down and lost in time.
2020-09-28 - Java 11
Category DEVThe latest Debian Busty offers Java 11 via OpenJDK. There’s also a comment on the OpenJDK web site that from now on all official Java releases are done via the OpenJDK (site/framework)... does that mean one no longer has to wonder about Java vs OpenJDK compatibility? That would be nice.
Of note: Debian has an openjdk-11-headless… no more need to drag X libs pointlessly.
It also begs the question of “what’s new in Java 11”... and what can be used on Android.
https://simply-how.com/getting-started-with-java-11
- Java 9:
- A new concept of “modules”, a “self describing collection of code and data”.
- Jlink, a tool with a link time phase vs compile time phase, using modules.
- Jshell, a REPL … that can come in handy.
- Multi-release JAR files: version-specific of classes in the same JAR.
- Private methods on interfaces, which can be used by default methods.
- Rx compliant Flow API.
- Factory/collections methods: Set.of, List.of…
- Stuff I don’t care, e.g. garbage collector changed. (skipping those below).
- Java 10:
- “Var” keyword for local type inference.
- Optional.orElseThrow.
- Unmodifiable collections: List.copyOf, etc.
- Java 11:
- HTTP Client API (do I care?)
- “Singe-file source-code programs”... sounds like scripting to me.
- “Var” keyword can be used in lambda parameters.
- Java 12:
- More garbage collector whatever this or that.
- Mostly nothing except some *preview* of a condensed switch/case/break syntax (e.g. the “break” also acts as a “return”, and can be further condensed to an -> arrow syntax)... meh.
Bottom line: mostly nothing to see here.
So overall a fairly incremental update to the language. The most notable useful thing is the “var” keyword. Since it is type-inference, I expect it can generate backward-compatible bytecode running fine with older JREs. New APIs like collections would obviously require the latest JRE to run.
We still don’t have support for “safe-dereference” (?. which was proposed for Java 7!) and folks horrendously suggest using Optional instead.
For gradle, the usual:
targetCompatibility = 11
sourceCompatibility = 11
Or
compileOptions {
targetCompatibility JavaVersion.VERSION_12
sourceCompatibility JavaVersion.VERSION_12
}
Thus it seems to me overall I’d want something along the lines of “target 8… source 11”.