X
    Categories: Articles

8 New Features in Java 10 That You Should Know About

Java is a very popular language pertaining to its amazing features. It dates 20 years back but still qualifies as one of the most exciting languages to work with. Recently, Java 10 is launched with a mix of exciting new features. Here is an overview of the 10 most significant features you will work when using Java 10:

1.Local Variable Type Inference

Java now features a var keyword similar to Javascript to declare a variable without specifying its type. The stored value of the variable will indicate the variable type. For example, if you have written this line of code, var name = “Name” then the compiler will know that the variable value is a String.

Var keyword can only be used for declaration of local variables and can not be used for member variable declaration (which is done inside the class body). You also need to note that this change still does not make it a dynamically typed language such as Python. However, this feature reduces a lot of lines of code which are otherwise required to declare local variables using the Java language.

2. Time-Based Released Versioning

Java has scheduled a new release every six months since JDK 10 release. This approach has received a mix of both positive and negative reviews from the Java community. The update element also increments 1 month after a Feature element. This means that the April 2018 java release is JDK 10.0.1, whereas July 2018 release is JDK 10.0.2 so on and so forth.



3. Garbage-Collector Interface (JEP 304)

Garbage Collector interface is another useful and interesting Java 10 feature. It gives a clean garbage collector interface which means that you can now exclude GC from a JDK build. This makes it easy to add a new GC without working on the code base. Read about Java Memory Management to understand how G1 Garbage Collection works and learn the difference between G1 and Concurrent Mark Sweep Garbage Collector.

4. Heap Allocation on Alternative Memory Devices (JEP 316)

Heap Allocation on Alternative Memory Devices is another great Java 10 feature. It helps to enable HotSpot VM to allocate Java object heap on an alternative memory device indicated by the user. This feature also makes it possible to allocate lower priority procedures for using the NV-DIMM memory while assisting the higher priority procedures to the DRAM in a multi-JVM environment.

5. Root Certificates (JEP 319)

Root Certificates is another significant change featured in Java 10. JDK 10 was built in connection with OpenJDK and that’s prominent from this feature, as it offers a default set of root Certification Authority. It also focuses on reducing the difference between OpenJDK and Oracle JDK. Security components such as TLS are default enabled in OpenJDK builds.

6. Thread-Local Handshakes (JEP 312)

Thread-Local Handshakes in Java 10 offers an improved VM performance. It enables callback on application threads without the execution of a global VM savepoint. This means that the JVM can now also stop individual threads instead of collective threads whenever required.

Small improvements are also done as part of this feature to enhance VM performance. Various memory barriers are removed from JVM with an improved biased locking to stop individual threads for revoking biases.

7. Application class-data sharing

Class-Data Sharing time was introduced in Java 5 to improve startup times of small java applications. It helped in loading the class metadata so as not to load all of it each time. This shared data cache signified a big improvement in startup times for small applications as the relative core class size was mostly larger in size than the application. In Java 10, this feature is further extended to include the system classloader and the platform classloader. To benefit from that, simply add -XX:+UseAppCDS as a parameter.

8. Remove the Native-Header Generation Tool (JEP 313) & Deprecated Methods

Remove the Native-Header Generation Toll focuses on housekeeping by eliminating javah tool from JDK. Javah was separately used to generate header files for compilation of JNI code. It will be done through javac now.

Deprecated methods such as java.security can be removed by setting the value of forRemoval=true in a deprecated text. The java.security.acl is also marked for removal by setting ForRemoval=true in a deprecated text.  Some fields and methods of java.lang.SecurityManager are also set for removal in Java 10. javax.security.auth.Policy is marked for removal setting the same value whereas its features are available in java.security.Policy. com.sun.security.auth.** classes set for removal using forRemoval=True value in JDK 9 is removed from this version.

Conclusion

Java 10 features and changes are not something that will ring an alarm bell for the developers’ community. It mainly comprises a list of minor changes for enhancing the language’s performance. However, it also signifies the first series of changes in the release cycle. Java 10 is delivered on time as expected like its compiler. However, only the time will tell how the Java community responds to the new changes. For now, the developers can enjoy working with Java 10 as it has become much more powerful and useful compared to its previous versions.

 

Author Bio

Faiza Farooqi is an Ecommerce Manager at Codup who accepts challenging strategies and puts amazing ideas on the table! She is an active community manager and also blogs at Codup Readers.

0 0 votes
Article Rating
filip:
Related Post