-
Notifications
You must be signed in to change notification settings - Fork 52
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
Remove unused code in the interop layers #1255
Comments
I was wrong. (Or at least, not quite right.) dotnet/android@2f93f763 removes support for JNI Global References being direct object pointers. Meaning instead of there being an indirection (GREF value > GREF table > object instance), the GREF value was the object instance. In a world in which objects can move around in memory due to GC, "direct" references cannot work, but Android worked this way for quite some time (through API-13). Consequently, dotnet/android@2f93f763 is entirely unrelated to our code to use The That said, we have no current tests which set this property, and I see no obvious usage of |
Context: dotnet/java-interop#1255 Context: xamarin/monodroid@a5c5290 Context: https://issuetracker.google.com/issues/36986478 Context: https://github.com/dotnet/android/blob/b56d68fe2a2c2dffa47eb7e41ae08a00fda86367/Documentation/workflow/SystemProperties.md#debugmonowref Android did not support [JNI Weak Global References][0] until API-8 (Android 2.2). To allow Mono for Android applications to run on API-7 and earlier devices, while using JNI Weak Global References when possible (fewer GC allocations, better performance), the GC bridge supported two modes of operation: * `debug.mono.wref=jni`: Use JNI Weak Global References. * `debug.mono.wref=java`: Use [`java.lang.ref.WeakReference`][1]. With the exception of a ["minor" (lol) issue][2] in KitKat v4.4.2 (API-19) -- in which `JNIEnv::NewGlobalRef()` around a collected JNI Weak Global Reference would return a non-`NULL` value, which would result in app crashes; xamarin/monodroid@a5c52905 added a workaround to use the `WeakReference` backend on Android 4.4.2 -- the `debug.mono.wref=java` backend has not been used since *2014*. Apps *could* use [`@(AndroidEnvironment)`][3] to set `debug.mono.wref=java`, but there is no reason to do so (worse performance!), [nor has anyone done so on GitHub.com][4] (no matches for `debug.mono.wref` within files that would be used with `@(AndroidEnvironment)`). Cleanup src/native and src/Mono.Android, and *remove* support for the `debug.mono.wref=java` backend. [0]: https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#weak_global_references [1]: https://developer.android.com/reference/java/lang/ref/WeakReference [2]: https://issuetracker.google.com/issues/36986478 [3]: https://learn.microsoft.com/dotnet/android/building-apps/build-items#androidenvironment [4]: https://github.com/search?type=code&q=debug.mono.wref
Context: dotnet/java-interop#1255 Context: xamarin/monodroid@a5c5290 Context: https://issuetracker.google.com/issues/36986478 Context: https://github.com/dotnet/android/blob/b56d68fe2a2c2dffa47eb7e41ae08a00fda86367/Documentation/workflow/SystemProperties.md#debugmonowref Android did not support [JNI Weak Global References][0] until API-8 (Android 2.2). To allow Mono for Android applications to run on API-7 and earlier devices, while using JNI Weak Global References when possible (fewer GC allocations, better performance), the GC bridge supported two modes of operation: * `debug.mono.wref=jni`: Use JNI Weak Global References. * `debug.mono.wref=java`: Use [`java.lang.ref.WeakReference`][1]. With the exception of a ["minor" (lol) issue][2] in KitKat v4.4.2 (API-19) -- in which `JNIEnv::NewGlobalRef()` around a collected JNI Weak Global Reference would return a non-`NULL` value, which would result in app crashes; xamarin/monodroid@a5c52905 added a workaround to use the `WeakReference` backend on Android 4.4.2 -- the `debug.mono.wref=java` backend has not been used since *2014*. Apps *could* use [`@(AndroidEnvironment)`][3] to set `debug.mono.wref=java`, but there is no reason to do so (worse performance!), [nor has anyone done so on GitHub.com][4] (no matches for `debug.mono.wref` within files that would be used with `@(AndroidEnvironment)`). Cleanup src/native and src/Mono.Android, and *remove* support for the `debug.mono.wref=java` backend. [0]: https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#weak_global_references [1]: https://developer.android.com/reference/java/lang/ref/WeakReference [2]: https://issuetracker.google.com/issues/36986478 [3]: https://learn.microsoft.com/dotnet/android/building-apps/build-items#androidenvironment [4]: https://github.com/search?type=code&q=debug.mono.wref
Context: dotnet/java-interop#1255 Context: xamarin/monodroid@a5c5290 Context: https://issuetracker.google.com/issues/36986478 Context: https://github.com/dotnet/android/blob/b56d68fe2a2c2dffa47eb7e41ae08a00fda86367/Documentation/workflow/SystemProperties.md#debugmonowref Android did not support [JNI Weak Global References][0] until API-8 (Android 2.2). To allow Mono for Android applications to run on API-7 and earlier devices, while using JNI Weak Global References when possible (fewer GC allocations, better performance), the GC bridge supported two modes of operation: * `debug.mono.wref=jni`: Use JNI Weak Global References. * `debug.mono.wref=java`: Use [`java.lang.ref.WeakReference`][1]. With the exception of a ["minor" (lol) issue][2] in KitKat v4.4.2 (API-19) -- in which `JNIEnv::NewGlobalRef()` around a collected JNI Weak Global Reference would return a non-`NULL` value, which would result in app crashes; xamarin/monodroid@a5c52905 added a workaround to use the `WeakReference` backend on Android 4.4.2 -- the `debug.mono.wref=java` backend has not been used since *2014*. Apps *could* use [`@(AndroidEnvironment)`][3] to set `debug.mono.wref=java`, but there is no reason to do so (worse performance!), [nor has anyone done so on GitHub.com][4] (no matches for `debug.mono.wref` within files that would be used with `@(AndroidEnvironment)`). Cleanup src/native and src/Mono.Android, and *remove* support for the `debug.mono.wref=java` backend. [0]: https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#weak_global_references [1]: https://developer.android.com/reference/java/lang/ref/WeakReference [2]: https://issuetracker.google.com/issues/36986478 [3]: https://learn.microsoft.com/dotnet/android/building-apps/build-items#androidenvironment [4]: https://github.com/search?type=code&q=debug.mono.wref
Context: dotnet/java-interop#1255 Context: xamarin/monodroid@a5c5290 Context: https://issuetracker.google.com/issues/36986478 Context: https://github.com/dotnet/android/blob/b56d68fe2a2c2dffa47eb7e41ae08a00fda86367/Documentation/workflow/SystemProperties.md#debugmonowref Android did not support [JNI Weak Global References][0] until API-8 (Android 2.2). To allow Mono for Android applications to run on API-7 and earlier devices, while using JNI Weak Global References when possible (fewer GC allocations, better performance), the GC bridge supported two modes of operation: * `debug.mono.wref=jni`: Use JNI Weak Global References. * `debug.mono.wref=java`: Use [`java.lang.ref.WeakReference`][1]. With the exception of a ["minor" (lol) issue][2] in KitKat v4.4.2 (API-19) -- in which `JNIEnv::NewGlobalRef()` around a collected JNI Weak Global Reference would return a non-`NULL` value, which would result in app crashes; xamarin/monodroid@a5c52905 added a workaround to use the `WeakReference` backend on Android 4.4.2 -- the `debug.mono.wref=java` backend has not been used since *2014*. Apps *could* use [`@(AndroidEnvironment)`][3] to set `debug.mono.wref=java`, but there is no reason to do so (worse performance!), [nor has anyone done so on GitHub.com][4] (no matches for `debug.mono.wref` within files that would be used with `@(AndroidEnvironment)`). Cleanup src/native and src/Mono.Android, and *remove* support for the `debug.mono.wref=java` backend. [0]: https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#weak_global_references [1]: https://developer.android.com/reference/java/lang/ref/WeakReference [2]: https://issuetracker.google.com/issues/36986478 [3]: https://learn.microsoft.com/dotnet/android/building-apps/build-items#androidenvironment [4]: https://github.com/search?type=code&q=debug.mono.wref
dotnet/android@e98ae9c removes support for Development of #1257 can resume, if desired. |
I'll get to it in the upcoming week[s]. Thanks for the Android PR! |
Casual look at the
Java.Interop
/java-interop
projects that there's a lot of code that can be removed since it's no longer used:WeakReference
instead of the JNI weak handle. This option is not used anymore but the native code to support it still exists:java-interop/src/java-interop/java-interop-gc-bridge-mono.cc
Lines 1288 to 1292 in 5bd93ae
/java_interop_strdup
java_interop_free
The text was updated successfully, but these errors were encountered: