-
Notifications
You must be signed in to change notification settings - Fork 64
Register JNI natives via blittable JniNativeMethod #1474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5bf02a7
2a87d46
3882658
464419a
fd98743
00cb033
e2aa95c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| using System; | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| using Java.Interop; | ||
|
|
@@ -42,6 +43,7 @@ public void Ctor_ThrowsIfTypeNotFound () | |
| } | ||
|
|
||
| [Test] | ||
| [UnconditionalSuppressMessage ("AOT", "IL3050", Justification = "Test exercises non-AOT-compatible JniType.RegisterNativeMethods API.")] | ||
| public unsafe void Dispose_Exceptions () | ||
| { | ||
| var t = new JniType ("java/lang/Object"); | ||
|
|
@@ -175,6 +177,7 @@ public void RegisterWithRuntime () | |
| } | ||
|
|
||
| [Test] | ||
| [UnconditionalSuppressMessage ("AOT", "IL3050", Justification = "Test exercises non-AOT-compatible JniType.RegisterNativeMethods API.")] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Rule: Bug fixes need regression tests |
||
| public void RegisterNativeMethods () | ||
| { | ||
| using (var TestType_class = new JniType ("net/dot/jni/test/CallNonvirtualBase")) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 💡 Error handling —
Marshal.GetFunctionPointerForDelegate (m.Marshaler)throwsArgumentNullExceptionwhenMarshaleris null, whereas the old_RegisterNativespath marshalled a nullDelegatefield to a null function pointer without throwing. The#if DEBUGblock just above guards againstm.Marshaler == null, so null is part of this method's existing input contract — this is a behavioral change. Either reject it explicitly with an actionable message that names the offending entry/index, or passIntPtr.Zerowhenm.Marshaleris null. As written, the framework exception's parameter name (d) gives the caller no clue which registration was malformed.Rule: Include actionable details in exceptions