J2V8 是 V8 引擎的 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();
Maven:
com.eclipsesource.j2v8
j2v8_win32_x86_64
2.2.1
compile