[tests] Use blittable RegisterNatives in JNI callback tests#12019
Open
simonrozsival wants to merge 2 commits into
Open
[tests] Use blittable RegisterNatives in JNI callback tests#12019simonrozsival wants to merge 2 commits into
simonrozsival wants to merge 2 commits into
Conversation
RegisterNativeMethods_JniNativeMethodRegistration and
RegisterNativeMethods_JniNativeMethodRegistration_ManyMethods exercise the
JniNativeMethodRegistration[] RegisterNatives path, which marshals managed
delegates and requires dynamic code (IL3050) - unsupported under the trimmable
typemap and NativeAOT, where native registration goes through the runtime
registerNatives path instead.
Add [Category ("NativeAOTIgnore")] and [Category ("TrimmableTypeMapUnsupported")]
so TestInstrumentation excludes them on NativeAOT (PublishAot) and trimmable
typemap runs, matching the other unsupported Java.Interop tests.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Java.Interop test metadata so two JniNativeMethodRegistration[] RegisterNatives tests can be excluded in NativeAOT/trimmable scenarios where delegate marshaling requires dynamic code and is not supported.
Changes:
- Add
NativeAOTIgnorecategory to twoJniNativeMethodRegistration[]registration tests. - Add
TrimmableTypeMapUnsupportedcategory to the same tests.
Show a summary per file
| File | Description |
|---|---|
| external/Java.Interop/tests/Java.Interop-Tests/Java.Interop/JniTypeTest.cs | Adds NUnit categories to skip the JniNativeMethodRegistration[] registration-path tests under specific runtimes/configurations. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 2
Keep the RegisterNatives coverage enabled under NativeAOT by switching the affected tests from JniNativeMethodRegistration[] delegate marshaling to the blittable JniNativeMethod span overload with UnmanagedCallersOnly function pointers. This avoids the dynamic-code requirement while preserving the single-method and many-method registration coverage. 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.
Summary
Tiny test-only split from #11822.
Instead of disabling the
RegisterNativeMethods_JniNativeMethodRegistration*coverage on trimmable NativeAOT, this updates those tests to use the NativeAOT-compatible path:ManagedAddis now[UnmanagedCallersOnly].RegisterNatives(JniObjectReference, ReadOnlySpan<JniNativeMethod>)overload with raw function pointers.JniNativeMethodRegistration[]delegate marshaling.Testing
dotnet test external/Java.Interop/tests/Java.Interop-Tests/Java.Interop-Tests.csproj --filter 'FullyQualifiedName~JniTypeTest.RegisterNativeMethods_JniNativeMethod'could not run in the temporary worktree because Java tool resolution failed before compiling tests (Java.Interop.targets: empty javac command, exit 127).Notes
Extracted from #11822 to keep the NativeAOT default flip focused.