On Tue, 11 Aug 2026 03:22:06 GMT, Chen Liang <[email protected]> wrote:

>> This PR implements [JEP 540: Simple JSON API 
>> (Incubator)](https://openjdk.org/jeps/540).
>> 
>> It adds the `jdk.incubator.json` module which provides APIs for reading and 
>> writing JSON documents as specified by [RFC 
>> 8259](https://datatracker.ietf.org/doc/html/rfc8259). This is an incubating 
>> API.
>> 
>> API documentation: 
>> https://cr.openjdk.org/~naoto/json/javadoc/api/jdk.incubator.json/module-summary.html
>> Co-authored-by: Justin Lu 
>> ([@justin-curtis-lu](https://github.com/justin-curtis-lu))
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> src/jdk.incubator.json/share/classes/jdk/incubator/json/impl/JsonNumberImpl.java
>  line 58:
> 
>> 56:     public int asInt() {
>> 57:         return numInteger.get().orElseThrow(() ->
>> 58:             Utils.composeError(this, this + " cannot be represented as 
>> an int."));
> 
> `orElseThrow` unforunately requires a capturing lambda - ugliness but C2 
> should be able to deal with these. Or the language need some optimizations 
> around this-capturing lambdas.

Hopefully, migrating lambda implementations to value classes will make 
capturing lambdas cheaper, possibly with some form of on‑stack allocation 
support for value classes (which would only require converting the on‑stack 
representation to a buffered one when storing in a non‑flattened field or array)

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/32282#discussion_r3774703447

Reply via email to