Added common code for Java source generation.