What’s New in JDK 10 – Features and Enhancements Java 10?
Java released its new version Java 10 recently. Java Standard Edition 10, was released on March 20, 2018.There are few updates in security, collections api and garbage collection are done in java .Let’s check some of the features and enhancements in Java 10.This release of JDK 10 is considered as a Short term release.The Long term Support (LTS) release of JDK 10 is due in September .We are going to discuss some highlighted features only .
Java has added a new
orElseThrow method in the optional class.
Optional.get() seems tempting for developers leading to frequent errors . Its a kind of replacement for
optional.get() is not yet deprecated.
APIs for Creating Unmodifiable Collections:-
Features and Enhancements Java 10 has a new Api such as
java.util.collections package. Some new
API are also added in
Stream package such as
toUnmodifiableMap .These allow the elements of a Stream to be collected into an unmodifiable collection.
List<String> list = List.of(...); List<CharSequence> newList = List.copyOf(list);
This can’t be done for mutable collections, since it can lead to heap pollution.
Bytecode Generation for Enhanced for Loop:-
If a huge list of array is iterated using for loop,it keeps a temporary reference to the memory .This memory might be locked for garbage collection , hence causing out of memory errors. Hence java team updated the byte code generation logic for this.
Parallel Full GC for G1:-
Java now has its
GC as Parallel GC.The new G1 garbage collector is designed to avoid full collections, but when the concurrent collections can’t reclaim memory fast enough a fall back full GC will occur.With the new update of Java 10 G1 is converted as parallel.
Some of the Features and Enhancements In Java 10 which are removed:-
- Removal of Deprecated Classes in com.sun.security.auth.**
- Removal of policy tool
- Removal of Common DOM APIs
- Removal of RMI Server-Side Multiplex Protocol Support
- Removal of Runtime.getLocalizedInputStream and getLocalizedOutputStream Methods
- Removal of Support for Using Old LookAndFeel
- Removal of Deprecated Pre-1.2 SecurityManager Methods and Fields
Please visit this link from Oracle to learn more about the variouss Features and enhancements in Java 10