Skip to content

Commit f3c122e

Browse files
committed
Update Object.GetObject() to use JniRuntime.JniValueManager
Should fix the unexpected P/Invoke which is causing the NativeAOT sample to crash: net.dot.jni.internal.JavaProxyThrowable: System.DllNotFoundException: DllNotFound_Linux, xa-internal-api, dlopen failed: library "xa-internal-api.so" not found dlopen failed: library "libxa-internal-api.so" not found dlopen failed: library "xa-internal-api" not found dlopen failed: library "libxa-internal-api" not found 01-30 02:19:25.570 3348 3348 E AndroidRuntime: at System.Runtime.InteropServices.NativeLibrary.LoadLibErrorTracker.Throw(String) + 0x47 at Internal.Runtime.CompilerHelpers.InteropHelpers.FixupModuleCell(InteropHelpers.ModuleFixupCell*) + 0xe2 at Internal.Runtime.CompilerHelpers.InteropHelpers.ResolvePInvokeSlow(InteropHelpers.MethodFixupCell*) + 0x35 at Android.Runtime.RuntimeNativeMethods.monodroid_TypeManager_get_java_class_name(IntPtr) + 0x22 at Java.Interop.TypeManager.GetClassName(IntPtr) + 0xe at Java.Interop.TypeManager.CreateInstance(IntPtr, JniHandleOwnership, Type) + 0x69 at Java.Lang.Object._GetObject[T](IntPtr, JniHandleOwnership) + 0x4e at Android.App.Application.n_OnCreate(IntPtr jnienv, IntPtr native__this) + 0x89 at my.MainApplication.n_onCreate(Native Method) at my.MainApplication.onCreate(MainApplication.java:24) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1182) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460) at android.app.ActivityThread.access$1300(ActivityThread.java:219) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
1 parent 68d632b commit f3c122e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/Mono.Android/Java.Lang/Object.cs

+3-7
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,9 @@ protected void SetHandle (IntPtr value, JniHandleOwnership transfer)
156156
if (handle == IntPtr.Zero)
157157
return null;
158158

159-
var r = PeekObject (handle, type);
160-
if (r != null) {
161-
JNIEnv.DeleteRef (handle, transfer);
162-
return r;
163-
}
164-
165-
return Java.Interop.TypeManager.CreateInstance (handle, transfer, type);
159+
var p = JNIEnvInit.ValueManager!.GetPeer (new JniObjectReference (handle), type);
160+
JNIEnv.DeleteRef (handle, transfer);
161+
return p;
166162
}
167163

168164
[EditorBrowsable (EditorBrowsableState.Never)]

0 commit comments

Comments
 (0)