Class ModularRuntimeImage

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class ModularRuntimeImage
    extends java.lang.Object
    implements java.io.Closeable
    Wraps a Java 9 JEP 220 modular runtime image. Requires the JRT NIO file system.
    Since:
    6.3
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.net.URLClassLoader classLoader  
      private java.nio.file.FileSystem fileSystem  
      (package private) static java.lang.String MODULES_PATH  
      (package private) static java.lang.String PACKAGES_PATH  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        ModularRuntimeImage()
      Constructs a default instance.
        ModularRuntimeImage​(java.lang.String javaHome)
      Constructs an instance using the JRT file system implementation from a specific Java Home.
      private ModularRuntimeImage​(java.net.URLClassLoader cl, java.nio.file.FileSystem fs)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      java.nio.file.FileSystem getFileSystem()  
      java.util.List<java.nio.file.Path> list​(java.lang.String dirName)
      Lists all entries in the given directory.
      java.util.List<java.nio.file.Path> list​(java.nio.file.Path dirPath)
      Lists all entries in the given directory.
      java.util.List<java.nio.file.Path> modules()
      Lists all modules.
      java.util.List<java.nio.file.Path> packages()
      Lists all packages.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MODULES_PATH

        static final java.lang.String MODULES_PATH
      • PACKAGES_PATH

        static final java.lang.String PACKAGES_PATH
      • classLoader

        private final java.net.URLClassLoader classLoader
      • fileSystem

        private final java.nio.file.FileSystem fileSystem
    • Constructor Detail

      • ModularRuntimeImage

        public ModularRuntimeImage()
        Constructs a default instance.
      • ModularRuntimeImage

        public ModularRuntimeImage​(java.lang.String javaHome)
                            throws java.io.IOException
        Constructs an instance using the JRT file system implementation from a specific Java Home.
        Parameters:
        javaHome - Path to a Java 9 or greater home.
        Throws:
        java.io.IOException - an I/O error occurs accessing the file system
      • ModularRuntimeImage

        private ModularRuntimeImage​(java.net.URLClassLoader cl,
                                    java.nio.file.FileSystem fs)
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • getFileSystem

        public java.nio.file.FileSystem getFileSystem()
      • list

        public java.util.List<java.nio.file.Path> list​(java.nio.file.Path dirPath)
                                                throws java.io.IOException
        Lists all entries in the given directory.
        Parameters:
        dirPath - directory path.
        Returns:
        a list of dir entries if an I/O error occurs
        Throws:
        java.io.IOException - an I/O error occurs accessing the file system
      • list

        public java.util.List<java.nio.file.Path> list​(java.lang.String dirName)
                                                throws java.io.IOException
        Lists all entries in the given directory.
        Parameters:
        dirName - directory path.
        Returns:
        a list of dir entries if an I/O error occurs
        Throws:
        java.io.IOException - an I/O error occurs accessing the file system
      • modules

        public java.util.List<java.nio.file.Path> modules()
                                                   throws java.io.IOException
        Lists all modules.
        Returns:
        a list of modules
        Throws:
        java.io.IOException - an I/O error occurs accessing the file system
      • packages

        public java.util.List<java.nio.file.Path> packages()
                                                    throws java.io.IOException
        Lists all packages.
        Returns:
        a list of modules
        Throws:
        java.io.IOException - an I/O error occurs accessing the file system