On Mon, 31 Aug 2026 23:53:07 GMT, Thomas Zimmermann <[email protected]> wrote:
>> Thanks. Changed to use `List.copyOf()`, and consolidated the one in the >> factory method into constructor. I did not do the same for `JsonObjectImpl`, >> as it should preserve the encounter order of the backing map, which >> `Map.copyOf()` does not guarantee. >> >> As to the suggestion to change impls to records, we intentionally did not >> define equality on `JsonValue` so that users would not accidentally count on >> the behavior. Making the impls based on `record` may introduce that >> possibility. > > Definitely out of scope and probably obvious, but if there ever was something > like `SequencedMap::of` / `SequencedMap::ofEntries` / `SequencedMap::copyOf`, > `JsonObjectImpl` would be a prime candidate for the latter. Note that `List.copyOf(…)` should probably be improved to trust the return value of `List::toArray()` when the list implementation’s class is exactly `ArrayList.class`[^1][^2]: - https://github.com/openjdk/jdk/pull/32282#discussion_r3774849249 -------------------------------------------------------------------------------- Also, +1 to introducing `SequencedMap::of(…)` and `SequencedSet::of(…)`. [^1]: And probably some other well‑known and trusted JDK list implementations. [^2]: The same should probably also be done with [`MethodType.methodType(Class, List)`]. [`MethodType.methodType(Class, List)`]: https://docs.oracle.com/en/java/javase/26/docs/api/java.base/java/lang/invoke/MethodType.html#methodType(java.lang.Class,java.util.List) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/32282#discussion_r3935197642
