Package io.github.classgraph
Class ClasspathElementZip
java.lang.Object
io.github.classgraph.ClasspathElement
io.github.classgraph.ClasspathElementZip
- All Implemented Interfaces:
Comparable<ClasspathElement>
A zip/jarfile classpath element.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
The automatic module name, derived from the jarfile filename.(package private) LogicalZipFile
The logical zipfile for this classpath element.(package private) String
The name of the module from theAutomatic-Module-Name
manifest attribute, if one is present in the root of the classpath element.private final NestedJarHandler
The nested jar handler.private final String
private final ConcurrentHashMap
<String, Resource> A map from relative path toResource
for non-rejected zip entries.A list of all automatic package root prefixes found as prefixes of paths within this zipfile.private String
The normalized path of the jarfile, "!/"-separated if nested, excluding any package root.Fields inherited from class io.github.classgraph.ClasspathElement
acceptedClassfileResources, acceptedResources, childClasspathElements, classLoader, classpathElementIdx, classpathElementIdxWithinParent, containsSpecificallyAcceptedClasspathElementResourcePath, fileToLastModified, moduleNameFromModuleDescriptor, nestedClasspathRootPrefixes, packageRootPrefix, scanned, scanSpec, skipClasspathElement
-
Constructor Summary
ConstructorsConstructorDescriptionClasspathElementZip
(Scanner.ClasspathEntryWorkUnit workUnit, NestedJarHandler nestedJarHandler, ScanSpec scanSpec) A jarfile classpath element. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Return URI for classpath element, plus URIs for any stripped nested automatic package root prefixes, e.g.(package private) File
getFile()
Get theFile
for the outermost zipfile of this classpath element.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.(package private) Resource
getResource
(String relativePath) Get theResource
for a given relative path.(package private) URI
getURI()
Get the URI for this classpath element.(package private) String
Get the zipfile path.int
hashCode()
private Resource
newResource
(FastZipEntry zipEntry, String pathRelativeToPackageRoot) Create a newResource
object for a resource or classfile discovered while scanning paths.(package private) void
open
(WorkQueue<Scanner.ClasspathEntryWorkUnit> workQueue, LogNode log) Determine if this classpath element is valid.(package private) void
Scan for path matches within jarfile, and record ZipEntry objects of matching files.toString()
Return the classpath element path.Methods inherited from class io.github.classgraph.ClasspathElement
addAcceptedResource, checkResourcePathAcceptReject, compareTo, finishScanPaths, getClassLoader, getNumClassfileMatches, log, log, maskClassfiles
-
Field Details
-
rawPath
-
logicalZipFile
LogicalZipFile logicalZipFileThe logical zipfile for this classpath element. -
zipFilePath
The normalized path of the jarfile, "!/"-separated if nested, excluding any package root. -
relativePathToResource
A map from relative path toResource
for non-rejected zip entries. -
strippedAutomaticPackageRootPrefixes
A list of all automatic package root prefixes found as prefixes of paths within this zipfile. -
nestedJarHandler
The nested jar handler. -
moduleNameFromManifestFile
String moduleNameFromManifestFileThe name of the module from theAutomatic-Module-Name
manifest attribute, if one is present in the root of the classpath element. -
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 unitnestedJarHandler
- the nested jar handlerscanSpec
- the scan spec
-
-
Method Details
-
open
void open(WorkQueue<Scanner.ClasspathEntryWorkUnit> workQueue, LogNode log) throws InterruptedException Description copied from class:ClasspathElement
Determine if this classpath element is valid. If it is not valid, sets skipClasspathElement. ForClasspathElementZip
, 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 classClasspathElement
- Parameters:
workQueue
- the work queuelog
- the log- Throws:
InterruptedException
- if the thread was interrupted while trying to open the classpath element.
-
newResource
Create a newResource
object for a resource or classfile discovered while scanning paths.- Parameters:
zipEntry
- the zip entrypathRelativeToPackageRoot
- the path relative to package root- Returns:
- the resource
-
getResource
Get theResource
for a given relative path.- Specified by:
getResource
in classClasspathElement
- Parameters:
relativePath
- The relative path of theResource
to return.- Returns:
- The
Resource
for the given relative path, or null if relativePath does not exist in this classpath element.
-
scanPaths
Scan for path matches within jarfile, and record ZipEntry objects of matching files.- Specified by:
scanPaths
in classClasspathElement
- Parameters:
log
- the log
-
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 classClasspathElement
- 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 classClasspathElement
- Returns:
- the URI for the classpath element.
-
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 classClasspathElement
- Returns:
- the URI for the classpath element.
-
getFile
File getFile()Get theFile
for the outermost zipfile of this classpath element.- Specified by:
getFile
in classClasspathElement
- 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 thePath
API put not theFile
API.
-
toString
Return the classpath element path. -
equals
-
hashCode
public int hashCode()
-