atdj: generate wrapper classes for top-level list aliases#500
Merged
mjambon merged 3 commits intoahrefs:masterfrom Apr 17, 2026
Merged
atdj: generate wrapper classes for top-level list aliases#500mjambon merged 3 commits intoahrefs:masterfrom
mjambon merged 3 commits intoahrefs:masterfrom
Conversation
Java has no type aliases, so 'type items = item list' previously caused an error. We now generate a class Items implementing Atdj with: - a no-arg constructor (empty list) - a constructor from ArrayList<Item> - a constructor from a JSON string - a package-private constructor from JSONArray (analogous to the JSONObject constructor generated for records) - toJsonBuffer / toJson - a public 'value' field of type ArrayList<Item> The assign function is also updated so that list aliases used as record fields or sum-variant payloads are deserialized via 'new Items(jsonArray)' rather than triggering the inline ArrayList-building loop. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
JSONObject.keys() returns Iterator<Object> in newer versions of org.json, causing a compile error. The returned key is always a String in practice, so a cast is safe. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pedrobslisboa
pushed a commit
that referenced
this pull request
Apr 22, 2026
* atdj: generate wrapper classes for top-level list aliases Java has no type aliases, so 'type items = item list' previously caused an error. We now generate a class Items implementing Atdj with: - a no-arg constructor (empty list) - a constructor from ArrayList<Item> - a constructor from a JSON string - a package-private constructor from JSONArray (analogous to the JSONObject constructor generated for records) - toJsonBuffer / toJson - a public 'value' field of type ArrayList<Item> The assign function is also updated so that list aliases used as record fields or sum-variant payloads are deserialized via 'new Items(jsonArray)' rather than triggering the inline ArrayList-building loop. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Update CHANGES.md for atdj list alias support Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * atdj: cast keys().next() to String for newer org.json JSONObject.keys() returns Iterator<Object> in newer versions of org.json, causing a compile error. The returned key is always a String in practice, so a cast is safe. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
pedrobslisboa
pushed a commit
that referenced
this pull request
Apr 22, 2026
* atdj: generate wrapper classes for top-level list aliases Java has no type aliases, so 'type items = item list' previously caused an error. We now generate a class Items implementing Atdj with: - a no-arg constructor (empty list) - a constructor from ArrayList<Item> - a constructor from a JSON string - a package-private constructor from JSONArray (analogous to the JSONObject constructor generated for records) - toJsonBuffer / toJson - a public 'value' field of type ArrayList<Item> The assign function is also updated so that list aliases used as record fields or sum-variant payloads are deserialized via 'new Items(jsonArray)' rather than triggering the inline ArrayList-building loop. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Update CHANGES.md for atdj list alias support Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * atdj: cast keys().next() to String for newer org.json JSONObject.keys() returns Iterator<Object> in newer versions of org.json, causing a compile error. The returned key is always a String in practice, so a cast is safe. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
type items = item listpreviously caused an error in atdj. This PR generates a proper Java class instead.trans_list_aliasfunction inatdj_trans.mlgenerates a class (e.g.Items) implementingAtdjwith the same interface as record classes: no-arg constructor,ArrayList<T>constructor,String(JSON) constructor, package-privateJSONArrayconstructor,toJsonBuffer,toJson, and a publicvaluefield.trans_outeris extended to recognise both directListnodes andNamealiases that resolve to aListvianorm_ty.assignis updated so that when a list alias appears as a record field or sum-variant payload, deserialization usesnew Items(jsonArray)rather than the inlineArrayList-building loop.Util.writeJsonStringas expected).type items = simple_record listis added along with the expectedItems.javaoutput and the necessary dune rules.Test plan
dune build atdjcompiles cleanly🤖 Generated with Claude Code