j2v8 Tag

J2V8 provides a tight binding between Java and the V8 JavaScript engine. Using JNI, you can execute JS scripts on V8, get and set values, register callbacks and invoke JavaScript functions -- all from Java. However, because of the subtleties related to multiple threads, J2V8 requires that all interactions happen from the same thread. Because JavaScript itself is single threaded, this works out ok. But what if you...

Read More

When working with JNI, sooner or later you will need to track references to native objects. This came up in J2V8 pretty quickly. With J2V8 we need to keep a handle to the V8 Isolate (an isolated V8 runtime for executing Javascript on). All JNI calls to V8 need to first acquire the isolate, and then perform operations such as executeScript, getValue, setValue, callFunction, etc...

Read More

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. [raw] var myStuff = []; myStuff[0] = 42; myStuff[1] = true; myStuff[2] = "Strings"; [/raw] A  few years ago, the Javascript community realized the need for a more efficient...

Read More

Wiki's and Readme files are the most common ways to document a build. While documenting a build is better than not documenting it, Wikis and Readme files have two flaws when used to describe a process: 1) they require humans to read them, and 2) they evolve. Of course the fact that Wikis evolve is often seen as their biggest strength. However, when trying to reproduce...

Read More

Last year I announced J2V8, a new JavaScript engine for Java that wraps V8 with a set of Java Bindings. We have been using this technology to power Tabris.js on Android -- giving us much better performance than Rhino could. While J2V8 was very stable, it wasn't very easy to consume. Today I'm happy to announce that J2V8 2.0 has shipped, and it's much easier...

Read More

Over the past 4 months I've been working on integrating Java and JavaScript in a highly efficient manner. Rhino and Nashorn are two common JavaScript runtimes, but these did not meet our requirements in a number of areas: Neither support 'Primitives'. All interactions with these platforms require wrapper classes such as Integer, Double or Boolean. Nashorn is not supported on Android. Rhino compiler optimizations are not supported on...

Read More