Skip to content
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

Any way to make this work on Android? #73

Open
AndroidDeveloperLB opened this issue May 7, 2020 · 0 comments
Open

Any way to make this work on Android? #73

AndroidDeveloperLB opened this issue May 7, 2020 · 0 comments

Comments

@AndroidDeveloperLB
Copy link

AndroidDeveloperLB commented May 7, 2020

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:

                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) 

My Application.zip

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant