3 ms·
I'm sorta blown away at the complexity and overhead of making a native call in Java. Looks like this was one if the areas Microsoft was improving in Java, with
by MichaelGG 12y ago
I'm sorta blown away at the complexity and overhead of making a native call in Java. Looks like this was one if the areas Microsoft was improving in Java, with J/Direct? In comparison, calling native code from the CLR is a one-line affair. Even two-way; you just pass a delegate and the runtime creates a thunk on the fly.
- tormeh 12y agoA lot of the overhead is optional, I think. Lots of boilerplate, but if you know how to ask you get direct access to memory.
- pron 12y agoYes, and this was not something that demanded attention because Java originally wanted to discourage the use of native -- and platform specific -- code. So JNI was originally thought of as a bridge you build once to your legacy C code, and then move on. Recently, people have been wanting a more liberal use of native 3rd party libraries, so this issue is getting fixed with JNR[1], which will serve as the basis of Java's new FFI being developed under Project Panama[2]. [1]: https://github.com/jnr/jnr-ffi https://github.com/jnr/jnr-ffi [2]: http://openjdk.java.net/projects/panama/ http://openjdk.java.net/projects/panama/