To run each example use: java --enable-preview --source 28 <FileName.java>
- 401 - Value Objects (Preview)
- 535 - Shenandoah GC: Generational Mode by Default
- 539 - Strict Field Initialization in the JVM (Preview)
- 540 - Simple JSON API (Incubator)
- 541 - Deprecate the macOS/x64 Port for Removal
- 542 - PEM Encodings of Cryptographic Objects
- Shenandoah GC: Generational Mode by Default
- Shenandoah is a low-pause-time garbage collector
- switch the default mode of Shenandoah GC to the generational mode
- deprecate the non-generational mode
- default mode:
XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational - to use non-generational mode:
-XX:+UseShenandoahGC -XX:ShenandoahGCMode=satb
- Simple JSON API
- a simple standard API for parsing and generating JSON documents that conform to RFC 8259
- this JEP replaces the JEP 198 - Light-Weight JSON API
- the API is organized around the sealed interface
JsonValuewhich has the following sub-interfaces:JsonString,JsonNumber,JsonBoolean,JsonNull,JsonObjectandJsonArray - the
Json.parsemethod returns a tree of JsonValue instances that expose the names, types, and values of the parsed JSON data - generating JSON text:
Json.toString: returns the JSON string converted from the tree of objects:Json.toDisplayString(JsonValue, String): returns the formatted JSON string for better readability, the string parameter is the indentation
- navigating JSON documents:
JsonValuemethods to read a value:get(String): obtains the value of an object memberget(int): obtains an array elementtryGet(String): obtains an optional value of an object member
- it is recommended to use type patterns to handle dynamic structure
- if the
JsonValueinstance is of the wrong type or the requested member or element does not exist aJsonValueExceptionwill be thrown
- converting values to Java types:
JsonValuemethods to convert a value:asStringasIntasLong()asDouble()asBoolean()asMap()asList()
- the methods are implemented by the
JsonValuesub-interfaces (JsonString,JsonNumber) - there is no conversion method for null value, we should check with
instanceof JsonNullor usetryValuethat returns anOptional - if a
JsonValueis not an instance of the appropriate subtype for a conversion method then the method throws a JsonValueException - numeric conversions can fail for reasons such as the numeric value not being representable in the target Java numeric type, which also causes a
JsonValueExceptionto be thrown
- PEM Encodings of Cryptographic Objects
- promotion to standard
- "introduce an API for encoding objects that represent cryptographic keys, certificates, and certificate revocation lists into the widely-used Privacy-Enhanced Mail (PEM) transport format"
- support conversions between PEM text and cryptographic objects that have standard representations in the binary formats of PKCS#8 (for private keys), X.509 (public keys, certificates, and certificate revocation lists), and PKCS#8 v2.0 (encrypted private keys and asymmetric keys)