title: How can I get short[] from a ByteBuffer
body: <p>I am using JNI code in an Android project in which the JNI native function requires a short[] argument. However, the original data is stored as a ByteBuffer. I'm trying the convert the data format as follows.</p>
  
  <pre><code>ByteBuffer rgbBuf = ByteBuffer.allocate(size);
  ...    
  short[] shortArray = (short[]) rgbBuf.asShortBuffer().array().clone();
  </code></pre>
  
  <p>But I encounter the following problem when running the second line of code shown above:</p>
  
  <pre><code>E/AndroidRuntime(23923): Caused by: java.lang.UnsupportedOperationException
  E/AndroidRuntime(23923): at Java.nio.ShortToByteBufferAdapter.protectedArray(ShortToByteBufferAdapter.java:169)
  </code></pre>
  
  <p>Could anyone suggest a means to implement the conversion?</p>