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 Certificates
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 fixes and enhancements but no incompatible changes.
‣ UPDATE: counter will be incremented for compatible update releases that fix
security issues, regressions, and bugs in newer features.
‣ PATCH: counter will be incremented for an emergency release to fix 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 certificates that can be used to
establish trust in the certificate chains used by various security
protocols.
‣ With Java 10, Oracle has open-sourced the root certificates 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 flags 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 first 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 Unmodifiable 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 unmodifiable
collections.
2. The List.copyOf, Set.copyOf, and Map.copyOf methods create new collection
instances from existing instances.
3. New methods toUnmodifiableList, toUnmodifiableSet, and
toUnmodifiableMap have been added to the Collectors class in the stream
package. These methods allow the elements of a Stream to be collected into
an unmodifiable collection.



Stream<String> myStream = Stream.of("a", "b", "c");

List<String> unModifiableList =
myStream.collect(Collectors.toUnmodifiableList());

unModifiableList.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 firstEven = someIntList.stream()

.filter(i -> i % 2 == 0)

.findFirst()

.orElseThrow();

is(firstEven).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 significantly
reduced, especially in cases where a start file 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 files which were required
to implement native methods. Now, javac -h can be used
instead.
‣ policytool was the security tool for policy file 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 significantly 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 fine-
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 first launched, anything loaded was
serialized and stored in a file 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 FlatProfiler: The FlatProfiler, deprecated in
JDK 9, has been made obsolete by removing the
implementation code. The FlatProfiler was enabled by
setting the -Xprof VM argument. The -Xprof flag 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 file 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 file 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,
specified 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

ODP
Java 9 Features
PDF
Java 9 New Features
ODP
Java 9/10/11 - What's new and why you should upgrade
PDF
Introduction to Java 11
PDF
Java11 New Features
PPTX
Migrating to Java 11
PDF
Spring Boot
Java 9 Features
Java 9 New Features
Java 9/10/11 - What's new and why you should upgrade
Introduction to Java 11
Java11 New Features
Migrating to Java 11
Spring Boot

What's hot (20)

PDF
An Introduction to Gradle for Java Developers
PDF
Gradle Introduction
PPTX
Maven tutorial
PDF
Upgrade to java 16 or 17
PDF
Java modules
PDF
JVM Under The Hood WDI.pdf
PDF
Introduction To Git For Version Control Architecture And Common Commands Comp...
PPTX
Spring boot
PDF
SOLID Design Principles applied in Java
PDF
Introduction to gradle
PDF
Introduction to Spring Boot!
PDF
Java 8 Workshop
PPTX
Exploring the power of Gradle in android studio - Basics & Beyond
PDF
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...
PDF
Basic Java Programming
PPTX
Core java
PPTX
Design principles - SOLID
PPTX
Optional in Java 8
PPTX
Spring boot Introduction
PDF
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
An Introduction to Gradle for Java Developers
Gradle Introduction
Maven tutorial
Upgrade to java 16 or 17
Java modules
JVM Under The Hood WDI.pdf
Introduction To Git For Version Control Architecture And Common Commands Comp...
Spring boot
SOLID Design Principles applied in Java
Introduction to gradle
Introduction to Spring Boot!
Java 8 Workshop
Exploring the power of Gradle in android studio - Basics & Beyond
Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Begin...
Basic Java Programming
Core java
Design principles - SOLID
Optional in Java 8
Spring boot Introduction
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
Ad

Similar to Java 10 New Features (20)

PDF
Summary of JDK10 and What will come into JDK11
PDF
Java 10 - Key Note
PDF
Java10 and Java11 at JJUG CCC 2018 Spr
PDF
Summary of JDK10 and What will come into JDK11
ODP
Java 10 - Updates
PDF
JDK 10 Java Module System
PPT
PPTX
java new technology
PPTX
New thing in JDK10 even that scala-er should know
PDF
Java jdk-update-nov10-sde-v3m
PDF
What's New in IBM Java 8 SE?
PDF
Highlights from Java 10, 11 and 12 and Future of Java at JUG Koblenz
PPTX
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
PDF
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
PPTX
Top 10 Java Interview Questions for freshers.
PDF
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
PPTX
Classes and Objects
PPT
Java SE 7 New Features and Enhancements
PPTX
The Next Generation of Java — Oleksandr Navka
PDF
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
Summary of JDK10 and What will come into JDK11
Java 10 - Key Note
Java10 and Java11 at JJUG CCC 2018 Spr
Summary of JDK10 and What will come into JDK11
Java 10 - Updates
JDK 10 Java Module System
java new technology
New thing in JDK10 even that scala-er should know
Java jdk-update-nov10-sde-v3m
What's New in IBM Java 8 SE?
Highlights from Java 10, 11 and 12 and Future of Java at JUG Koblenz
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Top 10 Java Interview Questions for freshers.
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
Classes and Objects
Java SE 7 New Features and Enhancements
The Next Generation of Java — Oleksandr Navka
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
Ad

Recently uploaded (20)

PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
history of c programming in notes for students .pptx
PPTX
ai tools demonstartion for schools and inter college
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
medical staffing services at VALiNTRY
PDF
Understanding Forklifts - TECH EHS Solution
PDF
System and Network Administraation Chapter 3
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
L1 - Introduction to python Backend.pptx
PDF
top salesforce developer skills in 2025.pdf
How Creative Agencies Leverage Project Management Software.pdf
history of c programming in notes for students .pptx
ai tools demonstartion for schools and inter college
VVF-Customer-Presentation2025-Ver1.9.pptx
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
medical staffing services at VALiNTRY
Understanding Forklifts - TECH EHS Solution
System and Network Administraation Chapter 3
CHAPTER 2 - PM Management and IT Context
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
How to Migrate SBCGlobal Email to Yahoo Easily
Which alternative to Crystal Reports is best for small or large businesses.pdf
Design an Analysis of Algorithms I-SECS-1021-03
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Softaken Excel to vCard Converter Software.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Odoo POS Development Services by CandidRoot Solutions
Operating system designcfffgfgggggggvggggggggg
L1 - Introduction to python Backend.pptx
top salesforce developer skills in 2025.pdf

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 Certificates 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 fixes and enhancements but no incompatible changes. ‣ UPDATE: counter will be incremented for compatible update releases that fix security issues, regressions, and bugs in newer features. ‣ PATCH: counter will be incremented for an emergency release to fix 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 certificates that can be used to establish trust in the certificate chains used by various security protocols. ‣ With Java 10, Oracle has open-sourced the root certificates 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 flags 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 first 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 Unmodifiable 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 unmodifiable collections. 2. The List.copyOf, Set.copyOf, and Map.copyOf methods create new collection instances from existing instances. 3. New methods toUnmodifiableList, toUnmodifiableSet, and toUnmodifiableMap have been added to the Collectors class in the stream package. These methods allow the elements of a Stream to be collected into an unmodifiable collection.
 
 Stream<String> myStream = Stream.of("a", "b", "c");
 List<String> unModifiableList = myStream.collect(Collectors.toUnmodifiableList());
 unModifiableList.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 firstEven = someIntList.stream()
 .filter(i -> i % 2 == 0)
 .findFirst()
 .orElseThrow();
 is(firstEven).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 significantly reduced, especially in cases where a start file 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 files which were required to implement native methods. Now, javac -h can be used instead. ‣ policytool was the security tool for policy file 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 significantly 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 fine- 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 first launched, anything loaded was serialized and stored in a file 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 FlatProfiler: The FlatProfiler, deprecated in JDK 9, has been made obsolete by removing the implementation code. The FlatProfiler was enabled by setting the -Xprof VM argument. The -Xprof flag 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 file 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 file 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, specified 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