Java API: null pointer should have checked at dispose()