Skip to content

Add documentation for DDM-generated Java code#694

Merged
atomb merged 6 commits intomainfrom
ddm-java-doc
Apr 3, 2026
Merged

Add documentation for DDM-generated Java code#694
atomb merged 6 commits intomainfrom
ddm-java-doc

Conversation

@atomb
Copy link
Copy Markdown
Contributor

@atomb atomb commented Mar 27, 2026

Adds docs/DDMJavaCodeGen.md, a reference for the DDM Java code generator. Covers CLI usage (strata javaGen), Lean API, generated file structure, type mapping, Ion serialization format, name disambiguation, and limitations. Documentation only — no code changes.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@atomb atomb requested review from fabiomadge and joehendrix March 27, 2026 18:45
@atomb atomb marked this pull request as ready for review March 27, 2026 18:45
@atomb atomb requested a review from a team March 27, 2026 18:45
@joscoh joscoh added the Java label Mar 30, 2026
fabiomadge
fabiomadge previously approved these changes Mar 31, 2026
Copy link
Copy Markdown
Contributor

@fabiomadge fabiomadge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While reviewing Aaron's doc, I found several bugs in the code generator that would make the doc describe incorrect behavior. I also reconsidered some design choices. Rather than documenting known bugs, I fixed them:

  • fromCategoryName?/fromIonName? silently returned wrong values (Lean namespace resolution issue)
  • Init.Str fields serialized as ident instead of strlit
  • Reflection-based serializer replaced with generated toIon methods on each record
  • Records are now nested inside their category interface (eliminates most _ suffix collisions)

The doc is rewritten to match the new structure. All existing tests updated and passing.

Happy to split the implementation changes into a separate PR if you'd prefer to land the doc independently.

@fabiomadge fabiomadge force-pushed the ddm-java-doc branch 3 times, most recently from 190e98c to 78389da Compare March 31, 2026 06:45
atomb and others added 3 commits March 31, 2026 08:47
… bug fixes

Restructure the generated Java code to use nested records inside category
interfaces, replacing the previous flat file-per-operator layout. Each
record now has a generated toIon method with field-specific serialization,
replacing the reflection-based IonSerializer.

Code generator changes:
- Operators are nested records within their category's sealed interface
- Single-op categories with name collision use "Of" as record name
- Generated toIon methods on each record (no reflection, no separator map)
- IonSerializer is now a slim helper class with typed public methods
- Node interface gains toIon(IonSerializer) method signature
- Factory class name is now escaped and PascalCased like other names

Bug fixes:
- Fix SepFormat.fromCategoryName? and fromIonName? returning some .none
  for all inputs due to Lean namespace resolution of bare 'none' inside
  namespace SepFormat (now uses .none which resolves via expected type)
- Fix Init.Str fields serializing as (ident ...) instead of (strlit ...)
- Remove dead "non-sealed" entry from javaReservedWords

Tests and proofs:
- Add fromIonName_none_of_invalid theorem (invalid inputs return none)
- Add #guard for fromCategoryName? regression
- Strengthen roundtrip test to verify strlit for Init.Str fields
- Regenerate test Ion data with correct strlit serialization
- Update all 15 tests for new nested records structure

Documentation:
- Rewrite DDMJavaCodeGen.md to reflect new structure
- Document multi-file Ion format, ion-java dependency, program header
- Document naming rules (Of, _ suffix), factory method naming
- Fix serialization format (ident vs strlit distinction)
- Document syncat/metadata handling, SourceRange ambiguity, precision limits
The restructured Node.java now imports com.amazon.ion.IonSexp for the
toIon method, requiring ion-java on the classpath. Download the jar
from Maven Central before the Lean build step so the test runs in CI.

Also make the test fail loudly if the jar is missing instead of
silently skipping.
fabiomadge
fabiomadge previously approved these changes Mar 31, 2026
@atomb
Copy link
Copy Markdown
Contributor Author

atomb commented Apr 1, 2026

Thanks, @fabiomadge! I'm quite happy to have the code fixes be in this PR, too.

Comment thread Strata/DDM/Integration/Java/Gen.lean
Comment thread Strata/DDM/Integration/Java/Gen.lean Outdated
Comment thread Strata/DDM/Integration/Java/Gen.lean
Comment thread Strata/DDM/Integration/Java/templates/IonSerializer.java
Comment thread docs/DDMJavaCodeGen.md
Comment thread docs/DDMJavaCodeGen.md
…ify docs

- Rename _used to used in Gen.lean since it's actually referenced
- Extract newTagged private helper in IonSerializer.java template,
  converting 5 primitive serializers to one-liners
- Note case-insensitive comparison in collision docs
MikaelMayer
MikaelMayer previously approved these changes Apr 2, 2026
Comment thread docs/DDMJavaCodeGen.md
Comment thread Strata/DDM/Integration/Java/Gen.lean Outdated
Comment thread Strata/DDM/Integration/Java/Gen.lean Outdated
Comment thread StrataTest/DDM/Integration/Java/TestGen.lean
Comment thread StrataTest/DDM/Integration/Java/TestGen.lean
@atomb atomb enabled auto-merge April 3, 2026 19:40
@atomb atomb added this pull request to the merge queue Apr 3, 2026
Merged via the queue into main with commit abe13ae Apr 3, 2026
15 checks passed
@atomb atomb deleted the ddm-java-doc branch April 3, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants