Java2go is a transpiler that automatically converts Java source code to compatible Go code
It does this through several steps:
Parse the java source code into a
tree-sitterASTConvert that AST into Golang's own internal AST representation
Use Golang's builtin AST printer to print out the generated code
Note: Java2go is still in development, and as such, please expect many bugs
Currently, the following features are not implemented
- Enum classes (Fully)
- Generic types
- Any type of inheritance
- Abstract classes
- Lambda interfaces
- Inheritance
- Decorators
- Anything that checks
instanceof - Types for lambda expressions
Clone the repo
go buildto build the java2go binary./java2go <files>to parse a list of files or directories
-wwrites the files directly to their corresponding.gofiles, instead ofstdout-outputspecifies an alternate directory for the generated files. Defaults to putting them next to their source files by default-qprevents the outputs of the parsed files from appearing onstdout, if not being written-astpretty-prints the generated ast, in addition to any other options-symbols(WIP) controls whether the parser uses internal symbol tables to handle things such as name collistions, resulting in better code generation at the cost of increased parser complexity (default: true)-syncparses the files in sequential order, instead of in parallel-exclude-annotationsspecifies a list of annotations on methods and fields that will exclude them from the generated code