This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 198982 - NIO2 and FileSystems: FileObject to provide java.nio.file.Path
Summary: NIO2 and FileSystems: FileObject to provide java.nio.file.Path
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 7.1
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Assignee: Jaroslav Havlin
URL:
Keywords:
Depends on:
Blocks: 244319
  Show dependency tree
 
Reported: 2011-05-29 21:09 UTC by Jaroslav Tulach
Modified: 2014-11-06 10:45 UTC (History)
4 users (show)

See Also:
Issue Type: TASK
Exception Reporter:


Attachments
Test to verify netigso (5.45 KB, patch)
2011-06-30 14:15 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Tulach 2011-05-29 21:09:24 UTC
NIO2 is part of JDK7 and JDK7 is around the corner. There are many things that can be done to align filesystem API and NIO2. This issue is supposed to track them.

The first goal is to write a bridge to expose any FileObject based solution via NIO2 path API.
Comment 1 Jesse Glick 2011-06-28 21:34:24 UTC
I would say the first priority would be to use the native parts of NIO.2 to improve the functionality and reliability of existing NB code paths:

- create a Notifier impl delegating to WatchService

- use Files.probeContentType from a low-priority MIMEResolver

- define File FileUtil.fromURL(URL) and URL FileUtil.toURL(File), using Path.toUri and Paths.get(URI) on JDK 7 and using File.toURI and new File(URI) plus special UNC handling on JDK 6, and use them throughout the NB code base wherever URL's (or URI's) are being interconverted with File's

- define FileUtil methods delegating to Path.resolve/relativize on JDK 7 (and some near-equivalent on JDK 6) and use them in various places, e.g. project.ant

- use Files.copy(..., COPY_ATTRIBUTES) for FileObject.copy in masterfs

- use Path.normalize/realPath in FileUtil.normalizeFile
Comment 2 Jaroslav Tulach 2011-06-30 14:15:34 UTC
Created attachment 109169 [details]
Test to verify netigso
Comment 3 Jaroslav Tulach 2014-04-18 09:11:25 UTC
(In reply to Jaroslav Tulach from comment #0)
> The first goal is to write a bridge to expose any FileObject based solution
> via NIO2 path API.

http://bits.netbeans.org/8.0/javadoc/org-openide-filesystems/org/openide/filesystems/FileObject.html
should either implement http://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html
or have a method toPath like File has
http://docs.oracle.com/javase/7/docs/api/java/io/File.html#toPath()

The important question I ask myself is: How will we know our implementation of the Path interface is good enough? My favourite answer: We should have a TCK that works with Path interface (in the openide.filesystems module) and run it (at least) twice: once on Path objects provided by masterfs's FileObjects and once on plain java.io.File.toPath implementation. If they behave the same we can have enough confidence that our Path implementation is compatible enough.