Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7138658

MODULE_MODE: java.nio.file.ProviderNotFoundException: Provider "jar" not found

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Not an Issue
    • Affects Version/s: 9-repo-jigsaw
    • Fix Version/s: None
    • Component/s: core-libs

      Description

      The following test run in module mode fails with "java.nio.file.ProviderNotFoundException: Provider "jar" not found" exception.

      > cat ZipFileSystemProviderTest.java
      package test;
      import java.nio.file.*;
      import java.net.URI;
      import java.util.Map;
      import java.util.Collections;

      public class ZipFileSystemProviderTest {

          public static void main(String[] args) throws Exception {
              try {
                  String urip = "jar:file:///tmp/test.zip";
                  URI uri = new URI(urip);

                  Map<String, ?> env = Collections.emptyMap();

                  FileSystem fs = FileSystems.newFileSystem(uri, env);

              } catch (Exception e) {
                      System.out.println("Exception: " + e); e.printStackTrace();
              }
          }
      }

      > cat module-info.java
      module test @ 1.0 {
        requires jdk.base;
            
        class test.ZipFileSystemProviderTest;
      }

      # compile and install
      > javac -d . *.java
        jar cf test.jar test/ module-info.class
        jmod -L mlib/ install test.jar


      # run
      > java -L mlib -m test
      Exception: java.nio.file.ProviderNotFoundException: Provider "jar" not foundjava.nio.file.ProviderNotFoundException: Provider "jar" not found at java.nio.file.FileSystems.newFileSystem(FileSystems.java:337)
              at java.nio.file.FileSystems.newFileSystem(FileSystems.java:272)
              at test.ZipFileSystemProviderTest.main(ZipFileSystemProviderTest.java:17)


      The test works fine in legacy mode.

      Adding "requires jdk.zipfs;" into module-info.java leads to following exception

      Exception in thread "main" java.util.ServiceConfigurationError: java.nio.file.spi.FileSystemProvider: Provider com.sun.nio.zipfs.ZipFileSystemProvider not found at java.util.ServiceLoader.fail(ServiceLoader.java:231) at java.util.ServiceLoader.access$400(ServiceLoader.java:181)
              at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:367) at java.util.ServiceLoader$1.next(ServiceLoader.java:438)
              at java.nio.file.spi.FileSystemProvider.loadInstalledProviders(FileSystemProvider.java:119)
              at java.nio.file.spi.FileSystemProvider.access$000(FileSystemProvider.java:77)
              at java.nio.file.spi.FileSystemProvider$1.run(FileSystemProvider.java:169)
              at java.nio.file.spi.FileSystemProvider$1.run(FileSystemProvider.java:166)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.nio.file.spi.FileSystemProvider.installedProviders(FileSystemProvider.java:166)
              at java.nio.file.FileSystems.newFileSystem(FileSystems.java:320)
              at java.nio.file.FileSystems.newFileSystem(FileSystems.java:272)
              at test.ZipFileSystemProviderTest.main(ZipFileSystemProviderTest.java:17)

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              epavlova Ekaterina Pavlova
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: