fix superheating and supercooling for java backend

@traiansf @yilongli please review
Thanks for fixing this.  I wonder how we didn't notice it before.