News for hackers. Stuff that matters.
Re:Removal of Unsafe in Java 9 – A disaster in the making by vardump on Monday July 13, 2015 @11:53AM (#9878889)
It'd be unusably slow. "sun.misc.Unsafe" compiles in the instruction stream. JNI implementation would need to go through a complicated calling mechanism. I think it'd be up to 100x slower.
Re:Removal of Unsafe in Java 9 – A disaster in the making by karavelov on Monday July 13, 2015 @01:33PM (#9879602)
At least in OpenJDK it is in fact implemented as a JNI package, so it is already going through the JNI calling convention: http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/9b8c96f96a0f/s...
Re:Removal of Unsafe in Java 9 – A disaster in the making by vardump on Monday July 13, 2015 @02:42PM (#9880087)
I think these are a strong hint they're not truly JNI:

Line 61:

  * <p> Most methods in this class are very low-level, and correspond to a
  * small number of hardware instructions (on typical machines).  Compilers
  * are encouraged to optimize these methods accordingly.
Line 90:

  /// peek and poke operations
  /// (compilers should optimize these to memory ops)
Re:Removal of Unsafe in Java 9 – A disaster in the making by twic on Monday July 13, 2015 @02:14PM (#9879889)
That code shows that it's implemented as native methods, but not necessarily as JNI - these could be VM intrinsics, like Object::getClass and so on. This is the native code for Unsafe:

https://github.com/openjdk-mirror/jdk7u-hotspot/blob/master/...

It's certainly JNI-ish. Whether it is actually called via the JNI mechanism, i can't tell.