refactored JavaGenerator