feat: generate record deconstructors alongside instantiators#299
Merged
Conversation
The metamodel generators emit an Instantiator per record type so construction runs as generated code, but reading a record's components back out still went through reflective accessors. Both generators now also emit a deconstructor that reads the components directly, and write-set rebuilds (key propagation and generated-key assignment) run the full deconstruct-adjust-instantiate round trip as generated code. Instantiator gains a deconstruct method whose default returns null, signalling that no generated deconstructor is available; callers fall back to reflective component access, so instantiators generated before this change and types without generated support keep working unchanged. Component reads as generated code need no accessor registration for native images and start at full speed in short-lived processes; warmed-JIT throughput is unchanged. Closes #295
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.
Closes #295
What
The metamodel generators emit an
Instantiatorper record type, so record construction runs as generated code — but reading a record's components back out still went through reflective accessors. This completes the pair:Instantiator#deconstruct(T)— returns the canonical constructor arguments in declaration order as a freshly allocated array the caller may adjust and pass back toinstantiate. The default returnsnull("no generated deconstructor"), so instantiators generated before this change and types without generated support keep working unchanged through the reflective fallback.withComponent) now run the full deconstruct → adjust → instantiate round trip as generated code.Why
Testing