Zip file system provider only works with default file system

Philippe Marschall philippe.marschall at
Sat Dec 8 05:41:28 PST 2012

On Sat, Dec 8, 2012 at 11:52 AM, Alan Bateman <Alan.Bateman at> wrote:
> On 07/12/2012 23:05, Philippe Marschall wrote:
>> Hi
>> First, I hope I got the right mailing list. I'm in the process of
>> writing my own file system provider. As a test I wanted to create a
>> zip file on it using the zip file system provider. That's when I
>> discovered that it only works with the default file system.
> Thanks for the bug report, It's possible that zip provider has been tested
> with other providers. Is your provider interposing on the system-default or
> is a distinct provider? I'm curious how you ran into this.

To give a bit more context my code looks something like this:

public class ZipFileSystemInteropabilityTest {

  public final FileSystemRule rule = new FileSystemRule();

  public void createZipFileSystem() throws IOException {
    FileSystem memoryFileSystem = this.rule.getFileSystem();
    Map<String, String> env = Collections.singletonMap("create", "true");
    URI uri = URI.create("jar:" +
    try (FileSystem zipfs = FileSystems.newFileSystem(uri, env)) {
      try (BufferedWriter writer =
StandardCharsets.US_ASCII, CREATE_NEW, WRITE)) {


where memoryFileSystem would be an instance of my custom memory file
system and the rule would be a JUnit rule that create a file system
before the test and removes it afterward.

The exception I get is: Permission denied
	at Method)
	at com.sun.nio.zipfs.ZipFileSystem.createTempFileInSameDirectoryAs(
	at com.sun.nio.zipfs.ZipFileSystem.sync(
	at com.sun.nio.zipfs.ZipFileSystem.close(
	at com.acme.memoryfilesystem.ZipFileSystemInteropabilityTest.createZipFileSystem(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(
	at com.acme.memoryfilesystem.FileSystemRule$1.evaluate(
	at ..

The problem is that the zip file system provider tries to create a
temp file like /zipfstmp5062712090450520532.tmp in the default file
system instead of the file system it's running on. And on Unix you
generally don't have the permission to create files in the root.


More information about the nio-dev mailing list