Class ClasspathOrModulePathEntry


  • public class ClasspathOrModulePathEntry
    extends Object
    An entry in the classpath or module path. If the path is an http(s):// URL, the remote jar will be fetched and cached if getFile() / isFile() etc. are called. If the path is a '!'-separated path to a nested jar, the innermost jar will be extracted and cached on these calls.
    • Field Detail

      • classLoaders

        public ClassLoader[] classLoaders
        The ClassLoader(s) used to load classes for this classpath element
    • Constructor Detail

      • ClasspathOrModulePathEntry

        public ClasspathOrModulePathEntry​(String pathToResolveAgainst,
                                          String relativePath,
                                          ClassLoader[] classLoaders,
                                          NestedJarHandler nestedJarHandler,
                                          ScanSpec scanSpec,
                                          LogNode log)
        A relative path. This is used for paths relative to the current directory (for classpath elements), and also for relative paths within classpath elements (e.g. the files within a ZipFile).
      • ClasspathOrModulePathEntry

        public ClasspathOrModulePathEntry​(ModuleRef moduleRef,
                                          NestedJarHandler nestedJarHandler,
                                          LogNode log)
        A relative path for a module (in JDK9+).
    • Method Detail

      • hashCode

        public int hashCode()
        Hash based on canonical path.
        Overrides:
        hashCode in class Object
      • equals

        public boolean equals​(Object o)
        Return true based on equality of canonical paths.
        Overrides:
        equals in class Object
      • getClassLoaders

        public ClassLoader[] getClassLoaders()
        Get the ClassLoader(s) that should be used to load classes for this classpath element.
      • getResolvedPath

        public String getResolvedPath()
        Get the path of this classpath element, resolved against the parent path.
      • isHttpURL

        public boolean isHttpURL()
        Returns true if the path is an http(s):// URL.
      • isJrtURL

        public boolean isJrtURL()
        Returns true if the path is a jrt:/ URL.
      • getModuleRef

        public ModuleRef getModuleRef()
        Returns the ModuleRef for this module, if this RelativePath corresponds to a module (in JDK9+).
      • getFile

        public File getFile​(LogNode log)
                     throws IOException
        Get the File object for the resolved path.
        Throws:
        IOException - if the path cannot be canonicalized.
      • getJarfilePackageRoot

        public String getJarfilePackageRoot()
        If non-empty, this path represents the package root within a jarfile, e.g. if the path is "spring-project.jar!/BOOT-INF/classes", the package root is "BOOT-INF/classes".
      • getCanonicalPath

        public String getCanonicalPath​(LogNode log)
                                throws IOException
        Gets the canonical path of the File object corresponding to the resolved path.
        Throws:
        IOException
      • isDirectory

        public boolean isDirectory​(LogNode log)
                            throws IOException
        True if this relative path corresponds with a directory.
        Throws:
        IOException
      • isClassfile

        public boolean isClassfile()
        Returns true if resolved path has a .class extension, ignoring case.
      • isValidClasspathElement

        public boolean isValidClasspathElement​(ScanSpec scanSpec,
                                               LogNode log)
                                        throws InterruptedException
        True if this relative path is a valid classpath element: that its path can be canonicalized, that it exists, that it is a jarfile or directory, that it is not a blacklisted jar, that it should be scanned, etc.

        N.B. this has the side effect of fetching any http(s):// URLs, and/or unzipping any inner jarfiles, to determine if these paths are valid. Any resulting temporary files will be cached.

        Throws:
        InterruptedException