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)

What this book covers

Chapter 1, The Java 11 Landscape, explores the newly implemented time-based versioning system for the Java platform. We survey the current Java landscape with a specific focus on changes introduced with Java 9, 10 (18.3), and 11 (18.9). Our exploration includes an overview of Java 9's modularity, Java Shell, external process control, garbage collection, JHM, and more. For Java 10, we will highlight key changes to include local variable type inference, JDK consolidation, garbage collection, application class-data sharing, and root certificates, to name a few. Finally, we will explore changes introduced in Java 11, including dynamic class-file constants, garbage collection, and local variable type inference for lambdas.

Chapter 2, Discovering Java 11, looks at several internal changes introduced in the Java platform, including changes from Java 9, 10, and 11. Java 9 represented a major release to the Java platform; Java 10 and 11 were timed releases. Collectively, these releases consisted of a large number of internal changes, representing a tremendous set of new possibilities for Java developers, some stemming from developer requests, others from Oracle-inspired enhancements.

Chapter 3, Java 11 Fundamentals, covers changes to the Java platform that impact variable handlers, import statements, improvements to Project Coin, local variable type inference, root certificates, dynamic class-file constants, and more. These represent changes to the Java language itself.

Chapter 4, Building Modular Applications with Java 11, examines the structure of a Java module as specified by Project Jigsaw. We take a deep dive into how Project Jigsaw is implemented as part of the Java platform. We also review key internal changes to the Java platform as they relate to the modular system.

Chapter 5, Migrating Applications to Java 11, explores how to migrate our existing applications to the current Java platform. We look at both manual and semi-automated migration processes. This chapter aims to provide you with insights and processes to get your non-modular Java code working with the current Java platform.

Chapter 6, Experimenting with the Java Shell, takes a look at the new command line, the Read-Eval-Print-Loop (also referred to as REPL) tool in Java, and the Java Shell (JShell). We start with introductory information regarding the tool, the REPL concept, and move into the commands and command-line options for use with JShell. We take a practitioner's approach to our review of JShell and include examples you can try on your own.

Chapter 7, Leveraging the Default G1 Garbage Collector, takes an in-depth look at garbage collection and how it is handled in Java. We start with an overview of garbage collection and then look at specifics in the pre-Java 9 realm. Armed with that foundational information, we look at specific garbage collection changes in the Java 9 platform. Lastly, we look at some garbage collection issues that persist, even after Java 11.

Chapter 8, Microbenchmarking Applications with JMH, looks at how to write performance tests using the Java Microbenchmark Harness (JMH), a Java harness library for writing benchmarks for the Java Virtual Machine (JVM). We use Maven along with JMH to help illustrate the power of microbenchmarking with the new Java platform.

Chapter 9, Making Use of the Process API, focuses on the updates to the Process class and the java.lang.ProcessHandle API. In earlier versions of Java, prior to Java 9, managing processes in Java was difficult. The API was insufficient with some features lacking and some tasks needed to be solved in a system-specific manner. For example, in Java 8, giving a process access to its own process identifier (PID) was an unnecessarily difficult task.

Chapter 10, Fine-Grained Stack Tracing, focuses on Java's StackWalker API. The API supports special functionality that is rarely needed by ordinary programs. The API can be useful for some very special cases, such as with functionality that is delivered by a framework. So, if you want an efficient means of stack walking that gives you filterable access to stack trace information, you will enjoy using the StackWalker API. The API provides fast and optimized access to the call stack, implementing lazy access to the individual frames.

Chapter 11, New Tools and Tool Enhancements, covers over a dozen tools and tool enhancements relevant to the modern Java platform. The featured changes will cover a wide range of tools and updates to APIs that are aimed at making developing with Java easier and enhance the ability to create optimized Java applications.

Chapter 12, Concurrency Enhancements, covers concurrency enhancements to the Java platform. Our primary focus is the support for reactive programming, a concurrency enhancement that is provided by the Flow class API. Reactive programming was first released in Java 9 and remains an important feature of Java 10 and 11. We also explore additional concurrency enhancements.

Chapter 13, Security Enhancements, looks at several recent changes made to the JDK that involve security. The size of these changes does not reflect their significance. The security enhancements to the modern Java platform provide developers with a greater ability to write and maintain applications that are more secure than previously possible.

Chapter 14, Command-Line Flags, explores several changes to the modern Java platform with the common theme of command-line flags. These include the following concepts: unified JVM logging, compiler control, diagnostic commands, the heap profiling agent, removing your JHAT, command-line flag argument validation, compiling for older platform versions, and the experimental Java-based JIT compiler.

Chapter 15, Additional Enhancements to the Java Platform, focuses on best practices with additional utilities provided with the Java platform. Specifically, this chapter covers support for UTF-8, Unicode support, Linux/AArch64 port, multi-resolution images, and the Common Locale Data Repository.

Chapter 16, Future Directions, provides an overview of the future development of the Java platform beyond Java 11. We look at what is planned for Java 19.3 and 19.9 and what further changes we are likely to see in the future. We start with a brief overview of the JDK Enhancement Program (JEP).

Chapter 17, Contributing to the Java Platform, discusses the Java community and ways developers can contribute to the Java platform. Specifically, the chapter covers the following Java community-related topics, such as the Java community, participating in a Java user group, the Java community process, Oracle Technology Network (OTN), and writing technical articles.