Skip to content

Use Java identity in constructor activation tests#11343

Open
simonrozsival wants to merge 2 commits into
mainfrom
dev/simonrozsival/investigate-failing-constructoractivationtests
Open

Use Java identity in constructor activation tests#11343
simonrozsival wants to merge 2 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.

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>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants