casting typed array to java byte[] is it possible?

Paulo Lopes pmartins at redhat.com
Fri Oct 12 13:59:17 UTC 2018


Interesting enough, with Java >=9 the length is reported correctly, so
in the case of:

var bb = java.nio.ByteBuffer.allocateDirect(12)
var ab = new ArrayBuffer(bb)
var ia = new Int8Array(ab)

ia.length // prints 12
ab.byteLength // prints 12

This fails now on JDK8 and Graal.js (is Graal.js supposed to allow
this? (setting a ByteBuffer as the underlying buffer of a js
ArrayBuffer?)

I can imagine that for embedded applications this could make sense...



More information about the nashorn-dev mailing list