by hyperpape · 5y ago · 0 comments
Among other things, this means that we can begin to use records, pattern matching for instanceof, the shenendoah GC, and more.
Links to JEPs for the other releases.
http://openjdk.java.net/projects/jdk/16/ http://openjdk.java.net/projects/jdk/15/ http://openjdk.java.net/projects/jdk/14/ http://openjdk.java.net/projects/jdk/13/ http://openjdk.java.net/projects/jdk/12/
> Pattern Matching for instanceof (16)
> Records (16)
> Restore Always-Strict Floating-Point Semantics (17)
> Sealed Classes (17)
> Switch Expressions (14)
> Text Blocks (15)
This is what excites me. Records, switch expressions and sealed classes are all excellent and even better together. Along with pattern matching switch statements, Java is finally losing a lot of cruft people complain about.
A lot of the time, the software I'm working on has data objects that are really amalgamations of other fields. Example: "Address" is the street address, the city, the postal code, etc, etc. These sorts of objects should be immutable. Records are perfect for that.
If I need to add additional logic, methods, then you can add those to a record. But it continues to enforce that the state is immutable.
* tuples (complex numbers, points, dimensions, colors, IP addresses),
* database query results,
* stateless beans for DI frameworks where it cuts down on the verbosity of using constructor injection (actually a slight misuse)
* composite natural keys in database modeling
The immutability can help to enforce API contracts and proper service layering. A common problem in legacy code is modules communicating with each other by modifying objects that were passed as arguments.
Eventually, Project Valhalla will introduce the possibility to declare records as primitive, which will also reduce the overhead of Wither methods.
Edit: Building web APIs should also benefit from records because the argument and result types are only supposed to be created and read, not modified.
They reduce a lot of boilerplate, e.g. when passing multiple return values.
I know the answer is always use IDE and all but it causes more context switches than scrolling a bit to see types I created.
https://advancedweb.hu/a-categorized-list-of-all-java-and-jv...
That's not _strictly_ true.
Java 17 is a release of the reference implementation, but there are a number of distributions from a variety of vendors.
Oracle are going to provide long term support for their distribution, and it sounds like many will follow their lead. (If you are going to provide LTS it would be a little perverse to be out of sync with other providers of the same software)
So, for all practical purposes, it is an LTS. But check with your vendor.
Yes, these are "distributions" (binaries) of OpenJDK that do not provide any sort of support, and clearly no LTS flag to them.
This seems like exactly the intended effect to me.
Desktop applications are usually not delivered as bare JARs, but with wrapper binaries or scripts, where such flags are supposed to go.
Extended support still behind Java 8 =)
I suspect Java 8 will be with us for a long long time.