Skip to content

Commit 6bb25bd

Browse files
authored
Kotlin: Pass explicit T::class.java to Native.register (#2678)
A follow-up PR for #2229. This is to prevent `Native.register` from throwing `IllegalStateException` on Android like the following: ``` java.lang.IllegalStateException: The SecurityManager implementation on this platform is broken; you must explicitly provide the class to register ```
1 parent 731ba33 commit 6bb25bd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

uniffi_bindgen/src/bindings/kotlin/templates/NamespaceLibraryTemplate.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ external fun {{ func.name() }}(
7575
// We now use JNA's "direct mapping" - unclear if same considerations apply exactly.
7676
internal object IntegrityCheckingUniffiLib {
7777
init {
78-
Native.register(findLibraryName(componentName = "{{ ci.namespace() }}"))
78+
Native.register(IntegrityCheckingUniffiLib::class.java, findLibraryName(componentName = "{{ ci.namespace() }}"))
7979
uniffiCheckContractApiVersion(this)
8080
{%- if !config.omit_checksums %}
8181
uniffiCheckApiChecksums(this)
@@ -95,7 +95,7 @@ internal object UniffiLib {
9595
{% endif %}
9696

9797
init {
98-
Native.register(findLibraryName(componentName = "{{ ci.namespace() }}"))
98+
Native.register(UniffiLib::class.java, findLibraryName(componentName = "{{ ci.namespace() }}"))
9999
{% for fn_item in self.initialization_fns(ci) -%}
100100
{{ fn_item }}
101101
{% endfor %}

0 commit comments

Comments
 (0)