Java 10changes to JDK 10 Jose Marcano Sr

  • Slides: 34
Download presentation
Java 10–changes to JDK 10. Jose Marcano, Sr. Software Engineer, May 15, 2018 FOR

Java 10–changes to JDK 10. Jose Marcano, Sr. Software Engineer, May 15, 2018 FOR INTERNAL USE ONLY AT MITCHELL. NOT INTENDED FOR EXTERNAL DISTRIBUTION. Confidential and Proprietary. © 2011 Mitchell International, Inc.

Java biggest changes • • 6/4/2021 | Page 2 Java 5 generics Java 7

Java biggest changes • • 6/4/2021 | Page 2 Java 5 generics Java 7 GC 1/NIO. Java 8 Lambdas/Streams Java 9 Modules. Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP and JSR Definition • JEP – JDK Enhancement Proposal • JSR – Java

JEP and JSR Definition • JEP – JDK Enhancement Proposal • JSR – Java Specification Request 6/4/2021 | Page 3 Confidential and Proprietary. © 2018 Mitchell International, Inc.

Java 10 changes • • • 6/4/2021 | Page 4 JEP-286: Local-Variable Type Inference

Java 10 changes • • • 6/4/2021 | Page 4 JEP-286: Local-Variable Type Inference JEP-296: Consolidate the JDK Forest into a Single Repository JEP-304: Garbage-Collector Interface JEP-307: Parallel Full GC for G 1 JEP-310: Application Class-Data Sharing JEP-312: Thread-Local Handshakes JEP-313: Remove the Native-Header Generation Tool (javah) JEP-314: Additional Unicode Language-Tag Extensions JEP-316: Heap Allocation on Alternative Memory Devices JEP-317: Experimental Java-Based JIT Compiler JEP-319: Root Certificates JEP-322: Time-Based Release Versioning Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-286 var • Local variable type inference, to enhance the Java language to extend

JEP-286 var • Local variable type inference, to enhance the Java language to extend type inference to declarations of local variables with initializers. – Before Java 10: • List<String> list = new Array. List<String>(); URL url = new URL("http: //www. oracle. com/"); • URLConnection conn = url. open. Connection(); • Reader reader = new Buffered. Reader( new Input. Stream. Reader(conn. get. Input. Stream())); – Java 10: • var list = new Array. List<String>(); var url = new URL("http: //www. oracle. com/"); • var conn = url. open. Connection(); • var reader = new Buffered. Reader( new Input. Stream. Reader(conn. get. Input. Stream())); 6/4/2021 | Page 5 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-286 var • Local variable type inference, to enhance the Java language to extend

JEP-286 var • Local variable type inference, to enhance the Java language to extend type inference to declarations of local variables with initializers. • List<String> list = new Array. List<>(); To • var list = new Array. List<>(); • Is list a List<String> ? No it is a List<Object> 6/4/2021 | Page 6 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-286 var • The var will be restricted to: – Local variables with initializers

JEP-286 var • The var will be restricted to: – Local variables with initializers – Indexes in the enhanced for-loop – Locals declared in a traditional for-loop • It will not be available for: – – – 6/4/2021 | Page 7 Method parameters Constructor parameters Method return types Fields Catch formals (or any other kind of variable declaration) Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-296: Consolidate the JDK Forest into a Single Repository • In JDK 9 there

JEP-296: Consolidate the JDK Forest into a Single Repository • In JDK 9 there are eight repos: root, corba, hotspot, jaxp, jaxws, jdk, langtools, and nashorn. • The idea is to combine many repositories of the JDK forest into a single repository to simplify development. 6/4/2021 | Page 8 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-304: Garbage-Collector Interface • Improve the source code isolation of different garbage collectors by

JEP-304: Garbage-Collector Interface • Improve the source code isolation of different garbage collectors by introducing a clean garbage collector (GC) interface • Better modularity for Hot. Spot internal GC code • Make it simpler to add a new GC to Hot. Spot without perturbing the current code base • Make it easier to exclude a GC from a JDK build 6/4/2021 | Page 9 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-307: Parallel Full GC for G 1 • G 1 became the default garbage

JEP-307: Parallel Full GC for G 1 • G 1 became the default garbage collector in JDK 9. Its design tries to avoid full GC • G 1 only uses a single-threaded mark-sweep-compact algorithm to perform a full collection • The previous default, the parallel collector, has a parallel full GC To minimize the impact for users experiencing full GCs, the G 1 full GC should be made parallel as well • The number of threads can be controlled by the XX: Parallel. GCThreads option • Improve G 1 worst-case latencies 6/4/2021 | Page 10 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-310: Application Class-Data Sharing • Introduced in JDK 5 • To improve startup and

JEP-310: Application Class-Data Sharing • Introduced in JDK 5 • To improve startup and footprint, this JEP extends the existing Class-Data Sharing ("CDS") feature to allow application classes to be placed in the shared archive • Until Java 10, it was only possible to use CDS with bootstrap class loader. • Java 10 enables CDS for system / application class loader with XX: +Use. App. CDS option 6/4/2021 | Page 11 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-312: Thread-Local Handshakes • Introduce a way to execute a callback on threads without

JEP-312: Thread-Local Handshakes • Introduce a way to execute a callback on threads without performing a global VM safepoint • Makes it both possible and cheap to stop individual threads and not just all threads or none. • A handshake operation is a callback that is executed for each Java. Thread while that thread is in a safepoint safe state • Thread-local handshakes will be implemented initially on x 64 and SPARC. Other platforms will fall back to normal safepoints. 6/4/2021 | Page 12 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-312: Thread-Local Handshakes • what’s a safepoint? • Stop-the-World pause mechanism • Stopping all

JEP-312: Thread-Local Handshakes • what’s a safepoint? • Stop-the-World pause mechanism • Stopping all threads are required to ensure that safepoint initiator has exclusive access to JVM data structure and can perform certain operations. • When a safepoint call is issued all of the application threads should "come to safepoint" as fast as possible. • Threads that have come to safepoint block until the JVM releases them 6/4/2021 | Page 13 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-312: Thread-Local Handshakes When safepoints are used? • Garbage collection pauses • Flushing code

JEP-312: Thread-Local Handshakes When safepoints are used? • Garbage collection pauses • Flushing code cache • Class redefinition (e. g. hot swap or instrumentation) • Biased lock revocation • Various debug operation (e. g. deadlock check or stack trace dump) 6/4/2021 | Page 14 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-313: Remove the Native-Header Generation Tool (javah) • Remove the javah tool from the

JEP-313: Remove the Native-Header Generation Tool (javah) • Remove the javah tool from the JDK since it has been superseded by superior functionality in javac. 6/4/2021 | Page 15 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-314: Additional Unicode Language-Tag Extensions • Additional Unicode Language-Tag Extensions: Enhances java. util. Locale

JEP-314: Additional Unicode Language-Tag Extensions • Additional Unicode Language-Tag Extensions: Enhances java. util. Locale and related APIs to implement additional Unicode extensions of BCP 47 language tags. • As of Java SE 9, the supported BCP 47 U language-tag extensions are ca and nu. This JEP will add support for the following additional extensions: – – 6/4/2021 | Page 16 cu (currency type) fw (first day of week) rg (region override) tz (time zone) Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-314: Additional Unicode Language-Tag Extensions • Additional Unicode Language-Tag Extensions: Enhances java. util. Locale

JEP-314: Additional Unicode Language-Tag Extensions • Additional Unicode Language-Tag Extensions: Enhances java. util. Locale and related APIs to implement additional Unicode extensions of BCP 47 language tags. • As of Java SE 9, the supported BCP 47 U language-tag extensions are ca and nu. This JEP will add support for the following additional extensions: – – 6/4/2021 | Page 17 cu (currency type) fw (first day of week) rg (region override) tz (time zone) Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-314: Additional Unicode Language-Tag Extensions • jshell> Currency. get. Instance(Locale. for. Language. Tag("de. CH")).

JEP-314: Additional Unicode Language-Tag Extensions • jshell> Currency. get. Instance(Locale. for. Language. Tag("de. CH")). get. Symbol() $22 ==> "CHF“ • jshell> Currency. get. Instance(Locale. for. Language. Tag("de-CH-u-cuusd")). get. Symbol() $25 ==> "$" 6/4/2021 | Page 18 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-316: Heap Allocation on Alternative Memory Devices • Enables the Hot. Spot VM to

JEP-316: Heap Allocation on Alternative Memory Devices • Enables the Hot. Spot VM to allocate the Java object heap on an alternative memory device, such as an NV-DIMM, specified by the user. 6/4/2021 | Page 19 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-316: Heap Allocation on Alternative Memory Devices • Some use cases for this proposal

JEP-316: Heap Allocation on Alternative Memory Devices • Some use cases for this proposal are: • In multi-JVM deployments some JVMs such as daemons, services, etc. , have lower priority than others. NV-DIMMs would potentially have higher access latency compared to DRAM. Lowpriority processes can use NV-DIMM memory for the heap, allowing high-priority processes to use more DRAM. • Applications such as big data and in-memory databases have an ever-increasing demand for memory. Such applications could use NV-DIMM for the heap since NV-DIMMs would potentially have a larger capacity, at lower cost, compared to DRAM. 6/4/2021 | Page 20 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-316: Heap Allocation on Alternative Memory Devices • To allocate the heap in such

JEP-316: Heap Allocation on Alternative Memory Devices • To allocate the heap in such memory we can add a new option, XX: Allocate. Heap. At=<path>. This option would take a path to the file system and use memory mapping to achieve the desired result of allocating the object heap on the memory device • The JEP does not intend to share a non-volatile region between multiple running JVMs or re-use the same region for further invocations of the JVM. • The existing heap related flags such as -Xmx, -Xms, etc. , and garbage-collection related flags would continue to work as before. 6/4/2021 | Page 21 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-317: Experimental Java-Based JIT Compiler • Enables the Java-based JIT compiler, Graal, to be

JEP-317: Experimental Java-Based JIT Compiler • Enables the Java-based JIT compiler, Graal, to be used as an experimental JIT compiler on the Linux/x 64 platform • Graal, is the basis of the experimental Ahead-of-Time (AOT) compiler introduced in JDK 9 • To enable Graal as the JIT compiler, use the following options on the java command line: – -XX: +Unlock. Experimental. VMOptions -XX: +Use. JVMCICompiler 6/4/2021 | Page 22 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-319: Root Certificates • Provides a default set of root Certification Authority (CA) certificates

JEP-319: Root Certificates • Provides a default set of root Certification Authority (CA) certificates in the JDK. • Open-source the root certificates in Oracle's Java SE Root CA program in order to make Open. JDK builds more attractive to developers, and to reduce the differences between those builds and Oracle JDK builds. 6/4/2021 | Page 23 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-319: Root Certificates • Provides a default set of root Certification Authority (CA) certificates

JEP-319: Root Certificates • Provides a default set of root Certification Authority (CA) certificates in the JDK. • Open-source the root certificates in Oracle's Java SE Root CA program in order to make Open. JDK builds more attractive to developers, and to reduce the differences between those builds and Oracle JDK builds. 6/4/2021 | Page 24 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-322: Time-Based Release Versioning • Revises the version-string scheme of the Java SE Platform

JEP-322: Time-Based Release Versioning • Revises 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 version-string scheme introduced by JEP 223 was a significant improvement over that of the past. That scheme is not, however, well-suited to the future, in which we intend to ship new releases of the Java SE Platform and the JDK on a strict, six-month cadence. 6/4/2021 | Page 25 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-322: Time-Based Release Versioning • Under the six-month release model the elements of version

JEP-322: Time-Based Release Versioning • Under the six-month release model the elements of version numbers vary as follows: • $FEATURE is incremented every six months: The March 2018 release is JDK 10, the September 2018 release is JDK 11, and so forth. • $INTERIM is always zero, since the six-month model does not include interim releases. We reserve it here for flexibility, so that a future revision to the release model could include such releases 6/4/2021 | Page 26 Confidential and Proprietary. © 2018 Mitchell International, Inc.

JEP-322: Time-Based Release Versioning • $UPDATE is incremented one month after $FEATURE is incremented,

JEP-322: Time-Based Release Versioning • $UPDATE is incremented one month after $FEATURE is incremented, and every three months thereafter: The April 2018 release is JDK 10. 0. 1, the July release is JDK 10. 0. 2, and so forth. • $PATCH — The emergency patch-release counter, incremented only when it's necessary to produce an emergency release to fix a critical issue 6/4/2021 | Page 27 Confidential and Proprietary. © 2018 Mitchell International, Inc.

Java Improvements for Docker Containers • JDK-8146115 Improve docker container detection and resource configuration

Java Improvements for Docker Containers • JDK-8146115 Improve docker container detection and resource configuration usage • The JVM has been modified to be aware that it is running in a Docker container and will extract container specific configuration information instead of querying the operating system • The information being extracted is the number of CPUs and total memory that have been allocated to the container. The total number of CPUs available to the Java process is calculated from any specified cpu sets, cpu shares or cpu quotas. 6/4/2021 | Page 28 Confidential and Proprietary. © 2018 Mitchell International, Inc.

Java Improvements for Docker Containers • JDK-8146115 Improve docker container detection and resource configuration

Java Improvements for Docker Containers • JDK-8146115 Improve docker container detection and resource configuration usage • This support is only available on Linux-based platforms. This new support is enabled by default and can be disabled in the command line with the JVM option: -XX: -Use. Container. Support • In addition, this change adds a JVM option that provides the ability to specify the number of CPUs that the JVM will use: -XX: Active. Processor. Count=count – This count overrides any other automatic CPU detection logic in the JVM. 6/4/2021 | Page 29 Confidential and Proprietary. © 2018 Mitchell International, Inc.

Java Improvements for Docker Containers • JDK-8186248 Allow more flexibility in selecting Heap %

Java Improvements for Docker Containers • JDK-8186248 Allow more flexibility in selecting Heap % of available RAM • 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: Initial. RAMPercentage -XX: Max. RAMPercentage -XX: Min. RAMPercentage • These options replace the deprecated Fraction forms (XX: Initial. RAMFraction, -XX: Max. RAMFraction, and XX: Min. RAMFraction). 6/4/2021 | Page 30 Confidential and Proprietary. © 2018 Mitchell International, Inc.

Optional. or. Else. Throw() Method • JDK-8140281 : (opt) add no-arg or. Else. Throw()

Optional. or. Else. Throw() Method • JDK-8140281 : (opt) add no-arg or. Else. Throw() as preferred alternative to get() • A new method or. Else. Throw has been added to the Optional class. It is synonymous with and is now the preferred alternative to the existing get method. 6/4/2021 | Page 31 Confidential and Proprietary. © 2018 Mitchell International, Inc.

APIs for Creating Unmodifiable Collections • The List. copy. Of, Set. copy. Of, and

APIs for Creating Unmodifiable Collections • The List. copy. Of, Set. copy. Of, and Map. copy. Of methods create new collection instances from existing instances. • to. Unmodifiable. List, to. Unmodifiable. Set, and to. Unmodifiable. Map have been added to the Collectors class in the Stream package. 6/4/2021 | Page 32 Confidential and Proprietary. © 2018 Mitchell International, Inc.

Information • For more information visit: 1. http: //openjdk. java. net/projects/jdk 10/ 6/4/2021 |

Information • For more information visit: 1. http: //openjdk. java. net/projects/jdk 10/ 6/4/2021 | Page 33 Confidential and Proprietary. © 2018 Mitchell International, Inc.

Questions? 6/4/2021 | Page 34 Confidential and Proprietary. © 2018 Mitchell International, Inc.

Questions? 6/4/2021 | Page 34 Confidential and Proprietary. © 2018 Mitchell International, Inc.