[Java.Interop] Fix inherited JCW interfaces - #12333
Conversation
Only emit the most-derived registered interfaces in Java callable wrappers and cover TabLayout listener generation with unit and device integration tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 92a1a03f-a5e0-4475-96fd-adb6cd5d193c
There was a problem hiding this comment.
Pull request overview
Updates the Java Callable Wrapper (JCW) generator in Java.Interop to avoid emitting redundant inherited registered interfaces, preventing invalid Java implements lists that javac rejects (e.g., TabLayout.OnTabSelectedListener vs its base listener type). Adds both a focused generator regression test and a device integration test to validate the scenario end-to-end.
Changes:
- Update JCW interface collection to omit registered interfaces that are already inherited through a more-derived registered interface.
- Add a JavaCallableWrappers unit/regression test ensuring only the most-derived registered interface is emitted.
- Add an MSBuildDeviceIntegration test app that implements
TabLayout.IOnTabSelectedListener2and verifiesOnTabSelectedruns on launch.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs | Adds device integration coverage for TabLayout.IOnTabSelectedListener2 execution via logcat assertion. |
| external/Java.Interop/tests/Java.Interop.Tools.JavaCallableWrappers-Tests/Java.Interop.Tools.JavaCallableWrappers/SupportDeclarations.cs | Adds minimal registered base/derived interface declarations used by the regression test. |
| external/Java.Interop/tests/Java.Interop.Tools.JavaCallableWrappers-Tests/Java.Interop.Tools.JavaCallableWrappers/JavaCallableWrapperGeneratorTests.cs | Adds regression test asserting the generated wrapper keeps only the most-derived registered interface. |
| external/Java.Interop/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers.Adapters/CecilImporter.cs | Implements the interface filtering/deduplication logic in the Cecil-based importer used by the generator. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Avoid interpolation in the generated MainActivity source so the expected logcat marker is explicit. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 92a1a03f-a5e0-4475-96fd-adb6cd5d193c
Use a MaterialComponents theme so TabLayout can be constructed and the listener callback can run during the device integration test. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 92a1a03f-a5e0-4475-96fd-adb6cd5d193c
|
/review |
|
❌ Android PR Reviewer failed. Please review the logs for details. |
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
Reviewed the current changes. Interface selection removes redundant registered bases while preserving independent interfaces and deterministic order; Java-name deduplication handles erasure, callback collection is unchanged, and focused plus on-device tests pass. No blocking issues found.
Fixes #11917.
Java callable wrapper generation now omits registered interfaces already inherited through a more-derived registered interface. This prevents generated Java classes from implementing both
TabLayout.OnTabSelectedListenerand its raw genericBaseOnTabSelectedListener, which javac rejects.Adds:
MSBuildDeviceIntegrationtest that builds and launches an app implementingTabLayout.IOnTabSelectedListener2, selects a tab, and verifiesOnTabSelectedrunsValidation:
Java.Interop.Tools.JavaCallableWrappers-Tests: 48 passedmaintargets .NET 11, while this machine has a .NET 10 SDK, and no Android device was connected