Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.
/ ToJava10 Public archive

A translator of java source code to use java 10 features, such as var keyword, written in java

License

Notifications You must be signed in to change notification settings

rgolangh/ToJava10

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ToJava10

Translate java source code to use jdk's 10 var keyword.

Uses the venerable ANTLR for generating the parser and the listeners.

Build

Build the jar or download from the releases(when available):

mvn package

ls -la target/
...
toJava10.jar

Usage

Point it at some java class, by default the change goes to stdout:

java -jar target/toJava10.jar src/main/resources/Simple.java

/**
 * A simple java class with 2 local variables declaration in the constructor.
 * A test should use those for conversion to 'var' and  analyze the result.
 */
public class Simple {

    private int x = 42;

    public Simple() {
        // foo comment
        var age = 1;
        var map = new ConcurrentHashMap<>();
    }
}

Add -i to write the changes to the file in-place:

java -jar target/toJava10.jar -i src/main/resources/Simple.java

Convert your whole git repo:

git ls-files '*.java' | xargs -I '{}' java -jar target/toJava10.jar -i '{}'

About

A translator of java source code to use java 10 features, such as var keyword, written in java

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published