Jaspiler is a Java to Java transpiler. It transpiles the given Java code to the corresponding Java code with some customizations. It is expected to be a Babel for Java. If you like this project, please star it.
- Annotation based customizations
- AST based customizations
- JavaScript as the domain specific language (JS as DSL)
- Babel flavored plugins
- JDK 17 Support
- Download the all-in-one jar file
Jaspiler-${version}.jar
from the latest Actions. - Create a JavaScript file
test.js
as follows:
const result = jaspiler.transformSync(
`package com.test;
public class A {
}
`,
{
plugins: [{
visitor: {
Class(node) {
node.simpleName = jaspiler.createName('B');
},
},
}],
sourceType: 'string',
});
console.info(result.code);
- Execute the command as follows:
java -jar Jaspiler-${version}.jar test.js
- The output is as follows:
package com.test;
public class B {
}
The complete document is at the wiki.
- 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.
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.