Skip to content

Use Java identity in constructor activation tests#11343

Merged
jonathanpeppers merged 3 commits into
mainfrom
dev/simonrozsival/investigate-failing-constructoractivationtests
May 19, 2026
Merged

Use Java identity in constructor activation tests#11343
jonathanpeppers merged 3 commits into
mainfrom
dev/simonrozsival/investigate-failing-constructoractivationtests

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

The CoreCLRTrimmable constructor activation tests were comparing raw JNI reference handle values for forwarded Application.Context arguments. Equivalent Java objects can be represented by different JNI refs, so these assertions should check Java object identity instead.

This changes the affected assertions to use JNIEnv.IsSameObject(...) while preserving the existing constructor invocation and value checks.

Validation:

  • MSBUILDDISABLENODEREUSE=1 ./dotnet-local.sh build tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj -t:RunTestApp -c Release -p:_AndroidTypeMapImplementation=trimmable -p:IncludeCategories=ConstructorActivationStress -nr:false (temporary local category used only to focus the fixture; not committed)

Compare forwarded Java object constructor arguments with JNI object identity instead of raw JNI reference handles, since equivalent Java objects can be represented by distinct local/global refs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 14, 2026 07:24
@simonrozsival simonrozsival added the copilot `copilot-cli` or other AIs were used to author this label May 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates CoreCLRTrimmable constructor activation tests to validate forwarded Application.Context arguments using Java object identity rather than comparing raw JNI handle values, which may differ across equivalent references.

Changes:

  • Replaced Handle equality assertions with an identity-based assertion helper for Application.Context forwarding checks.
  • Added AssertSameJavaObject helper to centralize Java identity comparison logic.

simonrozsival and others added 2 commits May 14, 2026 12:12
Update the constructor activation helper to compare PeerReference values with JniEnvironment.Types.IsSameObject and assert inputs are non-null before dereferencing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label May 19, 2026
Copy link
Copy Markdown
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

DotNetRunWaitForExit failure is unrelated.

@jonathanpeppers jonathanpeppers merged commit ca7de98 into main May 19, 2026
2 of 3 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/simonrozsival/investigate-failing-constructoractivationtests branch May 19, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot `copilot-cli` or other AIs were used to author this ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants