code: def relativize_classpath(classpath, root_dir, followlinks=True):
    
    def relativize_url(url, root_dir):
      # When symlink is involed, root_dir concatenated with the returned relpath may not exist.
      # Consider on mac `/var` is a symlink of `/private/var`, the relative path of subdirectories
      # under /var to any other directories under `/` computed by os.path.relpath misses one level
      # of `..`. Use os.path.realpath to guarantee returned relpath can always be located.
      # This is not needed only when path are all relative.
      url = os.path.realpath(url) if followlinks else url
      root_dir = os.path.realpath(root_dir) if followlinks else root_dir
      url_in_bundle = os.path.relpath(url, root_dir)
      # Append '/' for directories, those not ending with '/' are assumed to be jars.
      # Note isdir does what we need here to follow symlinks.
      if os.path.isdir(url):
        url_in_bundle += '/'
      return url_in_bundle
  
    return [relativize_url(url, root_dir) for url in classpath]
docs: Convert into classpath relative to a directory.
  
    This is eventually used by a jar file located in this directory as its manifest
    attribute Class-Path. See
    https://docs.oracle.com/javase/7/docs/technotes/guides/extensions/spec.html#bundled
  
    :param list classpath: Classpath to be relativized.
    :param string root_dir: directory to relativize urls in the classpath, does not
      have to exist yet.
    :param bool followlinks: whether to follow symlinks to calculate relative path.
  
    :returns: Converted classpath of the same size as input classpath.
    :rtype: list of strings