Repository navigation
[Java.Interop] Cache peer activation constructors - #12354
jonathanpeppers merged 2 commits into
Conversation
Cache reflection-based XA, Java.Interop, and missing constructor resolution once per managed type while preserving XA-first activation semantics. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 06d344d6-8ee8-4076-9517-b1b5822a56be
There was a problem hiding this comment.
Pull request overview
This PR optimizes the reflection-based peer activation path in Java.Interop.TypeManager.CreateProxy by caching activation constructor resolution per managed Type, addressing the performance concern in #7479.
Changes:
- Add a
Type→ activation-constructor cache (including “missing constructor” entries) forTypeManager.CreateProxy, preferring(IntPtr, JniHandleOwnership)and falling back to(ref JniObjectReference, JniObjectReferenceOptions). - Add focused on-device tests to validate XA preference, Java.Interop fallback behavior, and missing-constructor caching via reflection.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/ConstructorActivationTests.cs | Adds reflection-driven tests/helpers to validate constructor caching behavior in TypeManager.CreateProxy. |
| src/Mono.Android/Java.Interop/TypeManager.cs | Implements a cached resolution path for activation constructors to avoid repeated reflection. |
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 06d344d6-8ee8-4076-9517-b1b5822a56be
|
@dalexsoto review |
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
✅ LGTM — 0 errors, 0 warnings, 1 non-blocking suggestion. Constructor preference, Java.Interop fallback, missing-constructor behavior, and JNI ownership semantics are preserved and covered by focused tests. CI remains in progress; all completed checks observed are passing.
Generated by Android PR Reviewer for #12354 · gpt56 · 104 AIC · ⌖ 20.2 AIC · ⊞ 25.6K
Comment /review to run again
dalexsoto
left a comment
There was a problem hiding this comment.
Constructor caching preserves activation resolution, concurrency, and JNI lifetime semantics, with the exact-head checks green.
Description
Cache reflection-based peer activation constructor resolution once per managed
TypeinTypeManager.CreateProxy.The cache:
(IntPtr, JniHandleOwnership)constructor(ref JniObjectReference, JniObjectReferenceOptions)System.Threading.LockAdd focused reflection activation tests for XA preference, Java.Interop fallback, and missing-constructor caching.
Fixes #7479
Validation
make all CONFIGURATION=DebugReflectionCreateProxytests passed (3/3)ActivityTaskManager Displayedruns after a 5-second warmup:The startup result is indicative and within observed run-to-run variance.