Book Image

Mastering Java 11 - Second Edition

By : Dr. Edward Lavieri, Mandar Jog
Book Image

Mastering Java 11 - Second Edition

By: Dr. Edward Lavieri, Mandar Jog

Overview of this book

Java 11 is a long-term release and its new features add to the richness of the language. It emphasizes variable-type inference, performance improvements, along with simplified multithreading. The Java platform has a special emphasis on modularity, making this the programming platform of choice for millions of developers. The modern Java platform can be used to build robust software applications, including enterprise-level and mobile applications. Fully updated for Java 11, this book stands to help any Java developer enjoy the richness of the Java programming language. Mastering Java 11 is your one-stop guide to fully understanding recent Java platform updates. It contains detailed explanations of the recent features introduced in Java 9, Java 10, and Java 11 along with obtaining practical guidance on how to apply the new features. As you make your way through the chapters, you'll discover further information on the developments of the Java platform and learn about the changes introduced by the variable handles and Project Coin, along with several enhancements in relation to import statements processing. In the concluding chapters, you'll learn to improve your development productivity, making your applications more efficient. You'll also be able to get to grips with the command-line flags with respect to various utilities and the command-line utility changes featured in the current Java platform. By the end of the book, you'll have obtained an advanced level understanding of the Java platform and its recent changes.
Table of Contents (20 chapters)

Benefiting from changes introduced with Java 10

Java 10 was released in March 2018 and had the 11 features listed here, in addition to the previously covered time-based versioning:

  • Local variable type inference
  • Consolidation of the JDK forest into a single repository
  • Garbage collection interface
  • Parallel full garbage collector for G1
  • Application class-data sharing
  • Thread-local handshakes
  • Removal of the native-header generation tool (javah)
  • Additional Unicode language-tag extensions
  • Heap allocation on alternative memory devices
  • Experimental Java-based JIT compiler
  • Root certificates

A brief overview of these features is covered in this chapter, with more detailed coverage in subsequent chapters.

Local variable type inference

Starting with Java 10, declaring local variables has been simplified. Developers no longer have to include manifest declarations of local variable types. This is accomplished using the new var identifier, as shown in this example:

var myList = new ArrayList<String>();

Using the preceding code, ArrayList<String> is inferred, so we no longer need to use ArrayList<String> myList = new ArrayList<String>();.

Local variable type inference is covered in Chapter 3, Java 11 Fundamentals.

Consolidation of the JDK forest into a single repository

Prior to Java 10, there were eight repositories for the JDK (CORBA, HotSpot, JDK, JAXP, JAX-WS, langtools, Nashorn, and ROOT). With Java 10, these repositories have been consolidated into a single code base. Notably, Java FX was not part of this consolidation. This topic will be explained further in Chapter 2, Discovering Java 11.

Garbage collection interface

Java 10 ushered in enhancements to the garbage collection process. A new garbage collector interface results in improvements that will be detailed in Chapter 7, Leveraging the Default G1 Garbage Collector.

Parallel full garbage collector for G1

In Java 10, the G1 full garbage collector was made parallel. Starting with Java 9, G1 was made the default garbage collector, so this change was of special significance. This change will be detailed in Chapter 7, Leveraging the Default G1 Garbage Collector.

Application class-data sharing

Class-data sharing (CDS) has been extended to support faster application startup and smaller footprints. Using CDS, developers can have specific class files pre-parsed and stored in a shareable archive. We will explore this change to the Java platform in Chapter 2, Discovering Java 11.

Thread-local handshakes

With Java 10 and beyond, it is possible to stop individual threads without having to perform a global virtual machine safepoint. We will fully explore this change in Chapter 3, Java 11 Fundamentals.

Removal of the native-header generation tool (javah)

A concerted effort was undertaken to remove the javah tool from the JDK. This change was warranted because of the functionality available in javac. We will detail this change in Chapter 11, New Tools and Tool Enhancements.

Additional Unicode language-tag extensions

The Java platform has supported language tags since Java 7. In Java 10, changes were made to java.util.Local and related APIs to incorporate additional Unicode language tags. Details will be covered in Chapter 2, Discovering Java 11.

Heap allocation on alternative memory devices

The HotSpot virtual machine, as of Java 10, supports non-DRAM memory devices. This will be explained in Chapter 3, Java 11 Fundamentals.

Experimental Java-based JIT compiler

Java 9 introduced us to a Java-based just-in-time (JIT) compiler. This JIT compiler has been enabled for Linux/x64 platforms. This experimental compiler will be further explored in Chapter 14, Command-Line Flags.

Root certificates

Starting with the release of Java 10, there has been a default set of Certification Authority (CA) certificates as part of the JDK. This change and its benefits will be covered in Chapter 3, Java 11 Fundamentals.