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

NPE when creating default file system when default file system provider is packaged as JAR file on class path

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9, 17
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Introduced In Version:
      9
    • Resolved In Build:
      b11

      Description

      If the system property java.nio.file.spi.DefaultFileSystemProvider is set to the name of a class in a JAR file on the class path then it leads to an NPE in the ZipFile code. This is a bootstrapping/initialization issue (and a regression since JDK 9) due to the ZipFile code needing to use the default file system provider. We may have to change ZipFile to use the built-in file system provider, at least for the class path case.


      $ java -cp classes:provider.jar -Djava.nio.file.spi.DefaultFileSystemProvider=TestProvider org.test.Test

      Exception in thread "main" java.lang.Error: java.lang.NullPointerException: Cannot invoke "java.nio.file.FileSystem.getPath(String, String[])" because the return value of "java.nio.file.FileSystems.getDefault()" is null
      at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.getDefaultProvider(FileSystems.java:133)
      at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder$1.run(FileSystems.java:102)
      at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder$1.run(FileSystems.java:100)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
      at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.defaultFileSystem(FileSystems.java:100)
      at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.<clinit>(FileSystems.java:94)
      at java.base/java.nio.file.FileSystems.getDefault(FileSystems.java:182)
      at org.test.Test.main(Test.java:7)
      Caused by: java.lang.NullPointerException: Cannot invoke "java.nio.file.FileSystem.getPath(String, String[])" because the return value of "java.nio.file.FileSystems.getDefault()" is null
      at java.base/java.io.File.toPath(File.java:2318)
      at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1246)
      at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:707)
      at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:241)
      at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:172)
      at java.base/java.util.jar.JarFile.<init>(JarFile.java:349)
      at java.base/jdk.internal.loader.URLClassPath$JarLoader.getJarFile(URLClassPath.java:816)
      at java.base/jdk.internal.loader.URLClassPath$JarLoader$1.run(URLClassPath.java:761)
      at java.base/jdk.internal.loader.URLClassPath$JarLoader$1.run(URLClassPath.java:754)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:691)
      at java.base/jdk.internal.loader.URLClassPath$JarLoader.ensureOpen(URLClassPath.java:753)
      at java.base/jdk.internal.loader.URLClassPath$JarLoader.<init>(URLClassPath.java:728)
      at java.base/jdk.internal.loader.URLClassPath$3.run(URLClassPath.java:496)
      at java.base/jdk.internal.loader.URLClassPath$3.run(URLClassPath.java:479)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:691)
      at java.base/jdk.internal.loader.URLClassPath.getLoader(URLClassPath.java:478)
      at java.base/jdk.internal.loader.URLClassPath.getLoader(URLClassPath.java:447)
      at java.base/jdk.internal.loader.URLClassPath.getResource(URLClassPath.java:316)
      at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:750)
      at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:676)
      at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:634)
      at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
      at java.base/java.lang.Class.forName0(Native Method)
      at java.base/java.lang.Class.forName(Class.java:466)
      at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.getDefaultProvider(FileSystems.java:123)
      ... 7 more

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              lancea Lance Andersen
              Reporter:
              alanb Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: