You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context: 903ba37
Context: e1af958
Context: dotnet/java-interop#1027
Commit 903ba37 mentioned a TODO:
> Update/rewrite infrastructure to focus on implementing the runtime
> side of marshal methods, making it possible to actually run
> applications which use marshal methods.
Implement the necessary runtime elements to enable running of
applications with marshal methods. It is now possible, if
LLVM marshal methods are enabled/`ENABLE_MARSHAL_METHODS` is defined,
to run both plain .NET SDK for Android and MAUI apps.
Update `src/Microsoft.Android.Sdk.ILLink/PreserveLists/System.Runtime.InteropServices.xml`
so that `System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute`
is always preserved, as it is required by LLVM Marshal Methods.
The `[UnmanagedCallersOnly]` attribute used by marshal methods
requires that the invoked method have [blittable types][0] for the
method return type and all parameter types. Unfortunately, `bool`
is *not* a blittable type. Implement generation of wrapper methods
which replace `bool` with `byte` and convert the values appropriately
before calling the actual target method. In a "hello world" MAUI
test app there are 133 such methods (out of around 180 total).
Implement code that enables us to show error messages with the proper
assembly, class and method names on failure to look up or obtain
pointer to native callback methods.
TODO:
* Process *all* assemblies, including `Mono.Android.dll`, for
Java Callable Wrapper generation. This is necessary so that we
can find and emit LLVM marshal methods for types defined within
`Mono.Android.dll`.
* Remove the `ENABLE_MARSHAL_METHODS` define, and enable
LLVM marshal methods for everyone.
* Update `<GenerateJavaStubs/>` to rewrite all assemblies for all
Supported ABIs. Currently, we don't support `Java.Lang.Object` &
`Java.Lang.Throwable` subclasses being located in per-ABI
assemblies.
* How do `Java_…` native functions interact with
`JNIEnv::RegisterNatives()`?
#7285 (comment)
* *Can* JNI `native` methods contain "non-printable" characters
such as `\n`, or "non-representable in ELF symbols" characters
such as `-` (e.g. Kotlin mangled methods)?
#7285 (comment)
* Cleanup, cleanup, cleanup
[0]: https://docs.microsoft.com/en-us/dotnet/framework/interop/blittable-and-non-blittable-types
@@ -522,6 +545,9 @@ public void RegisterNativeMembers (JniType nativeClass, Type type, ReadOnlySpan<
522
545
if(minfo==null)
523
546
thrownewInvalidOperationException(String.Format("Specified managed method '{0}' was not found. Signature: {1}",mname.ToString(),signature.ToString()));
524
547
callback=CreateDynamicCallback(minfo);
548
+
#if ENABLE_MARSHAL_METHODS
549
+
needToRegisterNatives=true;
550
+
#endif
525
551
}else{
526
552
TypecallbackDeclaringType=type;
527
553
if(!callbackDeclaringTypeString.IsEmpty){
@@ -530,20 +556,73 @@ public void RegisterNativeMembers (JniType nativeClass, Type type, ReadOnlySpan<
Log.LogWarning($"Type '{t.GetAssemblyQualifiedName()}' will register some of its Java override methods dynamically. This may adversely affect runtime performance. See preceding warnings for names of dynamically registered methods.");
0 commit comments