fix some bugs in Java generator