refactored throwJavaException() and removed useless returns