Sadly, when I try to make a simple app using this library, it crashes:
val l: LIntArray = LArrayJ.newLIntArray(10000L) //crash here
l.update(0L, 20) // Set l[0L] = 20
l.update(1L, 123)
val e1: Int = l.apply(0L) // Get l[0L]
val e2: Int = l.apply(1L) // Get l[1L]
Log.d("AppLog", "first:$e1 second:$e2")
l.free()
Crash:
java.lang.ExceptionInInitializerError
at xerial.larray.buffer.DefaultMemoryAllocator.allocate(DefaultMemoryAllocator.java:69)
at xerial.larray.LIntArray.<init>(LArray.scala:802)
at xerial.larray.japi.LArrayJ.newLIntArray(LArrayJ.java:56)
at com.lb.myapplication.MainActivity$onCreate$1.invoke(MainActivity.kt:16)
at com.lb.myapplication.MainActivity$onCreate$1.invoke(MainActivity.kt:10)
at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
Caused by: java.lang.IllegalStateException: Failed to find constructor f java.nio.DirectByteBuffer: $s
at xerial.larray.buffer.UnsafeUtil.findDirectByteBufferConstructor(UnsafeUtil.java:40)
at xerial.larray.buffer.UnsafeUtil.<clinit>(UnsafeUtil.java:44)
at xerial.larray.buffer.DefaultMemoryAllocator.allocate(DefaultMemoryAllocator.java:69)
at xerial.larray.LIntArray.<init>(LArray.scala:802)
at xerial.larray.japi.LArrayJ.newLIntArray(LArrayJ.java:56)
at com.lb.myapplication.MainActivity$onCreate$1.invoke(MainActivity.kt:16)
at com.lb.myapplication.MainActivity$onCreate$1.invoke(MainActivity.kt:10)
at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
And it makes sense, because the requirements state that Android's VM is not supported:
A standard JVM, (e.g. Oracle JVM (standard JVM, HotSpotVM) or OpenJDK) must be used since larray-buffer depends on sun.misc.Unsafe class to allocate off-heap memory.
Is there any way to make it work still? Or an alternative to it?
I was hoping to use this to have a fallback in case I can't parse ZIP files using ZipFile: https://stackoverflow.com/q/61652063/878126
Sadly, when I try to make a simple app using this library, it crashes:
Crash:
My Application.zip
And it makes sense, because the requirements state that Android's VM is not supported:
Is there any way to make it work still? Or an alternative to it?