Re:Removal of Unsafe in Java 9 – A disaster in the making
by pjmlp on Monday July 13, 2015 @02:30PM
(#9880003)
JNI
[ Parent
| on HN ]
Re:Removal of Unsafe in Java 9 – A disaster in the making
by colin_mccabe on Monday July 13, 2015 @09:52PM
(#9882375)
JNI has a very high per-call overhead. It is not an effective alternative to many things in Unsafe. For example, in Hadoop when using short-circuit local reads, the client determines if the file descriptor it has cached is still valid by doing a read from a memory-mapped file. The only way to do this with decent performance is with Unsafe#getLongVolatile. In contrast, JNI methods can't be inlined, often require copying memory back and forth, and don't work well with the just-in-time compiler.
In many cases, the overhead of JNI is too large to even use it, unless you move a large portion of the program out of Java. If Oracle goes through with this removal it will be a huge problem for Java and the JVM ecosystem.