售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
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
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜