Skip to content

[tests] Cover virtual callbacks during construction - #12566

Open
simonrozsival wants to merge 2 commits into
mainfrom
simonrozsival-virtual-constructor-parity
Open

[tests] Cover virtual callbacks during construction#12566
simonrozsival wants to merge 2 commits into
mainfrom
simonrozsival-virtual-constructor-parity

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Summary

  • add a normal generated-registration fixture whose Java base constructor invokes an overridable managed method
  • cover managed-first and Java-first construction, final peer identity, reentrant and concurrent lookup, exactly-once construction, and callback exception propagation
  • bound concurrency waits so regressions fail deterministically instead of hanging

Matrix

The unchanged fixture passes under llvm-ir/MonoVM, trimmable/CoreCLR, and trimmable/NativeAOT (3/3 each). No production change was required.

Part of #12561

simonrozsival and others added 2 commits August 28, 2026 13:03
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

Review tier: Lite
Findings: 1 Low severity

New issues introduced by this change (1)
Severity Finding
Low severity tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​VirtualCallbackConstructorTests.cs — 💡 suggestionjavaClass is declared with using var but never used, which generates CS0219…
What changed in this PR

This PR expands the trimmable typemap runtime coverage test suite by adding a new fixture that validates virtual managed callbacks invoked from Java base constructors during object construction. It targets constructor-time peer identity stability, re-entrant/concurrent lookup behavior, and exception propagation in both managed-first and Java-first activation paths.

Changes:

  • Added a new Java base type whose constructor calls an overridable method to trigger virtual callbacks during construction.
  • Added a new managed test fixture covering managed-first vs Java-first construction, peer identity invariants, bounded concurrency, and callback exception behavior.
  • Wired the new test into the Mono.Android.NET-Tests project compilation list.
File Description
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Mono.Android.NET-Tests.csproj Includes the new virtual-callback constructor parity tests in the on-device test project.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​java/​net/​dot/​android/​test/​VirtualCallbackConstructorBase.java Introduces the Java base constructor callback trigger used by the new parity fixture.
tests/​Mono.Android-Tests/​Mono.Android-Tests/​Java.Interop/​VirtualCallbackConstructorTests.cs Implements NUnit coverage for constructor-time virtual callbacks, identity invariants, bounded concurrency, and exception propagation.

VirtualCallbackConstructorDerived.Reset ();
VirtualCallbackConstructorDerived.RunConcurrentLookup = true;

using var javaClass = VirtualCallbackConstructorDerived.GetJavaClass ();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants