V8 引擎的 Java 绑定:J2V8

jopen 10年前

J2V8是一组针对V8的java绑定。J2V8专注于性能和与V8的紧密集成。It also takes a 'primitive first' approach, meaning that if a value can be accessed as a primitive, then it should be. 这迫使JS和Java代码之间的多个静态型系统,但它也提高了性能,因为不创建中间对象。

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]);  result.release();  v8.release();

项目主页:http://www.open-open.com/lib/view/home/1429836512838