On Wed, 12 Aug 2026 06:07:39 GMT, Thomas Zimmermann <[email protected]> wrote:

>> Naoto Sato has updated the pull request incrementally with nine additional 
>> commits since the last revision:
>> 
>>  - Merge remote-tracking branch 'jdk-sandbox/json' into 
>> JDK-8381976-Implementation-for-Simple-JSON-API
>>  - offset -> cursorPos in JsonParser
>>  - Consolidated copyOf() in JsonArrayImpl constructor
>>  - Make Utils.composeTypeError derive expected from Class name
>>  - Refactor Frame classes in JG into records
>>  - Give initial size to StringBuilder
>>  - initSb() -> StringBuilder::new
>>  - Making Util class final
>>  - Clarify JSON string -> text in toDisplayString
>
> src/jdk.incubator.json/share/classes/jdk/incubator/json/JsonObject.java line 
> 110:
> 
>> 108: 
>> 109:         if (map.isEmpty()) {
>> 110:             return new JsonObjectImpl(Collections.emptyMap());
> 
> Suggestion:
> 
>             return new JsonObjectImpl(Map.of());

(See my other comments re internal use of SequencedMap.)

If the internals are converted to SequencedMap, then one can't use either of 
these. One would have to create an empty LinkedHashMap.

But this seems like a pretty rare case anyway -- how often does somebody create 
an empty JsonObject? There seems to be little to be gained from checking for 
the empty case, so maybe remove it and just let the empty case be handled by 
the entryset loop.

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

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

Reply via email to