JNI GetDirectBufferAddress vs. ByteBuffer.array()
<p>I have to mix c++ code with java. 
The java part allocates a <strong>java.nio.ByteBuffer</strong> and the c++ part gets it's address via <strong>env->GetDirectBufferAddress(buffer)</strong> as a jbyte* and fills in data.</p>

<p>ByteOrder is ok. Data can be retrieved in java via buffer.get() .getLong() etc.</p>

<p>However, the method buffer.array() fails and hasArray() returns false.
If I use buffer.allocate(size) instead of .allocateDirect(size) the method array() works well, but my c++ code gets a DirectBufferAddress of NULL and fails.</p>

<p>My question: how can I best combine both worlds, with least copying of data?
Or, how to easiest fill a java byte[] with native c++ data ? </p>