'This next method wraps the `next` method in Java iterators.
The `Iterator.next()` method is called and if an exception occur (e.g.,
NoSuchElementException), a StopIteration exception is raised.'

def next(self):

    if (self._next_name not in self._methods):
        self._methods[self._next_name] = JavaMember(self._next_name, self, self._target_id, self._gateway_client)
    try:
        return self._methods[self._next_name]()
    except Py4JError:
        raise StopIteration()
