def cached(cls, minimum_version=None, maximum_version=None, jdk=False):
    """Finds a java distribution that meets the given constraints and returns it.

    :API: public

    First looks for a cached version that was previously located, otherwise calls locate().
    :param minimum_version: minimum jvm version to look for (eg, 1.7).
                            The stricter of this and `--jvm-distributions-minimum-version` is used.
    :param maximum_version: maximum jvm version to look for (eg, 1.7.9999).
                            The stricter of this and `--jvm-distributions-maximum-version` is used.
    :param bool jdk: whether the found java distribution is required to have a jdk.
    :return: the Distribution.
    :rtype: :class:`Distribution`
    :raises: :class:`Distribution.Error` if no suitable java distribution could be found.
    """
    try:
      return cls.global_instance()._locator().locate(
          minimum_version=minimum_version,
          maximum_version=maximum_version,
          jdk=jdk)
    except _Locator.Error as e:
      raise cls.Error('Problem locating a java distribution: {}'.format(e))