https://kotlinlang.org logo
Title
m

martmists

11/23/2021, 1:54 PM
How would I pass "`--add-exports java.base/jdk.internal.misc=ALL-UNNAMED` " to compileKotlin in gradle? it's not a valid parameter but it still complains when compiling and using Unsafe
m

martmists

11/23/2021, 2:00 PM
so what should I do for now?
e

ephemient

11/23/2021, 2:01 PM
don't use internal JDK classes, or use them in a non-modular project
m

martmists

11/23/2021, 2:02 PM
how do I make my code non-modular then?
because afaik there's no other class that has methods like getLongUnaligned
e

ephemient

11/23/2021, 2:03 PM
compile with Java 8, and if you are on Java 9 at runtime, then the
--add-exports
flag can be added to jvm args there
what is readLongUnaligned?
m

martmists

11/23/2021, 2:05 PM
it's a method that reads a Long (or int/short/etc depending on the method) from a given byte array with given offset and endianness
e

ephemient

11/23/2021, 2:06 PM
I see no such method in jdk.internal.misc
m

martmists

11/23/2021, 2:06 PM
I tried setting project JDK to java 1.8 but now it doesn't recognize the Unsafe class anymore
I mean it does exist
ByteBuffer also uses that same function internally
e

ephemient

11/23/2021, 2:10 PM
why not just use ByteBuffer then?
ByteBuffer.wrap(byteArray).apply { position(index) }.getLong()