[typemap] Compare generated Java semantics - #12573
Open
simonrozsival wants to merge 5 commits into
Open
Conversation
Compare legacy and trimmable JCW classfile declarations after compiling each generated source set with javac, and exercise the shared fixture through llvm-ir, CoreCLR, and NativeAOT builds. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Include all declaration-relevant classfile modifiers in semantic parity and wait for javac termination before cleaning up a timed-out compilation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reference Mono.Android.Export explicitly for legacy generation and preserve observable interface declaration order across two implemented Java interfaces. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: 1
New issues introduced by this change (2)
| Severity | Finding |
|---|---|
tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/JavaSourceSemanticParityTests.cs — javac without CreateNoWindow/WindowStyle can flash a console window… |
|
tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/JavaSourceSemanticParityTests.cs — 💡 Cleanup in the finally block can throw (e.g., file locks/AV scanners), which can mask the real… |
What changed in this PR
This PR adds integration/build coverage to ensure the trimmable typemap Java source generator produces Java with the same declaration semantics as the legacy XAJavaInterop1 generator, by compiling both generated sources with javac and comparing the resulting classfile model.
Changes:
- Add a new semantic parity integration test that generates legacy vs trimmable Java, compiles with
javac, and compares parsed.classdeclarations (interfaces, ctors/methods/fields, modifiers, annotations, throws). - Introduce a shared managed fixture (
JavaSourceParityFixture) used by both generators and test harness. - Add a build test matrix to ensure the semantic parity fixture compiles across
llvm-ir/trimmableand CoreCLR/NativeAOT configurations.
| File | Description |
|---|---|
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests.csproj | Adds fixture project + bytecode reader dependency and embeds JavaCPath into assembly metadata for runtime javac invocation. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/JavaSourceSemanticParityTests.cs | New integration test that generates Java source for both pipelines, compiles via javac, reads classfile semantics, and asserts parity. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/JavaSourceParityFixture/JavaSourceParityTypes.cs | Adds the bounded managed fixture type set used for semantic parity comparisons. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/JavaSourceParityFixture/JavaSourceParityFixture.csproj | New fixture project that builds into the shared test output location and references ref assemblies as needed. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/TrimmableTypeMapBuildTests.cs | Adds build-time validation that the semantic parity fixture’s generated Java compiles across typemap/runtime configurations. |
Comment on lines
+224
to
+229
| var startInfo = new ProcessStartInfo { | ||
| FileName = compilerPath, | ||
| RedirectStandardOutput = true, | ||
| RedirectStandardError = true, | ||
| UseShellExecute = false, | ||
| }; |
Comment on lines
+151
to
+153
| } finally { | ||
| Directory.Delete (root, recursive: true); | ||
| } |
Remove retained-annotation comparison until the separate managed annotation forwarding work is available beneath this stack. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Split long declaration expectations into readable Mono-style multiline assertions without changing coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
27 tasks
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
Stacked on #12564 so the fixture consumes its shared constructor/method throws formatting fix. This is semantic-comparison groundwork; managed annotation forwarding remains covered by #12549, and the broader generated-Java parity checklist remains open.