SlideShare a Scribd company logo
Ali BAKANā€Ø
Software Engineerā€Ø
ā€Ø
28.09.2018ā€Ø
ali.bakan@cloudnesil.comā€Ø
https://cloudnesil.com
WHAT IS NEW IN JAVA 10
1
WHAT IS NEW IN JAVA 10
Java 10 contains various new features and enhancements.
This is the fastest release of a java version in its 23 year
history :)
1. New Features in Language
2. New Features in Compiler
3. New Features in Libraries
4. New Features in Tools
5. New Features in Runtime
6. Miscellaneous Changes
2
WHAT IS NEW IN JAVA 10
1. NEW FEATURES IN LANGUAGE
1. Local variable type inference
2. Time-Based Release Versioning
3. Root Certiļ¬cates
3
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE
1.1 LOCAL VARIABLE TYPE INFERENCE
ā€£ Java is known to be a bit verbose, which can be good when it comes to
understanding what you or another developer had in mind when a function was
written. Local variable type inference feature breaks this rule.
ā€£ Local variable type inference is the biggest new feature in Java 10 for developers.
ā€£ With the exception of assert from the Java 1.4 days, new keywords always seem
to make a big splash, and var is no different.
ā€£ What the var keyword does is turn local variable assignments:ā€Ø
ā€Ø
Map<String, String> myMap = new HashMap<>();ā€Ø
ā€Ø
into:ā€Ø
ā€Ø
var thisIsAlsoMyMap = new HashMap<String, String>();
4
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE
1.1 LOCAL VARIABLE TYPE INFERENCE
ā€£ Local type inference can be used only in the following
scenarios:
- Limited only to local variable with initializer
- Indexes of enhanced for loop or indexes
- Local declared in for loop
ā€£ It cannot be used for member variables, method parameters,
return types, etc.
ā€£ var is not a keyword ā€“ this ensures backward compatibility for
programs using var as a function or variable name.
5
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE
1.1 LOCAL VARIABLE TYPE INFERENCE
ā€£ We canā€™t use ā€˜varā€™ in scenarios below:
- var n; // cannot use 'var' without initializer
- var emptyList = null; // variable initializer is ā€˜null'
- public var = "hello"; // 'var' is not allowed here
- var p = (String s) -> s.length() > 10; // lambda expression
needs an explicit target-type
- var arr = { 1, 2, 3 }; // array initializer needs an explicit
target-type
6
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE
1.1 LOCAL VARIABLE TYPE INFERENCE
ā€£ Example:ā€Ø
ā€Ø
var numbers = List.of(1, 2, 3, 4, 5); // inferred value ArrayList<String>ā€Ø
ā€Ø
// Index of Enhanced For Loopā€Ø
for (var number : numbers) {ā€Ø
System.out.println(number);ā€Ø
}ā€Ø
ā€Ø
// Local variable declared in a loopā€Ø
for (var i = 0; i < numbers.size(); i++) {ā€Ø
System.out.println(numbers.get(i));ā€Ø
}
7
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE
1.2 TIME-BASED RELEASE VERSIONING
ā€£ The development of new Java versions was, up until now,
very feature driven.
ā€£ This meant that you had to wait for a few years for the next
release.
ā€£ Oracle has now switched to a new, time based model.
ā€£ Not everyone agrees with this proceeding. Larger
companies also appreciated the stability and the low rate
of change of Java so far
8
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE
1.2 TIME-BASED RELEASE VERSIONING
ā€£ Oracle has responded to these concerns and continues to
offer long-term releases on a regular basis, but also at
longer intervals. And after Java 8, it is Java 11, which will
receive a long term support again.
ā€£ Java 9 and Java 10 on the other hand will only be
supported for the time period of half a year, until the next
release is due.
ā€£ In fact, Java 9 and Java 10 support has just ended, since
Java 11 is out.
9
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE
1.2 TIME-BASED RELEASE VERSIONING
ā€£ With adoption of time based release cycle, Oracle changed the version-string
scheme of the Java SE Platform and the JDK, and related versioning
information, for present and future time-based release models
ā€£ The new pattern of the Version number is: FEATURE.INTERIM.UPDATE.PATCH
ā€£ FEATURE: counter will be incremented every 6 months and will be based on
feature release versions, e.g: JDK 10, JDK 11.
ā€£ INTERIM: counter will be incremented for non-feature releases that contain
compatible bug ļ¬xes and enhancements but no incompatible changes.
ā€£ UPDATE: counter will be incremented for compatible update releases that ļ¬x
security issues, regressions, and bugs in newer features.
ā€£ PATCH: counter will be incremented for an emergency release to ļ¬x a critical
issue.
10
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE
1.3 ROOT CERTIFICATES
ā€£ The cacerts keystore, which was initially empty so far, is
intended to contain a set of root certiļ¬cates that can be used to
establish trust in the certiļ¬cate chains used by various security
protocols.
ā€£ With Java 10, Oracle has open-sourced the root certiļ¬cates in
Oracleā€™s Java SE Root CA program in order to make OpenJDK
builds more attractive to developers and to reduce the
differences between those builds and Oracle JDK builds.
ā€£ Basically, this means that now doing simple things like
communicating over HTTPS between your application and, say,
a Google RESTful service will be much simpler with OpenJDK.
11
WHAT IS NEW IN JAVA 10
2. NEW FEATURES IN COMPILER
1. Experimental Java-Based JIT Compiler
2. Bytecode Generation for Enhanced for Loop
12
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN COMPILER
2.1 EXPERIMENTAL JAVA-BASED JIT COMPILER
ā€£ The Just-In-Time (JIT) Compiler is the part of java that converts java
byte code into machine code at runtime. It was written in c++
ā€£ This feature enables the Java-based JIT compiler, Graal, to be used as
an experimental JIT compiler on the Linux/x64 platform.
ā€£ Graal is a complete rewrite of the JIT compiler in java from scratch.
ā€£ To enable Graal, add these ļ¬‚ags to your command line arguments
when starting the application:ā€Ø
ā€Ø
-XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler
ā€£ Keep in mind that the Graal team makes no promises in this ļ¬rst release
that this compiler is any faster.
13
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN COMPILER
2.2 BYTE CODE GENERATION FOR ENHANCED FOR LOOP
ā€£ Bytecode generation has been improved for enhanced for loops, providing
an improvement in the translation approach for them. For example:ā€Ø
ā€Ø
List<String> data = new ArrayList<>(); for (String b : data);ā€Ø
ā€Ø
The following is the code generated after the enhancement:ā€Ø
ā€Ø
{ /*synthetic*/ Iterator i$ = data.iterator(); for (; i$.hasNext(); ) { String b =
(String)i$.next(); } b = null; i$ = null; }
ā€£ Declaring the iterator variable outside of the for loop allows a null to be
assigned to it as soon as it is no longer used
ā€£ This makes it accessible to the GC, which can then get rid of the unused
memory.
14
WHAT IS NEW IN JAVA 10
3. NEW FEATURES IN LIBRARIES
1. Creating Unmodiļ¬able Collections
2. Optional.orElseThrow() Method
15
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LIBRARIES
3.1 CREATING UNMODIFIABLE COLLECTIONS
1. Several new APIs have been added that facilitate the creation of unmodiļ¬able
collections.
2. The List.copyOf, Set.copyOf, and Map.copyOf methods create new collection
instances from existing instances.
3. New methods toUnmodiļ¬ableList, toUnmodiļ¬ableSet, and
toUnmodiļ¬ableMap have been added to the Collectors class in the stream
package. These methods allow the elements of a Stream to be collected into
an unmodiļ¬able collection.ā€Ø
ā€Ø
Stream<String> myStream = Stream.of("a", "b", "c");ā€Ø
List<String> unModiļ¬ableList =
myStream.collect(Collectors.toUnmodiļ¬ableList());ā€Ø
unModiļ¬ableList.add(ā€œd"); // throws java.lang.UnsupportedOperationException
16
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LIBRARIES
3.2 CREATING UNMODIFIABLE COLLECTIONS
ā€£ Optional, OptionalDouble, OptionalInt and OptionalLong each
got a new method orElseThrow() which doesnā€™t take any argument
and throws NoSuchElementException if no value is present: ā€Ø
ā€Ø
@Testā€Ø
public void whenListContainsInteger_OrElseThrowReturnsInteger() {ā€Ø
Integer ļ¬rstEven = someIntList.stream()ā€Ø
.ļ¬lter(i -> i % 2 == 0)ā€Ø
.ļ¬ndFirst()ā€Ø
.orElseThrow();ā€Ø
is(ļ¬rstEven).equals(Integer.valueOf(2));ā€Ø
}
17
WHAT IS NEW IN JAVA 10
4. NEW FEATURES IN TOOLS
1. JShell Startup
2. Removed Tools
18
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN TOOLS
4.1 JSHELL STARTUP
ā€£ The time needed to start JShell has been signiļ¬cantly
reduced, especially in cases where a start ļ¬le with many
snippets is used
19
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN TOOLS
4.2 REMOVED TOOLS
ā€£ Tool javah has been removed from Java 10 which
generated C headers and source ļ¬les which were required
to implement native methods. Now, javac -h can be used
instead.
ā€£ policytool was the security tool for policy ļ¬le creation and
management. This has now been removed.
20
WHAT IS NEW IN JAVA 10
5. NEW FEATURES IN RUNTIME
1. Parallel Full GC for G1
2. Improvements for Docker Containers
3. Application Data-Class Sharing
4. Removed Options
21
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN RUNTIME
5.1. PARALLEL FULL GC FOR G1
ā€£ G1 garbage collector was made default in JDK 9.
ā€£ However, the full GC for G1 used a single threaded mark-sweep-
compact algorithm.
ā€£ This has been changed to the parallel mark-sweep-compact algorithm
in Java 10 effectively reducing the stop-the-world time during full GC.
ā€£ This change wonā€™t help the best-case performance times of the
garbage collector, but it does signiļ¬cantly reduce the worst-case
latencies.
ā€£ When concurrent garbage collection falls behind, it triggers a Full GC
collection.
22
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN RUNTIME
5.2. IMPROVEMENTS FOR DOCKER CONTAINERS
ā€£ The JVM now knows when it is running inside a Docker
Container.
ā€£ This means the application now has accurate information
about what the docker container allocates to memory,
CPU, and other system resources.
ā€£ Previously, the JVM queried the host operating system to
get this information.
ā€£ However, this support is only available for Linux-based
platforms.
23
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN RUNTIME
5.2. IMPROVEMENTS FOR DOCKER CONTAINERS
ā€£ There are command line options to specify how the JVM inside a Docker container allocates
internal memory.
ā€£ This new support is enabled by default and can be disabled in the command line with the
JVM option:ā€Ø
ā€Ø
-XX:-UseContainerSupport
ā€£ To set the memory heap to the container group size and limit the number of processors you
could pass in these arguments:ā€Ø
ā€Ø
-XX:+UseCGroupMemoryLimitForHeapā€Š-XX:ActiveProcessorCount=2
ā€£ Three new JVM options have been added to allow Docker container users to gain more ļ¬ne-
grained control over the amount of system memory that will be used for the Java Heap:ā€Ø
ā€Ø
-XX:InitialRAMPercentageā€Ø
-XX:MaxRAMPercentageā€Ø
-XX:MinRAMPercentage
24
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN RUNTIME
5.3. APPLICATION DATA-CLASS SHARING
ā€£ Java 5 introduced Class-Data Sharing (CDS) to improve startup times of
smaller Java applications.
ā€£ CDS only allowed the bootstrap class loader, limiting the feature to system
classes only.
ā€£ This feature extends the existing CDS feature for allowing application classes
to be placed in the shared archive in order to improve startup and footprint.
ā€£ The general idea was that when the JVM ļ¬rst launched, anything loaded was
serialized and stored in a ļ¬le on disk that could be reloaded on future
launches of the JVM.
ā€£ This meant that multiple instances of the JVM shared the class metadata so it
wouldnā€™t have to load them all every time.
25
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN RUNTIME
5.3. APPLICATION DATA-CLASS SHARING
ā€£ We can use the following steps to make use of this feature:
1. Get the list of classes to archive:ā€Ø
$ java -Xshare:off -XX:+UseAppCDS ā€Ø
-XX:DumpLoadedClassList=hello.lst -cp hello.jar HelloWorld
2. Create the AppCDS archive:ā€Ø
$ java -Xshare:dump -XX:+UseAppCDS ā€Ø
-XX:SharedClassListFile=hello.lst ā€Ø
-XX:SharedArchiveFile=hello.jsa -cp hello.jar
3. Use the AppCDS archive:ā€Ø
$ java -Xshare:on -XX:+UseAppCDS ā€Ø
-XX:SharedArchiveFile=hello.jsa -cp hello.jar HelloWorld
26
WHAT IS NEW IN JAVA 10 - NEW FEATURES IN RUNTIME
5.4. REMOVED OPTIONS
ā€£ Removal of FlatProļ¬ler: The FlatProļ¬ler, deprecated in
JDK 9, has been made obsolete by removing the
implementation code. The FlatProļ¬ler was enabled by
setting the -Xprof VM argument. The -Xprof ļ¬‚ag remains
recognized in this release; however, setting it will print out
a warning message
ā€£ Removal of Obsolete -X Options: The obsolete HotSpot
VM options (-Xoss, -Xsqnopause, -Xoptimize, -
Xboundthreads, and -Xusealtsigs) have been removed
27
WHAT IS NEW IN JAVA 10
6. MISCELLANEOUS CHANGES
ā€£ Class File Version Number is 54.0:ā€Ø
The class ļ¬le version has been changed from 53 (or 44 + 9) to 54 (44 +10), even though
JDK 10 did not introduce other changes to the class ļ¬le format.
ā€£ Consolidate the JDK Forest into a Single Repository:ā€Ø
Combined the numerous repositories of the JDK forest into a single repository to
simplify and streamline development. The code base until now has been broken into
multiple repos, which can cause problems with source-code management.
ā€£ Additional Unicode Language-Tag Extensions:ā€Ø
Enhanced the java.util.Locale and related APIs to implement additional Unicode
extensions of BCP 47 language tags.
ā€£ Garbage Collector Interface:ā€Ø
A clean garbage collector interface to improve source-code isolation of different
garbage collectors. The goals for this effort include better modularity for internal
garbage collection code in the HotSpot virtual machine and making it easier to add a
new garbage collector to HotSpot.
28
WHAT IS NEW IN JAVA 10
6. MISCELLANEOUS CHANGES
ā€£ Heap Allocation on Alternative Memory Devices:ā€Ø
It enables the HotSpot VM to allocate the Java object heap
on an alternative memory device, such as an NV-DIMM,
speciļ¬ed by the user.
ā€£ Thread-Local Handshakesā€Ø
This is an internal JVM feature to improve performance.
This feature provides a way to execute a callback on
threads without performing a global VM safepoint. Make it
both possible and cheap to stop individual threads and
not just all threads or none.
29
WHAT IS NEW IN JAVA 10
SOURCES
- https://www.oracle.com/technetwork/java/javase/10-
relnote-issues-4108729.html
- http://cr.openjdk.java.net/~iris/se/10/latestSpec/
- https://www.baeldung.com/java-10-overview
- https://stackify.com/whats-new-in-java-10/
- https://www.journaldev.com/20395/java-10-features
- https://www.quora.com/What-is-new-in-Java-10
30

More Related Content

What's hot

Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
JosƩ Paumard
Ā 
java 8 new features
java 8 new features java 8 new features
java 8 new features
Rohit Verma
Ā 
Java8 features
Java8 featuresJava8 features
Java8 features
Elias Hasnat
Ā 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jaran Flaath
Ā 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jiayun Zhou
Ā 
Introduction to Java 8
Introduction to Java 8Introduction to Java 8
Introduction to Java 8
Knoldus Inc.
Ā 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
CodeOps Technologies LLP
Ā 
Lambda Expressions in Java
Lambda Expressions in JavaLambda Expressions in Java
Lambda Expressions in Java
Erhan Bagdemir
Ā 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
intelliyole
Ā 
Modern Java web applications with Spring Boot and Thymeleaf
Modern Java web applications with Spring Boot and ThymeleafModern Java web applications with Spring Boot and Thymeleaf
Modern Java web applications with Spring Boot and Thymeleaf
LAY Leangsros
Ā 
Java 8 lambda
Java 8 lambdaJava 8 lambda
Java 8 lambda
Manav Prasad
Ā 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)
Prashanth Kumar
Ā 
Java collection
Java collectionJava collection
Java collection
Arati Gadgil
Ā 
07 java collection
07 java collection07 java collection
07 java collection
Abhishek Khune
Ā 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
Van Huong
Ā 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to MavenVadym Lotar
Ā 
Java Lambda Expressions.pptx
Java Lambda Expressions.pptxJava Lambda Expressions.pptx
Java Lambda Expressions.pptx
SameerAhmed593310
Ā 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
Joshua Long
Ā 
Gradle
GradleGradle
Gradle
Han Yin
Ā 
Introduce yourself to java 17
Introduce yourself to java 17Introduce yourself to java 17
Introduce yourself to java 17
ankitbhandari32
Ā 

What's hot (20)

Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
Ā 
java 8 new features
java 8 new features java 8 new features
java 8 new features
Ā 
Java8 features
Java8 featuresJava8 features
Java8 features
Ā 
Spring Boot
Spring BootSpring Boot
Spring Boot
Ā 
Spring Boot
Spring BootSpring Boot
Spring Boot
Ā 
Introduction to Java 8
Introduction to Java 8Introduction to Java 8
Introduction to Java 8
Ā 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
Ā 
Lambda Expressions in Java
Lambda Expressions in JavaLambda Expressions in Java
Lambda Expressions in Java
Ā 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
Ā 
Modern Java web applications with Spring Boot and Thymeleaf
Modern Java web applications with Spring Boot and ThymeleafModern Java web applications with Spring Boot and Thymeleaf
Modern Java web applications with Spring Boot and Thymeleaf
Ā 
Java 8 lambda
Java 8 lambdaJava 8 lambda
Java 8 lambda
Ā 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)
Ā 
Java collection
Java collectionJava collection
Java collection
Ā 
07 java collection
07 java collection07 java collection
07 java collection
Ā 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
Ā 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
Ā 
Java Lambda Expressions.pptx
Java Lambda Expressions.pptxJava Lambda Expressions.pptx
Java Lambda Expressions.pptx
Ā 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
Ā 
Gradle
GradleGradle
Gradle
Ā 
Introduce yourself to java 17
Introduce yourself to java 17Introduce yourself to java 17
Introduce yourself to java 17
Ā 

Similar to Java 10 New Features

java new technology
java new technologyjava new technology
java new technology
chavdagirimal
Ā 
[JOI] TOTVS Developers Joinville - Java #1
[JOI] TOTVS Developers Joinville - Java #1[JOI] TOTVS Developers Joinville - Java #1
[JOI] TOTVS Developers Joinville - Java #1
Rubens Dos Santos Filho
Ā 
Features java9
Features java9Features java9
Features java9
srmohan06
Ā 
Java 9-coding-from-zero-level-v1.0
Java 9-coding-from-zero-level-v1.0Java 9-coding-from-zero-level-v1.0
Java 9-coding-from-zero-level-v1.0
Parikshit Kumar Singh
Ā 
What is new in node 8
What is new in node 8 What is new in node 8
What is new in node 8
OnGraph Technologies Pvt. Ltd.
Ā 
Follow these reasons to know javaā€™s importance
Follow these reasons to know javaā€™s importanceFollow these reasons to know javaā€™s importance
Follow these reasons to know javaā€™s importance
nishajj
Ā 
The features of java 11 vs. java 12
The features of  java 11 vs. java 12The features of  java 11 vs. java 12
The features of java 11 vs. java 12
FarjanaAhmed3
Ā 
Java7
Java7Java7
Java7
Dinesh Guntha
Ā 
Angular 11 ā€“ everything you need to know
Angular 11 ā€“ everything you need to knowAngular 11 ā€“ everything you need to know
Angular 11 ā€“ everything you need to know
WebGuru Infosystems Pvt. Ltd.
Ā 
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performance
Red Hat
Ā 
Top Features And Updates Of Angular 13 You Must Know
Top Features And Updates Of Angular 13 You Must KnowTop Features And Updates Of Angular 13 You Must Know
Top Features And Updates Of Angular 13 You Must Know
Andolasoft Inc
Ā 
Java 9 and Beyond
Java 9 and BeyondJava 9 and Beyond
Java 9 and Beyond
Mayank Patel
Ā 
Microsoft .NET 6 -What's All About The New Update
Microsoft .NET 6 -What's All About The New UpdateMicrosoft .NET 6 -What's All About The New Update
Microsoft .NET 6 -What's All About The New Update
Adam John
Ā 
What's Expected in Java 7
What's Expected in Java 7What's Expected in Java 7
What's Expected in Java 7
Gal Marder
Ā 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
Prabu U
Ā 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
Srijan Technologies
Ā 
What angular 13 will bring to the table
What angular 13 will bring to the table What angular 13 will bring to the table
What angular 13 will bring to the table
Moon Technolabs Pvt. Ltd.
Ā 
Brief introduction to Angular 2.0 & 4.0
Brief introduction to Angular 2.0 & 4.0Brief introduction to Angular 2.0 & 4.0
Brief introduction to Angular 2.0 & 4.0
Nisheed Jagadish
Ā 
Angular version 10 is here check out the new features, notable changes, depr...
Angular version 10 is here  check out the new features, notable changes, depr...Angular version 10 is here  check out the new features, notable changes, depr...
Angular version 10 is here check out the new features, notable changes, depr...
Katy Slemon
Ā 
Fabric8 - Being devOps doesn't suck anymore
Fabric8 - Being devOps doesn't suck anymoreFabric8 - Being devOps doesn't suck anymore
Fabric8 - Being devOps doesn't suck anymore
Henryk Konsek
Ā 

Similar to Java 10 New Features (20)

java new technology
java new technologyjava new technology
java new technology
Ā 
[JOI] TOTVS Developers Joinville - Java #1
[JOI] TOTVS Developers Joinville - Java #1[JOI] TOTVS Developers Joinville - Java #1
[JOI] TOTVS Developers Joinville - Java #1
Ā 
Features java9
Features java9Features java9
Features java9
Ā 
Java 9-coding-from-zero-level-v1.0
Java 9-coding-from-zero-level-v1.0Java 9-coding-from-zero-level-v1.0
Java 9-coding-from-zero-level-v1.0
Ā 
What is new in node 8
What is new in node 8 What is new in node 8
What is new in node 8
Ā 
Follow these reasons to know javaā€™s importance
Follow these reasons to know javaā€™s importanceFollow these reasons to know javaā€™s importance
Follow these reasons to know javaā€™s importance
Ā 
The features of java 11 vs. java 12
The features of  java 11 vs. java 12The features of  java 11 vs. java 12
The features of java 11 vs. java 12
Ā 
Java7
Java7Java7
Java7
Ā 
Angular 11 ā€“ everything you need to know
Angular 11 ā€“ everything you need to knowAngular 11 ā€“ everything you need to know
Angular 11 ā€“ everything you need to know
Ā 
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performance
Ā 
Top Features And Updates Of Angular 13 You Must Know
Top Features And Updates Of Angular 13 You Must KnowTop Features And Updates Of Angular 13 You Must Know
Top Features And Updates Of Angular 13 You Must Know
Ā 
Java 9 and Beyond
Java 9 and BeyondJava 9 and Beyond
Java 9 and Beyond
Ā 
Microsoft .NET 6 -What's All About The New Update
Microsoft .NET 6 -What's All About The New UpdateMicrosoft .NET 6 -What's All About The New Update
Microsoft .NET 6 -What's All About The New Update
Ā 
What's Expected in Java 7
What's Expected in Java 7What's Expected in Java 7
What's Expected in Java 7
Ā 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
Ā 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
Ā 
What angular 13 will bring to the table
What angular 13 will bring to the table What angular 13 will bring to the table
What angular 13 will bring to the table
Ā 
Brief introduction to Angular 2.0 & 4.0
Brief introduction to Angular 2.0 & 4.0Brief introduction to Angular 2.0 & 4.0
Brief introduction to Angular 2.0 & 4.0
Ā 
Angular version 10 is here check out the new features, notable changes, depr...
Angular version 10 is here  check out the new features, notable changes, depr...Angular version 10 is here  check out the new features, notable changes, depr...
Angular version 10 is here check out the new features, notable changes, depr...
Ā 
Fabric8 - Being devOps doesn't suck anymore
Fabric8 - Being devOps doesn't suck anymoreFabric8 - Being devOps doesn't suck anymore
Fabric8 - Being devOps doesn't suck anymore
Ā 

Recently uploaded

Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
Ā 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
Ā 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
Ā 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
Ā 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
Ā 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
Ā 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
Ā 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
Ā 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
Ā 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
Ā 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
Ā 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
Ā 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
Ā 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
Ā 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
Ā 
Paketo Buildpacks : la meilleure faƧon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure faƧon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure faƧon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure faƧon de construire des images OCI? DevopsDa...
Anthony Dahanne
Ā 
Dominate Social Media with TubeTrivia AIā€™s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AIā€™s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AIā€™s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AIā€™s Addictive Quiz Videos.pdf
AMB-Review
Ā 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
Ā 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
Ā 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
Ā 

Recently uploaded (20)

Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Ā 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Ā 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Ā 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Ā 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Ā 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Ā 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Ā 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Ā 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Ā 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Ā 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Ā 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Ā 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Ā 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
Ā 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Ā 
Paketo Buildpacks : la meilleure faƧon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure faƧon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure faƧon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure faƧon de construire des images OCI? DevopsDa...
Ā 
Dominate Social Media with TubeTrivia AIā€™s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AIā€™s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AIā€™s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AIā€™s Addictive Quiz Videos.pdf
Ā 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Ā 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Ā 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Ā 

Java 10 New Features

  • 2. WHAT IS NEW IN JAVA 10 Java 10 contains various new features and enhancements. This is the fastest release of a java version in its 23 year history :) 1. New Features in Language 2. New Features in Compiler 3. New Features in Libraries 4. New Features in Tools 5. New Features in Runtime 6. Miscellaneous Changes 2
  • 3. WHAT IS NEW IN JAVA 10 1. NEW FEATURES IN LANGUAGE 1. Local variable type inference 2. Time-Based Release Versioning 3. Root Certiļ¬cates 3
  • 4. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE 1.1 LOCAL VARIABLE TYPE INFERENCE ā€£ Java is known to be a bit verbose, which can be good when it comes to understanding what you or another developer had in mind when a function was written. Local variable type inference feature breaks this rule. ā€£ Local variable type inference is the biggest new feature in Java 10 for developers. ā€£ With the exception of assert from the Java 1.4 days, new keywords always seem to make a big splash, and var is no different. ā€£ What the var keyword does is turn local variable assignments:ā€Ø ā€Ø Map<String, String> myMap = new HashMap<>();ā€Ø ā€Ø into:ā€Ø ā€Ø var thisIsAlsoMyMap = new HashMap<String, String>(); 4
  • 5. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE 1.1 LOCAL VARIABLE TYPE INFERENCE ā€£ Local type inference can be used only in the following scenarios: - Limited only to local variable with initializer - Indexes of enhanced for loop or indexes - Local declared in for loop ā€£ It cannot be used for member variables, method parameters, return types, etc. ā€£ var is not a keyword ā€“ this ensures backward compatibility for programs using var as a function or variable name. 5
  • 6. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE 1.1 LOCAL VARIABLE TYPE INFERENCE ā€£ We canā€™t use ā€˜varā€™ in scenarios below: - var n; // cannot use 'var' without initializer - var emptyList = null; // variable initializer is ā€˜null' - public var = "hello"; // 'var' is not allowed here - var p = (String s) -> s.length() > 10; // lambda expression needs an explicit target-type - var arr = { 1, 2, 3 }; // array initializer needs an explicit target-type 6
  • 7. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE 1.1 LOCAL VARIABLE TYPE INFERENCE ā€£ Example:ā€Ø ā€Ø var numbers = List.of(1, 2, 3, 4, 5); // inferred value ArrayList<String>ā€Ø ā€Ø // Index of Enhanced For Loopā€Ø for (var number : numbers) {ā€Ø System.out.println(number);ā€Ø }ā€Ø ā€Ø // Local variable declared in a loopā€Ø for (var i = 0; i < numbers.size(); i++) {ā€Ø System.out.println(numbers.get(i));ā€Ø } 7
  • 8. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE 1.2 TIME-BASED RELEASE VERSIONING ā€£ The development of new Java versions was, up until now, very feature driven. ā€£ This meant that you had to wait for a few years for the next release. ā€£ Oracle has now switched to a new, time based model. ā€£ Not everyone agrees with this proceeding. Larger companies also appreciated the stability and the low rate of change of Java so far 8
  • 9. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE 1.2 TIME-BASED RELEASE VERSIONING ā€£ Oracle has responded to these concerns and continues to offer long-term releases on a regular basis, but also at longer intervals. And after Java 8, it is Java 11, which will receive a long term support again. ā€£ Java 9 and Java 10 on the other hand will only be supported for the time period of half a year, until the next release is due. ā€£ In fact, Java 9 and Java 10 support has just ended, since Java 11 is out. 9
  • 10. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE 1.2 TIME-BASED RELEASE VERSIONING ā€£ With adoption of time based release cycle, Oracle changed the version-string scheme of the Java SE Platform and the JDK, and related versioning information, for present and future time-based release models ā€£ The new pattern of the Version number is: FEATURE.INTERIM.UPDATE.PATCH ā€£ FEATURE: counter will be incremented every 6 months and will be based on feature release versions, e.g: JDK 10, JDK 11. ā€£ INTERIM: counter will be incremented for non-feature releases that contain compatible bug ļ¬xes and enhancements but no incompatible changes. ā€£ UPDATE: counter will be incremented for compatible update releases that ļ¬x security issues, regressions, and bugs in newer features. ā€£ PATCH: counter will be incremented for an emergency release to ļ¬x a critical issue. 10
  • 11. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LANGUAGE 1.3 ROOT CERTIFICATES ā€£ The cacerts keystore, which was initially empty so far, is intended to contain a set of root certiļ¬cates that can be used to establish trust in the certiļ¬cate chains used by various security protocols. ā€£ With Java 10, Oracle has open-sourced the root certiļ¬cates in Oracleā€™s Java SE Root CA program in order to make OpenJDK builds more attractive to developers and to reduce the differences between those builds and Oracle JDK builds. ā€£ Basically, this means that now doing simple things like communicating over HTTPS between your application and, say, a Google RESTful service will be much simpler with OpenJDK. 11
  • 12. WHAT IS NEW IN JAVA 10 2. NEW FEATURES IN COMPILER 1. Experimental Java-Based JIT Compiler 2. Bytecode Generation for Enhanced for Loop 12
  • 13. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN COMPILER 2.1 EXPERIMENTAL JAVA-BASED JIT COMPILER ā€£ The Just-In-Time (JIT) Compiler is the part of java that converts java byte code into machine code at runtime. It was written in c++ ā€£ This feature enables the Java-based JIT compiler, Graal, to be used as an experimental JIT compiler on the Linux/x64 platform. ā€£ Graal is a complete rewrite of the JIT compiler in java from scratch. ā€£ To enable Graal, add these ļ¬‚ags to your command line arguments when starting the application:ā€Ø ā€Ø -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler ā€£ Keep in mind that the Graal team makes no promises in this ļ¬rst release that this compiler is any faster. 13
  • 14. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN COMPILER 2.2 BYTE CODE GENERATION FOR ENHANCED FOR LOOP ā€£ Bytecode generation has been improved for enhanced for loops, providing an improvement in the translation approach for them. For example:ā€Ø ā€Ø List<String> data = new ArrayList<>(); for (String b : data);ā€Ø ā€Ø The following is the code generated after the enhancement:ā€Ø ā€Ø { /*synthetic*/ Iterator i$ = data.iterator(); for (; i$.hasNext(); ) { String b = (String)i$.next(); } b = null; i$ = null; } ā€£ Declaring the iterator variable outside of the for loop allows a null to be assigned to it as soon as it is no longer used ā€£ This makes it accessible to the GC, which can then get rid of the unused memory. 14
  • 15. WHAT IS NEW IN JAVA 10 3. NEW FEATURES IN LIBRARIES 1. Creating Unmodiļ¬able Collections 2. Optional.orElseThrow() Method 15
  • 16. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LIBRARIES 3.1 CREATING UNMODIFIABLE COLLECTIONS 1. Several new APIs have been added that facilitate the creation of unmodiļ¬able collections. 2. The List.copyOf, Set.copyOf, and Map.copyOf methods create new collection instances from existing instances. 3. New methods toUnmodiļ¬ableList, toUnmodiļ¬ableSet, and toUnmodiļ¬ableMap have been added to the Collectors class in the stream package. These methods allow the elements of a Stream to be collected into an unmodiļ¬able collection.ā€Ø ā€Ø Stream<String> myStream = Stream.of("a", "b", "c");ā€Ø List<String> unModiļ¬ableList = myStream.collect(Collectors.toUnmodiļ¬ableList());ā€Ø unModiļ¬ableList.add(ā€œd"); // throws java.lang.UnsupportedOperationException 16
  • 17. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN LIBRARIES 3.2 CREATING UNMODIFIABLE COLLECTIONS ā€£ Optional, OptionalDouble, OptionalInt and OptionalLong each got a new method orElseThrow() which doesnā€™t take any argument and throws NoSuchElementException if no value is present: ā€Ø ā€Ø @Testā€Ø public void whenListContainsInteger_OrElseThrowReturnsInteger() {ā€Ø Integer ļ¬rstEven = someIntList.stream()ā€Ø .ļ¬lter(i -> i % 2 == 0)ā€Ø .ļ¬ndFirst()ā€Ø .orElseThrow();ā€Ø is(ļ¬rstEven).equals(Integer.valueOf(2));ā€Ø } 17
  • 18. WHAT IS NEW IN JAVA 10 4. NEW FEATURES IN TOOLS 1. JShell Startup 2. Removed Tools 18
  • 19. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN TOOLS 4.1 JSHELL STARTUP ā€£ The time needed to start JShell has been signiļ¬cantly reduced, especially in cases where a start ļ¬le with many snippets is used 19
  • 20. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN TOOLS 4.2 REMOVED TOOLS ā€£ Tool javah has been removed from Java 10 which generated C headers and source ļ¬les which were required to implement native methods. Now, javac -h can be used instead. ā€£ policytool was the security tool for policy ļ¬le creation and management. This has now been removed. 20
  • 21. WHAT IS NEW IN JAVA 10 5. NEW FEATURES IN RUNTIME 1. Parallel Full GC for G1 2. Improvements for Docker Containers 3. Application Data-Class Sharing 4. Removed Options 21
  • 22. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN RUNTIME 5.1. PARALLEL FULL GC FOR G1 ā€£ G1 garbage collector was made default in JDK 9. ā€£ However, the full GC for G1 used a single threaded mark-sweep- compact algorithm. ā€£ This has been changed to the parallel mark-sweep-compact algorithm in Java 10 effectively reducing the stop-the-world time during full GC. ā€£ This change wonā€™t help the best-case performance times of the garbage collector, but it does signiļ¬cantly reduce the worst-case latencies. ā€£ When concurrent garbage collection falls behind, it triggers a Full GC collection. 22
  • 23. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN RUNTIME 5.2. IMPROVEMENTS FOR DOCKER CONTAINERS ā€£ The JVM now knows when it is running inside a Docker Container. ā€£ This means the application now has accurate information about what the docker container allocates to memory, CPU, and other system resources. ā€£ Previously, the JVM queried the host operating system to get this information. ā€£ However, this support is only available for Linux-based platforms. 23
  • 24. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN RUNTIME 5.2. IMPROVEMENTS FOR DOCKER CONTAINERS ā€£ There are command line options to specify how the JVM inside a Docker container allocates internal memory. ā€£ This new support is enabled by default and can be disabled in the command line with the JVM option:ā€Ø ā€Ø -XX:-UseContainerSupport ā€£ To set the memory heap to the container group size and limit the number of processors you could pass in these arguments:ā€Ø ā€Ø -XX:+UseCGroupMemoryLimitForHeapā€Š-XX:ActiveProcessorCount=2 ā€£ Three new JVM options have been added to allow Docker container users to gain more ļ¬ne- grained control over the amount of system memory that will be used for the Java Heap:ā€Ø ā€Ø -XX:InitialRAMPercentageā€Ø -XX:MaxRAMPercentageā€Ø -XX:MinRAMPercentage 24
  • 25. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN RUNTIME 5.3. APPLICATION DATA-CLASS SHARING ā€£ Java 5 introduced Class-Data Sharing (CDS) to improve startup times of smaller Java applications. ā€£ CDS only allowed the bootstrap class loader, limiting the feature to system classes only. ā€£ This feature extends the existing CDS feature for allowing application classes to be placed in the shared archive in order to improve startup and footprint. ā€£ The general idea was that when the JVM ļ¬rst launched, anything loaded was serialized and stored in a ļ¬le on disk that could be reloaded on future launches of the JVM. ā€£ This meant that multiple instances of the JVM shared the class metadata so it wouldnā€™t have to load them all every time. 25
  • 26. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN RUNTIME 5.3. APPLICATION DATA-CLASS SHARING ā€£ We can use the following steps to make use of this feature: 1. Get the list of classes to archive:ā€Ø $ java -Xshare:off -XX:+UseAppCDS ā€Ø -XX:DumpLoadedClassList=hello.lst -cp hello.jar HelloWorld 2. Create the AppCDS archive:ā€Ø $ java -Xshare:dump -XX:+UseAppCDS ā€Ø -XX:SharedClassListFile=hello.lst ā€Ø -XX:SharedArchiveFile=hello.jsa -cp hello.jar 3. Use the AppCDS archive:ā€Ø $ java -Xshare:on -XX:+UseAppCDS ā€Ø -XX:SharedArchiveFile=hello.jsa -cp hello.jar HelloWorld 26
  • 27. WHAT IS NEW IN JAVA 10 - NEW FEATURES IN RUNTIME 5.4. REMOVED OPTIONS ā€£ Removal of FlatProļ¬ler: The FlatProļ¬ler, deprecated in JDK 9, has been made obsolete by removing the implementation code. The FlatProļ¬ler was enabled by setting the -Xprof VM argument. The -Xprof ļ¬‚ag remains recognized in this release; however, setting it will print out a warning message ā€£ Removal of Obsolete -X Options: The obsolete HotSpot VM options (-Xoss, -Xsqnopause, -Xoptimize, - Xboundthreads, and -Xusealtsigs) have been removed 27
  • 28. WHAT IS NEW IN JAVA 10 6. MISCELLANEOUS CHANGES ā€£ Class File Version Number is 54.0:ā€Ø The class ļ¬le version has been changed from 53 (or 44 + 9) to 54 (44 +10), even though JDK 10 did not introduce other changes to the class ļ¬le format. ā€£ Consolidate the JDK Forest into a Single Repository:ā€Ø Combined the numerous repositories of the JDK forest into a single repository to simplify and streamline development. The code base until now has been broken into multiple repos, which can cause problems with source-code management. ā€£ Additional Unicode Language-Tag Extensions:ā€Ø Enhanced the java.util.Locale and related APIs to implement additional Unicode extensions of BCP 47 language tags. ā€£ Garbage Collector Interface:ā€Ø A clean garbage collector interface to improve source-code isolation of different garbage collectors. The goals for this effort include better modularity for internal garbage collection code in the HotSpot virtual machine and making it easier to add a new garbage collector to HotSpot. 28
  • 29. WHAT IS NEW IN JAVA 10 6. MISCELLANEOUS CHANGES ā€£ Heap Allocation on Alternative Memory Devices:ā€Ø It enables the HotSpot VM to allocate the Java object heap on an alternative memory device, such as an NV-DIMM, speciļ¬ed by the user. ā€£ Thread-Local Handshakesā€Ø This is an internal JVM feature to improve performance. This feature provides a way to execute a callback on threads without performing a global VM safepoint. Make it both possible and cheap to stop individual threads and not just all threads or none. 29
  • 30. WHAT IS NEW IN JAVA 10 SOURCES - https://www.oracle.com/technetwork/java/javase/10- relnote-issues-4108729.html - http://cr.openjdk.java.net/~iris/se/10/latestSpec/ - https://www.baeldung.com/java-10-overview - https://stackify.com/whats-new-in-java-10/ - https://www.journaldev.com/20395/java-10-features - https://www.quora.com/What-is-new-in-Java-10 30