found a bug on uiFixture and the only solution would be creating a cut-down copy of the original ui

This commit is contained in:
minjaesong
2024-01-27 19:48:44 +09:00
parent 8b1331770d
commit 46b55f6303
4 changed files with 40 additions and 2 deletions

View File

@@ -58,6 +58,20 @@ internal object UnsafeHelper {
* @return offset from the array's base memory address (aka pointer) that the actual data begins.
*/
fun getArrayOffset(obj: Any) = unsafe.arrayBaseOffset(obj.javaClass).toLong()
fun addressOf(o: Any): Long {
val array = arrayOf(o)
val baseOffset = unsafe.arrayBaseOffset(Array<Any>::class.java).toLong()
val addressSize = unsafe.addressSize()
val objectAddress = when (addressSize) {
4 -> unsafe.getInt(array, baseOffset).toLong()
8 -> unsafe.getLong(array, baseOffset)
else -> throw Error("unsupported address size: $addressSize")
}
return (objectAddress)
}
}
/**