J2V8 2.2 New and Noteworthy

May 8, 2015 | 2 min Read

I’m happy to announce the availability of J2V8 2.2 (2.2.1 actually). This release adds two important features: 1) Typed Arrays and 2) 64 Bit Windows support.

Typed Arrays

In Javascript, most arrays are untyped. That is, you can create an array and add anything to it.

var myStuff = [];
myStuff[0] = 42;
myStuff[1] = true;
myStuff[2] = "Strings";

A  few years ago, the Javascript community realized the need for a more efficient mechanism for working with binary data in WebGL. The result of this work were Typed Arrays. Typed Arrays are a continuous chunk of memory with a typed view onto it. The memory is managed by the underlying engine and they perform a lot better than regular Javascript arrays.

var buffer = new ArrayBuffer(256);
var i32 = new Int32Array(buffer);
i32[0] = 1;
i32[1] = 3;
i32[2] = i32[0] + i32[1];

In this example, an array buffer of 256 bytes is allocated. A view, rendering the data as an array of 32bit integers, is then projected onto that buffer. Because the memory is continuous and the types are known, the operations (such as add in this case) perform much faster.

J2V8 2.2 supports the creation of Typed Arrays. You can even access the contents of the arrays, in bulk, from Java using the getIntsMethod (getDoubles and getBoolean for doubles and booleans).

V8 v8 = V8.createV8Runtime();
V8Array result = v8.executeArrayScript("var buffer = new ArrayBuffer(256);\n"
 + "var i32 = new Int32Array(buffer);\n"
 + "i32[0] = 1;\n"
 + "i32[1] = 3;\n"
 + "i32[2] = i32[0] + i32[1];\n"
 + "i32;");
int[] ints = result.getInts(0, 3);
System.out.println("Result: " + ints[0] + ", " + ints[1] + ", " + ints[2]);

64 Bit Windows Support

J2V8 now supports 64 bit Windows. The binaries have pushed to Maven Central and can be consumed using the following dependency.


For more news about J2V8, follow me on Twitter.

Ian Bull

Ian Bull

Ian is an Eclipse committer and EclipseSource Distinguished Engineer with a passion for developer productivity.

He leads the J2V8 project and has served on several …