boolean conversion for Java using same fix as in JS