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.
It can be put over an array (as per ByteBuffer); but also over stack allocated memory; a native pointer T* etc
The underlying allocation is separate from the type