java: fix NULL pointr exception introduced by last commit. suggested by Dang Hoang Vu