3 ms·
ByteBuffer provides universal access to on heap/off heap data. JNI or Unsafe allow to create ByteBuffer from native pointers, created in C/C++ or in Java using
by _old_dude_ 9y ago
ByteBuffer provides universal access to on heap/off heap data.
JNI or Unsafe allow to create ByteBuffer from native pointers, created in C/C++ or in Java using malloc, memcopy them, etc.
This is used (and abused) by most web servers, DataStax or LMAX-Exchange have even created their whole business on that.
You also have have CharBuffer, DoubleBuffer, FloatBuffer, etc
There is no stack allocated ByteBuffer in Java (Java provides no stack access, this is religious) but in Java can do relaxed data access on Buffer element, volatile access, opaque access, CAS, etc.
This is the same API.
- benaadams 9y agoDoes it work over non-primitive and user defined types? Object, InetAddress, etc Though only `struct` value types should be used in stack or native memory due to risk of GC holes
- _old_dude_ 9y agoNo, not yet. I believe there is a prototype of that kind of buffers that comes with the valhalla project (value types) but i've not tested it.