Fixes to Java code generation

Change-Id: I1f15aab2188200330208631f3360e40c14fd6d97