Home  >  Java 10

Java 10 New Features

By Arvind Rai, October 02, 2020
On this page we will discuss Java 10 new features and improvements. In Java 10, some methods have been added to Stream classes, some new VM arguments have been introduced, some classes have been deprecated and marked to remove.
Now find the detailed description of Java 10 new features and improvements point-wise.

1. Optional.orElseThrow()

The Optional.orElseThrow() returns the value if present otherwise throws NoSuchElementException.
Integer num = Stream.of(10, 20, 30).findAny().orElseThrow(); 
We should prefer orElseThrow over get method of Optional class.

2. APIs for Unmodifiable Stream Collections

In Java 10, java.util.stream.Collectors has been added with new methods to create unmodifiable collections.
a. toUnmodifiableList : Returns a Collectorsthat accumulates the input elements into an unmodifiable List in encounter order.
List<Integer> list = Stream.of(5, 10, 15).collect(Collectors.toUnmodifiableList()); 
b. toUnmodifiableSet : Returns a Collector that accumulates the input elements into an unmodifiable Set.
Set<Integer> set = Stream.of(5, 10, 15).collect(Collectors.toUnmodifiableSet()); 
c. toUnmodifiableMap : Returns a Collector that accumulates the input elements into an unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements.
Map<Integer, Integer> map = Stream.of(5, 10, 15)
	.collect(Collectors.toUnmodifiableMap(i -> i, i -> i * 2)); 

3. New Options in tools/javadoc(tool)

1. A new javadoc command-line option has been added i.e. --add-stylesheet that supports the use of multiple stylesheets in the generated documentation.
2. A new option --overridden-methods=value has been added to the javadoc tool that is used to group inherited methods.
3. A new inline tag {@summary ...} has been added that explicitly specify the text used as the summary of the API description. By default summary of API is taken from first sentence.

4. Other New Features

1. New system property jdk.disableLastUsageTracking to disable JRE last usage tracking. We can use it with command prompt in following ways.
java -Djdk.disableLastUsageTracking=true
java -Djdk.disableLastUsageTracking 
2. In Java 10, the jmxremote.password is now over-writing the clear passwords with SHA3-512 hash by the JMX agent.
3. JEP 307 Parallel Full GC for G1: The full GC has been parallelized in Java 10. The old implementation was using single threaded mark-sweep-compact algorithm.
4. JEP 319 Root Certificates: This removes the problem of the empty cacerts keystore in the OpenJDK 9 binary for Linux x64. The cacerts keystore of the OpenJDK 9 binary for Linux x64 has been populated by JEP 319 Root Certificates with a set of root certificates.
5. Bytecode generation has been improved for enhanced for loops.
6. The class file version has been changed from 53 to 54 though JDK 10 did not introduce to other changes to class format.
7. Java 10 has added support for automatically showing the touch keyboard for Swing/AWT text components on Microsoft Windows 8 or later.
8. The requirement for finalize to call close method has been relaxed in FileInputStream and FileOutputStream.
9. The bootstrap class loader has been changed to skip an empty element specified in -Xbootclasspath/a when locating resources.
10. The RMI Registry filter now does not check the type of array instead it checks the size of array only. The maximum array size has been increased to 1,000,000.
11. When an application is launched for the first time via Java Web Start, now a deprecation warning dialog will be shown.
12. Now the default value for BiasedLockingStartupDelay has been changed from 4000 to 0.
13. New JVM options have added to select Heap % of available RAM
-XX:InitialRAMPercentage
-XX:MaxRAMPercentage
-XX:MinRAMPercentage 
14. Improvement in error message of java.lang.IllegalAccessError produced by javac.
15. The time needed to start JShell has been significantly reduced, especially in cases where a start file with many snippets is used.

5. Removed Features

1. Old LookAndFeel no more supported. Now we cannot use
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
javax.swing.UIManager.setLookAndFeel("apple.laf.AquaLookAndFeel"); 
These APIs were internal to JDK and we should not have used in our application. Now we need to migrate it with following API.
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
2. Following methods from Runtime have been removed.
Runtime.getLocalizedInputStream
Runtime.getLocalizedOutputStream 
3. The RMI Multiplex protocol has been removed now. It was disabled in Java 9.
4. Following Common DOM APIs have been removed.
com.sun.java.browser.plugin2.DOM
sun.plugin.dom.DOMObject 
Our application can use now netscape.javascript.JSObject to manipulate the DOM.
5. The FlatProfiler was deprecated in Java 9. Now the implementation code of FlatProfiler has been removed. The -Xprof VM argument is still available which was being used to enable FlatProfiler. Now calling -Xprof VM argument will print out warning.
6. The HostServices::getWebContext has been removed. It was deprecated in Java 9.
7. The T2K rasterizer and ICU layout engine have been removed from JavaFX.
8. In JavaFX Media, support for VP6 video encoding format and FXM/FLV container has been removed. Now we can use H.264/AVC1 in the MP4 container or HTTP Live Streaming.
9. The security tool policytool has been removed from JDK.
10. The native-header tool, javah, has been removed. Now the native headers can be generated using -h option with javac.
11. The data model selection options (-d32, -d64, -J-d32 and -J-d64) of java launcher has been removed.

6. Deprecated Features

Following APIs has been deprecated and marked for removal in further releases.
1. jdk.snmp module.
2. java.security.{Certificate,Identity,IdentityScope,Signer} APIs.
3. java.security.acl APIs.
4. javax.security.auth.Policy has been marked forRemoval=true for removal.

7. Reference

JDK 10 Release Notes
POSTED BY
ARVIND RAI
ARVIND RAI








©2020 concretepage.com | Privacy Policy | Contact Us