[java] Use only fast exceptions when not in debug mode