Java_gen: improvements to the value types, courtesy of Yotam

Reviewer: @rlane