Skip to content
Sam Cao edited this page Jun 30, 2023 · 8 revisions

Why do I Need a Java to Java Transpiler

  • I want to code with JDK 17 but support JDK 8/11. Jaspiler can help transform the code from JDK 17 to JDK 8/11.
  • I want to remove some proprietary cloud features at source code level before deploying the binaries to an on-premise environment to prevent the reverse engineering. Jaspiler can help add/update/remove any part of the code at the AST level.
  • I want to translate the Java code to JavaScript/Python/Go/.... Jaspiler can provide the complete AST and allow all kinds of translation.
  • I want to obfuscate the code. Jaspiler can help perform all kinds of code obfuscation at the AST level.

What's the Status of Jaspiler?

Jaspiler is at its early stage with limited feature set. You are welcome taking a try. Jaspiler is expected to be a community driven open-source project, so if you want a feature, either you raise an issue, wait for the community to prioritize it, or you submit a pull request.

Why is the Jar File So Large?

Jaspiler jar file an all-in-one jar file with all the dependencies. It is large because it embeds Javet (30+MB) to provide the Node.js runtime environment.

How to get the AST without transforming it?

Just call jaspiler.transformSync(..., { ast: true, ... }) with ast: true, without plugins, and Jaspiler will skip the transformation and return the AST.

How to get the command-line arguments?

Please visit Parse argv

What are the Known Limitations?

  • Comments Might be Lost - The JDK JavaCompiler separates the DocScanner and TreeScanner so that the comments between 2 AST trees are lost. Luckily the comments are still preserved in the parent AST trees. So, if the parent trees are not changed during the transformation, the comments do get preserved. Otherwise, the comments are lost.