@VisibleForTesting
  static FileSystem newFileSystem(URI uri, Configuration config) {
    checkArgument(
        URI_SCHEME.equals(uri.getScheme()), "uri (%s) must have scheme %s", uri, URI_SCHEME);

    try {
      // Create the FileSystem. It uses JimfsFileSystemProvider as its provider, as that is
      // the provider that actually implements the operations needed for Files methods to work.
      JimfsFileSystem fileSystem =
          JimfsFileSystems.newFileSystem(JimfsFileSystemProvider.instance(), uri, config);

      /*
       * Now, call FileSystems.newFileSystem, passing it the FileSystem we just created. This
       * allows the system-loaded SystemJimfsFileSystemProvider instance to cache the FileSystem
       * so that methods like Paths.get(URI) work.
       * We do it in this awkward way to avoid issues when the classes in the API (this class
       * and Configuration, for example) are loaded by a different classloader than the one that
       * loads SystemJimfsFileSystemProvider using ServiceLoader. See
       * https://github.com/google/jimfs/issues/18 for gory details.
       */
      try {
        ImmutableMap<String, ?> env = ImmutableMap.of(FILE_SYSTEM_KEY, fileSystem);
        FileSystems.newFileSystem(uri, env, SystemJimfsFileSystemProvider.class.getClassLoader());
      } catch (ProviderNotFoundException | ServiceConfigurationError ignore) {
        // See the similar catch block below for why we ignore this.
        // We log there rather than here so that there's only typically one such message per VM.
      }

      return fileSystem;
    } catch (IOException e) {
      throw new AssertionError(e);
    }
  }
Creates a new in-memory file system with the given configuration.

<p>The returned file system uses the given name as the host part of its URI and the URIs of
paths in the file system. For example, given the name {@code my-file-system}, the file system's
URI will be {@code jimfs://my-file-system} and the URI of the path {@code /foo/bar} will be
{@code jimfs://my-file-system/foo/bar}.
jimfs/src/main/java/com/google/common/jimfs/Jimfs.java