Split reflection-based JniTypeManager behavior#1441
Draft
simonrozsival wants to merge 15 commits into
Draft
Conversation
5ff4c17 to
6d72140
Compare
6d72140 to
58f0dbd
Compare
Member
Author
|
/azp run |
|
No pipelines are associated with this pull request. |
There was a problem hiding this comment.
Pull request overview
This draft PR refactors JniRuntime.JniTypeManager into an abstract base and moves the default reflection-based behavior into a new JniRuntime.DynamicJniTypeManager, with corresponding updates across tests, JRE runtime helpers, samples, and public API baselines.
Changes:
- Introduces
JniRuntime.DynamicJniTypeManagerand makesJniRuntime.JniTypeManagerabstract, shifting default/reflection-backed logic into the new derived type. - Updates test and JRE type managers to inherit from
DynamicJniTypeManager, and adjusts tests for new behaviors (e.g., generic invoker handling,GetTypearray behavior). - Updates trimmer/AOT annotations and PublicAPI baselines to reflect the split and new abstract members.
Show a summary per file
| File | Description |
|---|---|
| tests/Java.Interop-Tests/Java.Interop/JniTypeManagerTests.cs | Updates expectations around GetType behavior (notably array signatures and generic holder mapping). |
| tests/Java.Interop-Tests/Java.Interop/JniRuntimeTest.cs | Switches proxy manager to DynamicJniTypeManager and adds trim suppression for test-only reflection use. |
| tests/Java.Interop-Tests/Java.Interop/JniRuntime.JniTypeManagerTests.cs | Adds a generic invoker negative test and updates test manager base type. |
| tests/Java.Interop-Tests/Java.Interop/JavaVMFixture.cs | Updates fixture type manager to DynamicJniTypeManager and refines type lookup with trimming annotations. |
| src/Java.Runtime.Environment/Java.Interop/JreTypeManager.cs | Moves to DynamicJniTypeManager and adds a DAM-annotated GetTypeForSimpleReference override. |
| src/Java.Interop/PublicAPI.Unshipped.txt | Records newly introduced/reshaped APIs (new type, newly-abstract members, overrides). |
| src/Java.Interop/PublicAPI.Shipped.txt | Updates shipped API surface to reflect newly-abstract members and removed methods from JniTypeManager. |
| src/Java.Interop/Java.Interop/JniValueMarshaler.cs | Simplifies expression-based marshaler instantiation and adjusts trimming annotations. |
| src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs | Switches peer-type selection to GetReflectionConstructibleTypes() and refactors uninitialized peer creation. |
| src/Java.Interop/Java.Interop/JniRuntime.JniTypeManager.cs | Makes JniTypeManager abstract and factors previously-inlined logic into abstract core methods. |
| src/Java.Interop/Java.Interop/JniRuntime.DynamicJniTypeManager.cs | Adds the new reflection-backed type manager implementation and related registration behavior. |
| src/Java.Interop/Java.Interop/JniRuntime.cs | Removes the default new JniTypeManager() fallback; requires an explicit type manager in creation options. |
| src/Java.Interop/Java.Interop/JavaPrimitiveArrays.tt | Retargets primitive array helper generation to DynamicJniTypeManager. |
| src/Java.Interop/Java.Interop/JavaPrimitiveArrays.cs | Updates the generated primitive array helper container type to DynamicJniTypeManager. |
| src/Java.Interop/GlobalSuppressions.cs | Adds CA1034 suppression for the new nested DynamicJniTypeManager type. |
| samples/Hello-NativeAOTFromJNI/NativeAotTypeManager.cs | Updates sample type manager implementation to new hierarchy and adds explicit native member registration. |
| samples/Hello-NativeAOTFromJNI/ManagedType.cs | Changes the native registration hook to internal for sample-driven registration. |
| samples/Hello-NativeAOTFromAndroid/NativeAotTypeManager.cs | Updates sample type manager implementation to new hierarchy and implements abstract members. |
Copilot's findings
- Files reviewed: 18/18 changed files
- Comments generated: 3
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Map Java.Interop's internal proxy peer types in the base type manager so custom AOT-safe managers do not need reflection-based DynamicJniTypeManager behavior for JavaProxyThrowable/JavaProxyObject. Register built-in proxy native members by JNI type name before asking custom managers for a managed Type, avoiding DAM-annotated lookups of internal Exception/Delegate-derived types. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Let the base JniTypeManager resolve primitive JNI keyword signatures without requiring custom AOT-safe managers to duplicate the dynamic type manager's primitive mappings. Use that base lookup as a fallback when matching Java-to-managed constructor signatures so signatures such as (I)V resolve to System.Int32. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Draft PR to let CI validate the JniTypeManager split and AOT warning work.
Summary:
Local validation:
Notes: