Skip to content

Investigate better use of java.nio.file.Path in our JavaIoFilesystem #3952

@philwo

Description

@philwo

Taras suggested the following on bazel-dev:

when implementing JavaIoFilesystem methods you frequently use java.nio.file.Path, but instead of directly creating a java.nio.file.Path an extra allocation is used everywhere file.toPath() is used. In other words I'm only talking about implementation details - not changes to APIs. The other advantage I see is that if java.nio.file.Path was used instead of java.io.File, it would be possible to implement InMemoryFilesystem by just overriding a newly suggested getNioPath() method and jimfs would do the rest, which has an advantage of having to maintain one fewer FS implementations in Bazel :)

On a related note, I've noticed that some methods, like delete can be replaced with standard library functions like Files.delete and getDirectoryEntries can be implemented using Files.list. I'm guessing that it's because this filesystem implementation had to support older Java versions. Does anyone have any objections to migrate or at least add an additional getNioPath method in addition to getIoFile that can be used by methods that operate on java.nio.file.Path instead of java.io.File?

I'll look into this.

Metadata

Metadata

Assignees

Labels

P3We're not considering working on this, but happy to review a PR. (No assignee)category: misc > miscstaleIssues or PRs that are stale (no activity for 30 days)team-OSSIssues for the Bazel OSS team: installation, release processBazel packaging, websitetype: feature request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions