Resolve trait impl's in submodules and avoid Java keyword collisions#56
Merged
skeet70 merged 5 commits intoIronCoreLabs:mainfrom Apr 6, 2026
Merged
Resolve trait impl's in submodules and avoid Java keyword collisions#56skeet70 merged 5 commits intoIronCoreLabs:mainfrom
skeet70 merged 5 commits intoIronCoreLabs:mainfrom
Conversation
Java trait implementation rendering was assuming that a trait type's full module_path could always be resolved directly via ComponentInterface::find_component_interface. That is not true for local callback interfaces defined in a submodule of the current crate, such as slatedb_uniffi::metrics::MetricsRecorder. In that case the metadata still belongs to the current component interface, but trait_interface_name looked up the full module path and failed with: "no interface with module_path: slatedb_uniffi::metrics". This broke Java code generation for local object trait impls and forced downstream crates to keep callback traits at the crate root as a workaround. Fix the lookup by resolving the component interface from the trait type's crate name first. If the crate name matches the current component interface, use the current interface directly. Otherwise keep the existing external-interface lookup behavior, falling back from the full module path to the crate name. Add a regression test covering a local object that implements a callback interface declared in test::metrics. The test verifies both the filter result and the generated Java class declaration so the original failure mode is exercised directly.
Generate callback helper implementation classes with a class-style name derived from the trait method plus a Callback suffix instead of reusing the method identifier directly. This prevents invalid nested types such as "record" from being emitted when a callback method name collides with a Java keyword, while keeping the user-facing callback method name unchanged. Add a regression test for a "record" callback interface method.
Contributor
Author
|
cc @skeet70 |
7 tasks
Member
|
Thanks! I had run into the submodule issue myself and fixed it the same way Kotlin had, though I haven't released it yet. I'll look to see if your regression test covers anything mine doesn't. I'll pull the Java keyword fix in too. In my upstream library I noticed a regression in a very specific case (all other tests/benches on both projects show at least moderate gains), so I'm digging into that. I'll release these other bugfixes before that though since it's taking a while to track down. |
Contributor
Author
|
Awesome, thanks! Happy to take your fixes :) Feel free to close this PR if/when needed. |
skeet70
approved these changes
Apr 6, 2026
Member
skeet70
left a comment
There was a problem hiding this comment.
Thanks! This turned out to be better than the fix I had!
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.
This is two PRs combined in one. I got on a roll debugging. They're small enough that I feel it's OK. If you prefer two distinct PRs, LMK. The two issues uncovered ar:
This was failing to compile.
You can review each commit in this PR individually. See the detailed commit descriptions for each if you want more info.