Repository navigation
Conversation
eppleton
left a comment
There was a problem hiding this comment.
Making toPath work for every FileObject sounds useful, and the shared PathTestHid suite is a good base. Some observations from reading the code and checking the JDK and bootstrap sources; I didn't build or run the PR.
Most of the points below share one root: every PathTestHid test derives all paths from a single toPath() call, and on the fallback (non-disk) side the suite currently only runs on JarFileSystem, which is read-only. So equality across separate toPath() calls, writable virtual filesystems (MemoryFileSystem, MultiFileSystem/layers) and watch events are not exercised yet. Your "other filesystems" checklist item would catch several of these.
On the API side: toPath on master is only used from tests, so the new "never null" contract shouldn't break anything in the repo, but platform applications may use null as "not on disk". An apichanges.xml entry and a spec version bump would make that visible (I see it's on your checklist).
| import org.openide.filesystems.FileUtil; | ||
| import org.openide.util.lookup.ServiceProvider; | ||
|
|
||
| @ServiceProvider(service = FileTypeDetector.class, position = 100) |
There was a problem hiding this comment.
Files.probeContentType loads installed detectors with ServiceLoader.load(FileTypeDetector.class, ClassLoader.getSystemClassLoader()) (checked in the JDK 21 sources). In unit tests the module is on the system classpath, so this works. In the running IDE, openide.filesystems lives in platform/core and is loaded by MainImpl.BootClassLoader, not the system classloader, so I'd expect this detector never to be found there. Also, it's registered globally, so it would be asked about every Path in the JVM, not just the virtual ones; returning null early for non-NioPathForFileObject paths would keep it out of the way.
There was a problem hiding this comment.
- Interesting observation
- how do we want to address it?
- shell we register such an implementation in
openide.util.lookuporopenide.utiland ... - ... let the implementation delegate to all
FileTypeDetectors found in theLookup.getDefault()?
FileUtil.toPath to never return null
FileUtil.toPathLocalFileSystemFileObjectnullLocalFileSystemTestand make it pass - done in 1e50301Path<->FileObjectinteractions