Skip to content

Deprecate newFileSystem(...) overloads that default to platform-specific settings #106

@lukehutch

Description

@lukehutch

The following code

try (FileSystem memFs = Jimfs.newFileSystem()) {
    Path memFsRoot = memFs.getPath("");
    URI uri = memFsRoot.toUri();
    Path path = Paths.get(uri);
    System.out.println("memFsRoot: " + memFsRoot);
    System.out.println("uri: " + uri);
    System.out.println("path: " + path);
}

prints, on Windows:

memFsRoot: 
uri: jimfs://4dbef289-e533-4340-8531-fe2cc6b2f0f3/C:/work/
path: C:\work

This seems like a bug (even though the Path object is linked to the FileSystem instance). The path should not need the C: drive designation, as far as I can tell, because the GUID in the URI should be sufficient to locate the filesystem. The weird Jimfs URI and Path syntax makes porting code between Linux and Windows problematic.

On Linux the output is:

memFsRoot: 
uri: jimfs://4dbef289-e533-4340-8531-fe2cc6b2f0f3/work/
path: /work

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3type=defectBug, not working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions