java.nio.file: Where is the Path interface actually implemented?

Viewed 9982

Recently I was doing some coding using the java.nio.file package introduced in Java 7 and saw an example using Path like this:

Path path = Paths.get("C:\\Users");

Given that Path is an interface I was confused on how you could have a reference to it, however after some research I found out that a reference to an interface is allowed but it must point to a class that implements the interface. Looking on from this I looked at the Paths class and saw that it didn't implement Path. Looking at the source code the actual method Paths.get method is as follows:

public static Path get(String first, String... more) {
    return FileSystems.getDefault().getPath(first, more);
}    

the method first returns an object of type FileSystem (from an abstract class I think) using what I believe is called a static factory method, but FileSystem also doesn't implement the interface.

My question is does anyone know/able to explain where the Path interface is actually implemented as I cannot seem to find where this occurs.

2 Answers
Related