-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate newFileSystem(...) overloads that default to platform-specific settings #106
Comments
I am not as familiar as I should be with either (a)
|
I understand the behavior of Java's built-in Windows However, as far as I can tell, it was unnecessary for Jimfs to mimic this behavior right in the middle of a The less OS-specific behavior that a Java library exposes through its API, the more portable the library is. Based on the link you provided, it seems that this was an intentional choice. However, it's a very odd choice, and as I pointed out, can cause interoperability issues. In my case, my library assumed that everything after the GUID in a |
Having jimfs default to the behavior of the system it's running on definitely has downsides :( In your case, would |
Yes, that works fine, and makes the behavior on Windows and Linux exactly the same. Thanks for the suggestion. Although I still need to handle the Windows default configuration, since users of my library likely aren't calling Is there any advantage whatsoever to not using the Unix behavior as the default on all operating systems? It seems like the whole development world has come around to use Unix conventions (even Microsoft, by introducing WSL). Actually Unix style paths work perfectly fine with all Java APIs on Windows. The Unix default provides a much more straightforward mapping between Jimfs URLs and paths. |
Hi Luke. I'm not involved with the jimfs project but have been watching the repo. Here's my two cents. You've said:
Without knowing anything about what you're trying to do, can I ask why the folks using your library need to know about jimfs? It sounds like you've got a great opportunity to wrap jimfs and hide these implementation details. You could also give them a factory function that returns a file system configured "the right way". Good luck! |
@seanpoulter A user requested Jimfs support for the library I created, ClassGraph. Since a Jimfs Most of the time libraries probably don't need to do anything with the However I still find the syntax truly weird, and I don't see the purpose of allowing a drive letter in Jimfs, since that is only supported on Windows -- and every library written for Java should strive to be as cross-platform as possible! So if Jimfs-internal drive letters are not supported on Mac OS X or Linux or other Unices, they probably should not be supported on Windows. |
Thanks for the context. That is very clear and makes a lot more sense to me. The drive letter does not make sense in the URL like that. 😓 I found Jimfs looking for a way to mock the file system for an integration test. Depending on how thorough folks are testing, I'd expect some folks need that drive letter support. By the way, congrats on the great looking tool and zero bug policy. ClassGraph looks really interesting. 👏 |
That actually makes sense as a reasonable usecase, since if you just call However, I would still suggest making the Unix configuration the default for all operating systems, in the name of interoperability. Then if people want to test using Windows-like paths, they can enable that with one call.
Thanks! The library was born out of necessity, but it has been useful for a lot of people, since the JDK does not provide a "metamodel" natively yet. ClassGraph has been pretty stable for a couple of years now. The Zero Bugs Commitment was a reaction to spending 30 years reporting literally thousands of bugs in open source products, and seeing only maybe 1% of them fixed! |
Oddly enough, we originally had no methods that silently used the default platform... but then we were convinced to add them :\ The logic seems to have been that most people aren't going to write cross-platform code, anyway, so we might as well let them easily switch from the real filesystem for their platform to a corresponding fake one. Maybe that logic holds for app developers (e.g., if you're writing an Android app), but it's highly questionable for library developers. Given that all we're providing is the ability to write At this point, changing the default may be more harmful than helpful, especially in a world in which most build systems will silently let one of your dependencies update your version in jimfs in a way that breaks another dependency at runtime. I could imagine, though, that we could deprecate the no-arg |
I think that would be fine. The deprecation would alert users to the different behaviors, so they can decide which one they want to use. |
One more oddity of the Jimfs URL format: the drive letter may cause problems if URLs are relativized, since it may be confused for a protocol: https://stackoverflow.com/a/1737589/3950982 |
The following code
prints, on Windows:
This seems like a bug (even though the
Path
object is linked to theFileSystem
instance). The path should not need theC:
drive designation, as far as I can tell, because the GUID in the URI should be sufficient to locate the filesystem. The weird JimfsURI
andPath
syntax makes porting code between Linux and Windows problematic.On Linux the output is:
The text was updated successfully, but these errors were encountered: