Prevent integer overflow in Java's constant computation

We might just as well be using brainfuck, eh?

Change-Id: I102ae612aef4f1148efbeb292dfb0db98777c3c1