Skip to content

duhongbo123/java2go

 
 

Repository files navigation

Java2go

About

Java2go is a transpiler that automatically converts Java source code to compatible Go code

It does this through several steps:

  1. Parse the java source code into a tree-sitter AST

  2. Convert that AST into Golang's own internal AST representation

  3. Use Golang's builtin AST printer to print out the generated code

Usage

  • Clone the repo

  • go build to build the java2go binary

  • ./java2go <files> to parse a list of files or directories

Options

  • -w writes the files directly to their corresponding .go files, instead of stdout

  • -outDir specifies an alternate directory for the generated files. Defaults to putting them next to their source files by default

  • -q prevents the outputs of the parsed files from appearing on stdout, if not being written

  • -ast pretty-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)

  • -sync parses the files in sequential order, instead of in parallel

  • -exclude-annotations specifies a list of annotations on methods and fields that will exclude them from the generated code

About

Experimental Java to Go transcompiler that converts between a Java AST to native Go code

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Go 78.6%
  • Java 19.9%
  • Makefile 1.5%