Class JarfileMetadataReader
- java.lang.Object
-
- io.github.fastclasspathscanner.utils.JarfileMetadataReader
-
public class JarfileMetadataReader extends Object
Fast parser for jar manifest files.
-
-
Field Summary
Fields Modifier and Type Field Description List<String>
classPathEntriesToScan
"Class-Path" entries encountered in the manifest file.boolean
isSystemJar
If true, this is a JRE jar.List<String>
libJarPaths
Any jarfiles found in "lib/", "BOOT-INF/lib", "WEB-INF/lib", or "WEB-INF/lib-provided".static String
MANIFEST_PATH
Set<String>
packageRootRelativePaths
Any jarfile package roots, including anything after "!" in the path to this jar in the classpath, and/or "BOOT-INF/classes" or "WEB-INF/classes", if any files with this directory prefix are contained in the jar.List<ZipEntry>
zipEntries
The ZipEntries for the zipfile.
-
Constructor Summary
Constructors Constructor Description JarfileMetadataReader(File jarFile, LogNode log)
Fast parser for jar manifest files.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLibJarEntry(String libJarPath)
void
addPackageRootPath(String packageRoot)
ClassLoader
getCustomClassLoader(NestedJarHandler nestedJarHandler, LogNode log)
Create a custom URLClassLoader for the package root paths and lib jar entries in this jar.
-
-
-
Field Detail
-
isSystemJar
public boolean isSystemJar
If true, this is a JRE jar.
-
zipEntries
public List<ZipEntry> zipEntries
The ZipEntries for the zipfile. ZipEntries contain only static metadata, so can be reused between different ZipFile instances, even though ZipFile imposes a synchronized lock around each instance.
-
classPathEntriesToScan
public List<String> classPathEntriesToScan
"Class-Path" entries encountered in the manifest file. Also includes any "!BOOT-INF/classes" or "!WEB-INF/classes" package roots. Will also include classpath entries for any jars found in one of the lib directories of the jar ("lib/", "BOOT-INF/lib", "WEB-INF/lib", or "WEB-INF/lib-provided"), ifFastClasspathScanner#addNestedLibJarsToClasspath(true)
is called before scanning.
-
packageRootRelativePaths
public Set<String> packageRootRelativePaths
Any jarfile package roots, including anything after "!" in the path to this jar in the classpath, and/or "BOOT-INF/classes" or "WEB-INF/classes", if any files with this directory prefix are contained in the jar. If classes need to be loaded from this jar, and no classloader can be found to load them, then each of these subdirectories will get unzipped and added to the classpath of a new URLClassLoader.
-
libJarPaths
public List<String> libJarPaths
Any jarfiles found in "lib/", "BOOT-INF/lib", "WEB-INF/lib", or "WEB-INF/lib-provided". If classes need to be loaded from this jar, and no classloader can be found to load them, then each of these subdirectories will get unzipped and added to the classpath of a new URLClassLoader.
-
MANIFEST_PATH
public static final String MANIFEST_PATH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JarfileMetadataReader
public JarfileMetadataReader(File jarFile, LogNode log)
Fast parser for jar manifest files. Doesn't intern strings or create Attribute objects like the Manifest class, so has lower overhead. Only extracts a few specific entries from the manifest file, if present. Assumes there is only one of each entry present in the manifest.
-
-
Method Detail
-
getCustomClassLoader
public ClassLoader getCustomClassLoader(NestedJarHandler nestedJarHandler, LogNode log)
Create a custom URLClassLoader for the package root paths and lib jar entries in this jar. Called when the environment classloaders cannot load a class from this jar. This may result in the unzipping of a large number of lib jarfiles and/or classfiles (contained within the package root). Returns null if there were no valid package roots or lib jars found.
-
addPackageRootPath
public void addPackageRootPath(String packageRoot)
-
addLibJarEntry
public void addLibJarEntry(String libJarPath)
-
-