rewrite testgen in Java
rewrite testgen in Java