Skip to content

Commit 254717f

Browse files
committed
[WIP] Use icall instead of p/invoke
1 parent e012409 commit 254717f

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/Mono.Android/Android.Runtime/JNIEnv.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static void Initialize ()
272272
}
273273

274274
#if NETCOREAPP
275-
[DllImport (AndroidRuntime.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
275+
[MethodImplAttribute(MethodImplOptions.InternalCall)]
276276
extern static void monodroid_unhandled_exception (Exception javaException);
277277
#endif
278278

src/monodroid/jni/monodroid-glue-internal.hh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,6 @@ namespace xamarin::android::internal
174174
}
175175

176176
#if defined (NET6)
177-
void unhandled_exception (MonoObject *java_exception)
178-
{
179-
mono_unhandled_exception (java_exception);
180-
}
181-
182177
void propagate_uncaught_exception (JNIEnv *env, jobject javaThread, jthrowable javaException);
183178
#else // def NET6
184179
void propagate_uncaught_exception (MonoDomain *domain, JNIEnv *env, jobject javaThread, jthrowable javaException);
@@ -266,6 +261,8 @@ namespace xamarin::android::internal
266261
}
267262

268263
#if defined (NET6)
264+
static void monodroid_unhandled_exception (MonoObject *java_exception);
265+
269266
MonoClass* get_android_runtime_class ();
270267
#else // def NET6
271268
MonoClass* get_android_runtime_class (MonoDomain *domain);

src/monodroid/jni/monodroid-glue.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <mono/metadata/debug-helpers.h>
2828
#include <mono/metadata/mono-config.h>
2929
#include <mono/metadata/mono-debug.h>
30+
#include <mono/metadata/object.h>
3031
#include <mono/utils/mono-dl-fallback.h>
3132
#include <mono/utils/mono-logger.h>
3233

@@ -1009,6 +1010,9 @@ MonodroidRuntime::init_android_runtime (
10091010
{
10101011
mono_add_internal_call ("Java.Interop.TypeManager::monodroid_typemap_java_to_managed", reinterpret_cast<const void*>(typemap_java_to_managed));
10111012
mono_add_internal_call ("Android.Runtime.JNIEnv::monodroid_typemap_managed_to_java", reinterpret_cast<const void*>(typemap_managed_to_java));
1013+
#if defined (NET6)
1014+
mono_add_internal_call ("Android.Runtime.JNIEnv::monodroid_unhandled_exception", reinterpret_cast<const void*>(monodroid_unhandled_exception));
1015+
#endif // def NET6
10121016

10131017
struct JnienvInitializeArgs init = {};
10141018
init.javaVm = osBridge.get_jvm ();
@@ -1826,6 +1830,14 @@ MonodroidRuntime::create_and_initialize_domain (JNIEnv* env, jclass runtimeClass
18261830
return domain;
18271831
}
18281832

1833+
#if defined (NET6)
1834+
void
1835+
MonodroidRuntime::monodroid_unhandled_exception (MonoObject *java_exception)
1836+
{
1837+
mono_unhandled_exception (java_exception);
1838+
}
1839+
#endif // def NET6
1840+
18291841
MonoReflectionType*
18301842
MonodroidRuntime::typemap_java_to_managed (MonoString *java_type_name)
18311843
{

src/monodroid/jni/pinvoke-override-api.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,6 @@ monodroid_get_dylib (void)
345345
return nullptr;
346346
}
347347

348-
static void
349-
monodroid_unhandled_exception (MonoObject *java_exception)
350-
{
351-
monodroidRuntime.unhandled_exception (java_exception);
352-
}
353-
354348
#define PINVOKE_SYMBOL(_sym_) { #_sym_, reinterpret_cast<void*>(&_sym_) }
355349

356350
MonodroidRuntime::pinvoke_api_map MonodroidRuntime::xa_pinvoke_map = {
@@ -589,7 +583,6 @@ MonodroidRuntime::pinvoke_api_map MonodroidRuntime::xa_pinvoke_map = {
589583
PINVOKE_SYMBOL (recv_uninterrupted),
590584
PINVOKE_SYMBOL (send_uninterrupted),
591585
PINVOKE_SYMBOL (set_world_accessable),
592-
PINVOKE_SYMBOL (monodroid_unhandled_exception),
593586
};
594587

595588
MonodroidRuntime::pinvoke_library_map MonodroidRuntime::other_pinvoke_map (MonodroidRuntime::LIBRARY_MAP_INITIAL_BUCKET_COUNT);

0 commit comments

Comments
 (0)