-
-
Notifications
You must be signed in to change notification settings - Fork 1
Tech Detail Design
There is a Node.js runtime embedded in Jaspiler. It hosts multiple Babel flavored transform plugins that transform the Java code at AST level. Thanks to Javet (an awesome way of embedding Node.js and V8 in Java), Jaspiler is able to run JavaScript code easily.
With the help of Javet, Jaspiler injects a global namespace jaspiler
that enables the transform, AST manipulation, etc.
Though Jaspiler API is open if the applications prefer directly referencing the Jaspiler binary, it's quite inconvienent to write plugins in Java because Java applications have to go through the compilation, dependency resolution, runtime version mismatch, ...etc. That seriously slows down development.
Babel provides a much better experience in terms of transforming JavaScript code. So, why not borrow the similar experience in manipulating the Java AST in JavaScript? With Jaspiler, it is from write - compile - deploy - run
to write - run
with much better productivity and flexibility. Also, with the rich Node.js ecosystem, the JavaScript is able to access file system, network, basically not only do whatever a normal Node.js application can do, but also access the Java compiler exposed by Jaspiler.
Jaspiler has its own implementation on the official JavaCompiler
API built-in with JDK. So, the AST is the same as what javac
sees. Yes, that's 100% compatible. This design is at top of the line compared to other third-party implementations.