Fix Java lib exception handling.