To run each example use: java --enable-preview --source 18 <FileName.java>
- 400 - UTF-8 by Default
- 408 - Simple Web Server
- 413 - Code Snippets in Java API Documentation
- 416 - Reimplement Code Reflection with Method Handles
- 417 - Vector API (Third Incubator)
- 418 - Internet-Address Resolution SPI
- 419 - Foreign Function & Memory API (Second Incubator)
- 420 - Pattern matching for
switch(Second Preview) - 421 - Deprecate Finalization for Removal
- Chartset UTF-8 by Default
- to see which is default:
java -XshowSettings:properties -version 2>&1 | grep file.encoding - we can change the chartset with property:
-Dfile.encoding=UTF-8 - affected classes:
- Stream Reader and Writer
- File Reader and Writer
FormatterandScannerURLEncoderandURLDecoder
- the
System.outandSystem.errwill use the same charset from the terminal- we can see with:
Console.charset()
- we can see with:
- to see which is default:
- Pattern Matching for
switch(second preview)- Minor improvements from JDK 17:
- refined to use dominance checking that will force constant case label to appear before a guarded pattern of the same type;
- exhaustiveness checking is now more precise with sealed hierarchies.
- Minor improvements from JDK 17:
- Code snippet in Java Doc
- was introduced the
@snippettag to help write code fragments in Java docs - the goals is to provide a way to get this fragments (so it can be validated by other tool), enable syntax highlighting and provide better IDE support
- code snippet suports:
- attributes (key-pair values like
usage="sort") - ID to be referred in others snippets (through
idattribute) - language definition (through
langattribute) - default is java - external files (through
fileattribute) - using external file to define the snippets allow us to use everything that Java supports (like comments with/** */)
- attributes (key-pair values like
- we can pass
--snippet-pathtojavadoctool to define the folders for external snippets - example:
- was introduced the
- Reimplemented code reflection to use Method Handles
