万本电子书0元读

万本电子书0元读

顶部广告

Java 11 and 12 – New Features电子书

售       价:¥

40人正在读 | 0人评论 6.2

作       者:Mala Gupta

出  版  社:Packt Publishing

出版时间:2019-03-26

字       数:25.1万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Enhance your development skills with Java’s state-of-the-art features and projects to make your applications leaner and faster Key Features * Overcome the challenges involved in migrating to new versions of Java * Discover how Oracle has bridged the gap between Java and native code * Make the best use of new Java features and libraries in your applications Book Description With its new six-monthly release cadence, Java is moving forward faster. In addition to planned version releases, a lot of work is currently being undertaken on various Java projects at Oracle. In order to make best use of the new features in their applications and libraries, you must be well-versed with the most recent advancements. Java 11 and 12 – New Features will take you through the latest developments in Java, right from variable type inference and simplified multithreading through to performance improvements, which are covered in depth to help you make your applications more efficient. This book explains the relevance and applicability of Java's new features, and answers your questions on whether to invest in migrating to new Java versions and when to migrate. You'll also get to grips with platform features, such as AppCDS and new garbage collectors, to tune and optimize your application—from reduced launch time and latency to improved performance and throughput. By the end of this book, you will be equipped with a thorough understanding of the new features of Java 11, 12, and Project Amber, and possess the skills to apply them with a view to improving your application's performance. What you will learn * Study type interference and how to work with the var type * Understand Class-Data Sharing, its benefits, and limitations * Discover platform options to reduce your application’s launch time * Improve application performance by switching garbage collectors * Get up to date with the new Java release cadence * Define and assess decision criteria for migrating to a new version of Java Who this book is for If you’re an executive or solutions architect responsible for technology selection or Java migration decisions, this Java book is for you. You’ll also benefit from this book if you’re a computer science enthusiast curious to learn about the latest and upcoming Java features. This book will help you migrate your solutions from Java 8 or older to the latest Java release.
目录展开

Title Page

Copyright and Credits

Java 11 and 12 – New Features

About Packt

Why subscribe?

Packt.com

Contributors

About the author

About the reviewer

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Conventions used

Get in touch

Reviews

Section 1: JDK 10

Type Inference

What is type inference?

Type inference with var

Compulsory non-null initialization

Local variables

Code check – part 1

Using var with primitive data types

Type inference with derived classes

Type inference with interfaces

Using var with arrays

Type inference with generics

Code check – part 2

Passing inferred variables to a method

Reassigning values to inferred variables

Explicit casting with inferred variables

Assigning null with explicit casting

Type inference in previous versions of Java

Type inference in Java 5

Type inference in Java 7

Type inference in Java 8

Challenges

Limiting the scope of failed assumptions

Breaking existing code

Non-denotable types

Meaningful variable names

Code refactoring

Type inference versus dynamic binding

Summary

AppCDS

Technical requirements

What is CDS?

Location of the shared archive file

Manual creation of classes.jsa

Usage of CDS

AppCDS

Benefits of AppCDS

Enabling application class data archive

Which application classes to archive

Creating an application shared archive file

Using the shared application archive file

Summary

Garbage Collector Optimizations

Technical requirements

The GC interface

Benefits

Driving factors

Impact

Parallel full GC for G1 (JEP 307)

The design goals of G1 GC

G1 memory

Sample code

Understanding G1 GC logs

Summary

Miscellaneous Improvements in JDK 10

Technical requirements

Mapping JDK 10 features with scopes and JEPs

Consolidating the JDK forest into a single repository

Thread-local handshakes

Removal of the Native-Header Generation Tool (javah)

Additional Unicode language-tag extensions

Heap allocation on alternative memory devices

The experimental Java-based JIT compiler

Root certificates

Time-based release versioning

Summary

Section 2: JDK 11

Local Variable Syntax for Lambda Parameters

Technical requirements

Lambda expressions

Explicitly-typed lambda expressions

Implicitly-typed lambda expressions

Lambda parameters and type inference with var

Adding var to lambda parameters

Adding annotations to lambda parameters

Summary

Epsilon GC

Technical requirements

The motivation behind Epsilon GC

Features of Epsilon

Latency and application performance

GC-induced overheads versus system overheads

Extremely short-lived work

Getting started with the HelloEpsilon GC class

Which memory area does GC collect – stack or heap?

Memory pressure testing with Epsilon

Designing a garbage-free application

VM interface testing

Summary

The HTTP Client API

Technical requirements

A quick flashback

What can you do with HTTP?

The need for the HTTP Client API

HTTP Client usage

A basic example

The HttpClient class

Creating an HttpClient instance

Methods of the HttpClient class

HttpRequest

HttpResponse

Some examples

Accessing HTML pages using synchronous GET

Accessing HTML pages using asynchronous GET

Downloading multiple hosted image files

Posting form details

Summary

ZGC

Technical requirements

The motivation

Features of ZGC

Getting started with ZGC

ZGC heap

ZGC phases

Colored pointers

Tuning ZGC

Summary

Flight Recorder and Mission Control

Technical requirements

The motivation behind JFR

Features

Modules

Getting started with JFR

Exploring further

Working with custom events

Summary

Miscellaneous Improvements in JDK 11

Technical requirements

Listing the JEPs that are used in this chapter

Nest-based access control

What is nest-based access?

Affects of nest-based control

Dynamic class-file constants

Improving AArch64 intrinsics

Removing the Java EE and CORBA modules

A key agreement with Curve25519 and Curve448

Unicode 10

ChaCha20 and Poly1305 cryptographic algorithms

Launching single file source code programs

TLS 1.3

Deprecating the Nashorn JavaScript engine

JEP 336 – deprecating the pack200 tools and API

Summary

Section 3: JDK 12

Switch Expressions

Technical requirements

Issues with traditional switch constructs

Using switch expressions

Defining local variables in a switch branch

Another syntax for switch expressions

Comparing break with break <return value>

A preview language feature

Exhaustive cases

What can a switch branch execute other than returning a value?

How not to use labels and continue in switch expressions

Summary

Miscellaneous Improvements in JDK 12

Technical requirements

Mapping features of JDK 12 scope and JEP

Shenandoah – a low-pause-time GC

The microbenchmark suite

The JVM constants API

One AArch64 port, not two

Default CDS archives

What is CDS?

Enhancing CDS

Abortable mixed collections for G1

Promptly return unused committed memory from G1

Summary

Section 4: Project Amber

Enhanced Enums in Project Amber

A quick background

An example

Decompiled enum – behind the scenes

The state and behavior of enum constants

Adding states and behaviors to enum constants

Accessing the state and behavior of enum constants

Workarounds to access enum constants

Using inheritance with enum constants

Adding generics to enums

Sharper typing of enum constants

Summary

Data Classes and Their Usage

An introduction to data classes

What is a data class?

The need to add data classes to the language

Diving into data classes

Example of syntax and semantics

The aggregate and exploded forms of data classes

Limitations

Examples from the past – changes to define enums

Pattern matching with data classes

Encapsulating the state

Abstract and non-abstract data classes

Data classes and inheritance

Extending an abstract data class

Implementing interfaces

Additional variables

Overriding implicit behaviors

Additional methods and constructors

Mutability

Summary

Raw String Literals

Technical requirements

A quick example

Issues with existing multiline string values

A simple task

Escape sequence hell with traditional string literals

Concatenation hell with traditional string literals

Including escape sequences as part of string values

Strings and regex patterns, another hell

Welcoming raw string literals

Rewriting using raw strings

The delimiter (backtick)

Treating escape values

Raw string literals versus traditional string literals

Interpreting escape sequences

The unescape() method

The escape() method

Managing margins

The align() method

The indent(int) method

The overloaded align(int) method

The detab(int) and entab methods

The transform() method

Common examples

JSON data

XML data

File paths

Database queries

Summary

Lambda Leftovers

Technical requirements

Marking unused parameters with underscores

An example of lambda parameters

The journey of getting there

Shadowing of lambda parameters

The existing case of lambda parameters

Why should lambda parameters overshadow enclosing variables?

A few of the known issues

Disambiguation of functional expressions

Issues with resolving overloaded methods – passing lambdas

Issues with resolving overloaded methods – passing method references

The proposed solution

Summary

Pattern Matching

Technical requirements

Pattern matching

Existing issues with type testing

Type test patterns

Using pattern matching with switch constructs

Summary

Other Books You May Enjoy

Leave a review - let other readers know what you think

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部