Uses the venerable ANTLR for generating the parser and the listeners.
Build the jar or download from the releases(when available):
mvn package
ls -la target/
...
toJava10.jar
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<>();
}
}
java -jar target/toJava10.jar -i src/main/resources/Simple.java
git ls-files '*.java' | xargs -I '{}' java -jar target/toJava10.jar -i '{}'