Contain JNI logging failures and preserve UTF-8 payloads
This commit is contained in:
1 parent
c656e3a96b
commit
a77fc553e7
3 files changed
+139
-27
No files matched your search
@@ -0,0 +1,20 @@
|
||||
package com.utun.chat.data
|
||||
|
||||
import java.io.File
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
/** Сопоставляет настоящий JNI lookup с JVM-дескриптором скомпилированного Kotlin callback. */
|
||||
class NativeLogContractTest {
|
||||
@Test fun nativeLookupMatchesTheCompiledKotlinByteArrayCallback() {
|
||||
val method = LogManager::class.java.declaredMethods.single { it.name == "onNativeLog" }
|
||||
val descriptor = "(" + method.parameterTypes.joinToString("") {
|
||||
if (it == Int::class.javaPrimitiveType) "I" else it.name.replace('.', '/')
|
||||
} + ")" + if (method.returnType == Void.TYPE) "V" else method.returnType.name
|
||||
val source = File(requireNotNull(System.getProperty("utun.androidBridgeSource"))).readText()
|
||||
val native = Regex("GetMethodID\\(env, cls, \\\"onNativeLog\\\", \\\"([^\\\"]+)\\\"\\)").find(source)
|
||||
assertNotNull("JNI onNativeLog lookup missing", native)
|
||||
assertEquals("(I[B[B)V", descriptor)
|
||||
assertEquals(descriptor, native!!.groupValues[1])
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user