Class ClasspathElementZip

java.lang.Object
io.github.classgraph.ClasspathElement
io.github.classgraph.ClasspathElementZip
All Implemented Interfaces:
Comparable<ClasspathElement>

class ClasspathElementZip extends ClasspathElement
A zip/jarfile classpath element.
  • Field Details

    • rawPath

      private final String rawPath
      The String representation of the path string, URL, URI, or Path for this zipfile.
    • logicalZipFile

      LogicalZipFile logicalZipFile
      The logical zipfile for this classpath element.
    • zipFilePath

      private String zipFilePath
      The normalized path of the jarfile, "!/"-separated if nested, excluding any package root.
    • relativePathToResource

      private final ConcurrentHashMap<String,Resource> relativePathToResource
      A map from relative path to Resource for non-rejected zip entries.
    • strippedAutomaticPackageRootPrefixes

      private final Set<String> strippedAutomaticPackageRootPrefixes
      A list of all automatic package root prefixes found as prefixes of paths within this zipfile.
    • nestedJarHandler

      private final NestedJarHandler nestedJarHandler
      The nested jar handler.
    • moduleNameFromManifestFile

      String moduleNameFromManifestFile
      The name of the module from the Automatic-Module-Name manifest attribute, if one is present in the root of the classpath element.
    • derivedAutomaticModuleName

      private String derivedAutomaticModuleName
      The automatic module name, derived from the jarfile filename.
  • Constructor Details

    • ClasspathElementZip

      ClasspathElementZip(Scanner.ClasspathEntryWorkUnit workUnit, NestedJarHandler nestedJarHandler, ScanSpec scanSpec)
      A jarfile classpath element.
      Parameters:
      workUnit - the work unit
      nestedJarHandler - the nested jar handler
      scanSpec - the scan spec
  • Method Details

    • open

      Description copied from class: ClasspathElement
      Determine if this classpath element is valid. If it is not valid, sets skipClasspathElement. For ClasspathElementZip, may also open or extract inner jars, and also causes jarfile manifests to be read to look for Class-Path entries. If nested jars or Class-Path entries are found, they are added to the work queue. This method is only run once per classpath element, from a single thread.
      Specified by:
      open in class ClasspathElement
      Parameters:
      workQueue - the work queue
      log - the log
      Throws:
      InterruptedException - if the thread was interrupted while trying to open the classpath element.
    • newResource

      private Resource newResource(FastZipEntry zipEntry, String pathRelativeToPackageRoot)
      Create a new Resource object for a resource or classfile discovered while scanning paths.
      Parameters:
      zipEntry - the zip entry
      pathRelativeToPackageRoot - the path relative to package root
      Returns:
      the resource
    • getResource

      Resource getResource(String relativePath)
      Get the Resource for a given relative path.
      Specified by:
      getResource in class ClasspathElement
      Parameters:
      relativePath - The relative path of the Resource to return.
      Returns:
      The Resource for the given relative path, or null if relativePath does not exist in this classpath element.
    • scanPaths

      void scanPaths(LogNode log)
      Scan for path matches within jarfile, and record ZipEntry objects of matching files.
      Specified by:
      scanPaths in class ClasspathElement
      Parameters:
      log - the log
    • getModuleName

      public String getModuleName()
      Get module name from module descriptor, or get the automatic module name from the manifest file, or derive an automatic module name from the jar name.
      Specified by:
      getModuleName in class ClasspathElement
      Returns:
      the module name
    • getZipFilePath

      String getZipFilePath()
      Get the zipfile path.
      Returns:
      the path of the zipfile, including any package root.
    • getURI

      URI getURI()
      Description copied from class: ClasspathElement
      Get the URI for this classpath element.
      Specified by:
      getURI in class ClasspathElement
      Returns:
      the URI for the classpath element.
    • getAllURIs

      List<URI> getAllURIs()
      Return URI for classpath element, plus URIs for any stripped nested automatic package root prefixes, e.g. "!/BOOT-INF/classes".
      Specified by:
      getAllURIs in class ClasspathElement
      Returns:
      the URI for the classpath element.
    • getFile

      File getFile()
      Get the File for the outermost zipfile of this classpath element.
      Specified by:
      getFile in class ClasspathElement
      Returns:
      The File for the outermost zipfile of this classpath element, or null if this file was downloaded from a URL directly to RAM, or if the classpath element was backed by a custom filesystem that supports the Path API put not the File API.
    • toString

      public String toString()
      Return the classpath element path.
      Overrides:
      toString in class Object
      Returns:
      the string
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object