Some questions and comments

Kasper Nielsen kasper at kav.dk
Wed Aug 24 06:29:31 PDT 2011


Hi,

I am trying to implement a simple in-memory FileSystem for some testing 
I am doing. And I've made a small mixed list of questions and comments.

1)
perhaps the equals and compare method should note that
/foo/./xxx != /foo/xxx

2)
There are no description of what happens when you give a null object to 
any of the methods in Path. For example, does endWith(null) return false 
or throws an NullPointerException. I know this is minor details, but no 
implementations of Path is available in the standard src.jar.
So I have too try each method to see what happens when I give it a null 
object (or download the Openjdk).

This is probably not an issue for ordinary users, but for people trying 
to implement the interface it is a bit annoying.

3)
Shouldn't Paths.get("").iterator().next() throw NoSuchElementException?
so it is consistent with Paths.get("/").resolve("").iterator().next();

4)
I know this is a bit to late now, but the warning on Path

This interface is only intended to be implemented by those developing 
custom file system implementations. Methods may be added to this 
interface in future releases.

Is there any reason why an Abstract base class wasn't used instead of an 
interface?

5)
Path.subpath() does not include an description in 
IllegalArgumentException for the default Path providers.
This is especially annoying because the implementation is not included 
in src.jar.
So you have to start guessing what the problem is. Is my endIndex larger 
then size, or is there something else wrong.

6)
Default users of FileVisitor should print more some context if null is 
returned from any of the methods in FileVisitor
If I return a null from a method in FileVisitor to walkFileTree. I get 
the following exception
Exception in thread "main" java.lang.NullPointerException: FileVisitor 
returned null
	at java.util.Objects.requireNonNull(Objects.java:226)
	at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:72)
	at java.nio.file.Files.walkFileTree(Files.java:2585)
	at java.nio.file.Files.walkFileTree(Files.java:2618)
	at xxxx

It does not indicate which method or class that returned a null. At 
least something like this should be possible
fileWalker.getClass().getCanonicalName()+ "." + "visitFile()" returned null

Also there are no description on FileVisitor about returning null values.

7)
Would be nice with a Files.isDirectoryEmpty(Path p);
Right now I am using Files.newDirectoryStream(p).iterator().hasNext() 
which it kind of ugly

Cheers
   Kasper


More information about the nio-discuss mailing list