舉報

會員
Java 11 and 12:New Features
Withitsnewsix-monthlyreleasecadence,Javaismovingforwardfaster.Inadditiontoplannedversionreleases,alotofworkiscurrentlybeingundertakenonvariousJavaprojectsatOracle.Inordertomakebestuseofthenewfeaturesintheirapplicationsandlibraries,youmustbewell-versedwiththemostrecentadvancements.Java11and12–NewFeatureswilltakeyouthroughthelatestdevelopmentsinJava,rightfromvariabletypeinferenceandsimplifiedmultithreadingthroughtoperformanceimprovements,whicharecoveredindepthtohelpyoumakeyourapplicationsmoreefficient.ThisbookexplainstherelevanceandapplicabilityofJava'snewfeatures,andanswersyourquestionsonwhethertoinvestinmigratingtonewJavaversionsandwhentomigrate.You'llalsogettogripswithplatformfeatures,suchasAppCDSandnewgarbagecollectors,totuneandoptimizeyourapplication—fromreducedlaunchtimeandlatencytoimprovedperformanceandthroughput.Bytheendofthisbook,youwillbeequippedwithathoroughunderstandingofthenewfeaturesofJava11,12,andProjectAmber,andpossesstheskillstoapplythemwithaviewtoimprovingyourapplication'sperformance.
最新章節
- Leave a review - let other readers know what you think
- Other Books You May Enjoy
- Summary
- Using pattern matching with switch constructs
- Type test patterns
- Existing issues with type testing
品牌:中圖公司
上架時間:2021-07-02 11:59:12
出版社:Packt Publishing
本書數字版權由中圖公司提供,并由其授權上海閱文信息技術有限公司制作發行
- Leave a review - let other readers know what you think 更新時間:2021-07-02 12:27:40
- Other Books You May Enjoy
- Summary
- Using pattern matching with switch constructs
- Type test patterns
- Existing issues with type testing
- Pattern matching
- Technical requirements
- Pattern Matching
- Summary
- The proposed solution
- Issues with resolving overloaded methods – passing method references
- Issues with resolving overloaded methods – passing lambdas
- Disambiguation of functional expressions
- A few of the known issues
- Why should lambda parameters overshadow enclosing variables?
- The existing case of lambda parameters
- Shadowing of lambda parameters
- The journey of getting there
- An example of lambda parameters
- Marking unused parameters with underscores
- Technical requirements
- Lambda Leftovers
- Summary
- Database queries
- File paths
- XML data
- JSON data
- Common examples
- The transform() method
- The detab(int) and entab methods
- The overloaded align(int) method
- The indent(int) method
- The align() method
- Managing margins
- The escape() method
- The unescape() method
- Interpreting escape sequences
- Raw string literals versus traditional string literals
- Treating escape values
- The delimiter (backtick)
- Rewriting using raw strings
- Welcoming raw string literals
- Strings and regex patterns another hell
- Including escape sequences as part of string values
- Concatenation hell with traditional string literals
- Escape sequence hell with traditional string literals
- A simple task
- Issues with existing multiline string values
- A quick example
- Technical requirements
- Raw String Literals
- Summary
- Mutability
- Additional methods and constructors
- Overriding implicit behaviors
- Additional variables
- Implementing interfaces
- Extending an abstract data class
- Data classes and inheritance
- Abstract and non-abstract data classes
- Encapsulating the state
- Pattern matching with data classes
- Examples from the past – changes to define enums
- Limitations
- The aggregate and exploded forms of data classes
- Example of syntax and semantics
- Diving into data classes
- The need to add data classes to the language
- What is a data class?
- An introduction to data classes
- Data Classes and Their Usage
- Summary
- Sharper typing of enum constants
- Adding generics to enums
- Using inheritance with enum constants
- Workarounds to access enum constants
- Accessing the state and behavior of enum constants
- Adding states and behaviors to enum constants
- The state and behavior of enum constants
- Decompiled enum – behind the scenes
- An example
- A quick background
- Enhanced Enums in Project Amber
- Section 4: Project Amber
- Summary
- Promptly return unused committed memory from G1
- Abortable mixed collections for G1
- Enhancing CDS
- What is CDS?
- Default CDS archives
- One AArch64 port not two
- The JVM constants API
- The microbenchmark suite
- Shenandoah – a low-pause-time GC
- Mapping features of JDK 12 scope and JEP
- Technical requirements
- Miscellaneous Improvements in JDK 12
- Summary
- How not to use labels and continue in switch expressions
- What can a switch branch execute other than returning a value?
- Exhaustive cases
- A preview language feature
- Comparing break with break <return value>
- Another syntax for switch expressions
- Defining local variables in a switch branch
- Using switch expressions
- Issues with traditional switch constructs
- Technical requirements
- Switch Expressions
- Section 3: JDK 12
- Summary
- JEP 336 – deprecating the pack200 tools and API
- Deprecating the Nashorn JavaScript engine
- TLS 1.3
- Launching single file source code programs
- ChaCha20 and Poly1305 cryptographic algorithms
- Unicode 10
- A key agreement with Curve25519 and Curve448
- Removing the Java EE and CORBA modules
- Improving AArch64 intrinsics
- Dynamic class-file constants
- Affects of nest-based control
- What is nest-based access?
- Nest-based access control
- Listing the JEPs that are used in this chapter
- Technical requirements
- Miscellaneous Improvements in JDK 11
- Summary
- Working with custom events
- Exploring further
- Getting started with JFR
- Modules
- Features
- The motivation behind JFR
- Technical requirements
- Flight Recorder and Mission Control
- Summary
- Tuning ZGC
- Colored pointers
- ZGC phases
- ZGC heap
- Getting started with ZGC
- Features of ZGC
- The motivation
- Technical requirements
- ZGC
- Summary
- Posting form details
- Downloading multiple hosted image files
- Accessing HTML pages using asynchronous GET
- Accessing HTML pages using synchronous GET
- Some examples
- HttpResponse
- HttpRequest
- Methods of the HttpClient class
- Creating an HttpClient instance
- The HttpClient class
- A basic example
- HTTP Client usage
- The need for the HTTP Client API
- What can you do with HTTP?
- A quick flashback
- Technical requirements
- The HTTP Client API
- Summary
- VM interface testing
- Designing a garbage-free application
- Memory pressure testing with Epsilon
- Which memory area does GC collect – stack or heap?
- Getting started with the HelloEpsilon GC class
- Extremely short-lived work
- GC-induced overheads versus system overheads
- Latency and application performance
- Features of Epsilon
- The motivation behind Epsilon GC
- Technical requirements
- Epsilon GC
- Summary
- Adding annotations to lambda parameters
- Adding var to lambda parameters
- Lambda parameters and type inference with var
- Implicitly-typed lambda expressions
- Explicitly-typed lambda expressions
- Lambda expressions
- Technical requirements
- Local Variable Syntax for Lambda Parameters
- Section 2: JDK 11
- Summary
- Time-based release versioning
- Root certificates
- The experimental Java-based JIT compiler
- Heap allocation on alternative memory devices
- Additional Unicode language-tag extensions
- Removal of the Native-Header Generation Tool (javah)
- Thread-local handshakes
- Consolidating the JDK forest into a single repository
- Mapping JDK 10 features with scopes and JEPs
- Technical requirements
- Miscellaneous Improvements in JDK 10
- Summary
- Understanding G1 GC logs
- Sample code
- G1 memory
- The design goals of G1 GC
- Parallel full GC for G1 (JEP 307)
- Impact
- Driving factors
- Benefits
- The GC interface
- Technical requirements
- Garbage Collector Optimizations
- Summary
- Using the shared application archive file
- Creating an application shared archive file
- Which application classes to archive
- Enabling application class data archive
- Benefits of AppCDS
- AppCDS
- Usage of CDS
- Manual creation of classes.jsa
- Location of the shared archive file
- What is CDS?
- Technical requirements
- AppCDS
- Summary
- Type inference versus dynamic binding
- Code refactoring
- Meaningful variable names
- Non-denotable types
- Breaking existing code
- Limiting the scope of failed assumptions
- Challenges
- Type inference in Java 8
- Type inference in Java 7
- Type inference in Java 5
- Type inference in previous versions of Java
- Assigning null with explicit casting
- Explicit casting with inferred variables
- Reassigning values to inferred variables
- Passing inferred variables to a method
- Code check – part 2
- Type inference with generics
- Using var with arrays
- Type inference with interfaces
- Type inference with derived classes
- Using var with primitive data types
- Code check – part 1
- Local variables
- Compulsory non-null initialization
- Type inference with var
- What is type inference?
- Type Inference
- Section 1: JDK 10
- Reviews
- Get in touch
- Conventions used
- Download the color images
- Download the example code files
- To get the most out of this book
- What this book covers
- Who this book is for
- Preface
- Packt is searching for authors like you
- About the reviewer
- About the author
- Contributors
- Packt.com
- Why subscribe?
- About Packt
- Java 11 and 12 – New Features
- Copyright and Credits
- Title Page
- coverpage
- coverpage
- 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 更新時間:2021-07-02 12:27:40