RFR: 7903788: preparation towards json configuration for jextract tool

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Aug 16 12:13:01 UTC 2024


On Fri, 16 Aug 2024 12:08:15 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> src/main/java/org/openjdk/jextract/json/parser/JSONArray.java line 59:
>> 
>>> 57:     }
>>> 58: 
>>> 59:     public JSONArray set(int i, boolean value) {
>> 
>> Given we're not really planning to use this API directly, I think the setters are redundant. E.g. we should probably strive to build _immutable_ JSON nodes (and then map them back and forth into records). In this particular case, just copying the elements into an immutable list (`List::of`) will suffice - then we can drop all the setters. Probably similar simple changes in other classes will work too.
>
> I also note that all the other classes (except JSONObject) seem to be non-mutable...

Uhm. Nevermind. It seems the mappers built on top rely on mutation. While I'm sure that can be avoided (by buffering up the values before creating the JSONArray) that would imply slightly bigger changes. So, up to you.

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

PR Review Comment: https://git.openjdk.org/jextract/pull/257#discussion_r1719761604


More information about the jextract-dev mailing list