@HashCodeAndEqualsPlugin.Enhance public static class ClassFileLocator.ForJarFile extends ClassFileLocator.MultiReleaseAware
ClassFileLocator.Compound, ClassFileLocator.Filtering, ClassFileLocator.ForClassLoader, ClassFileLocator.ForFolder, ClassFileLocator.ForInstrumentation, ClassFileLocator.ForJarFile, ClassFileLocator.ForModule, ClassFileLocator.ForModuleFile, ClassFileLocator.ForUrl, ClassFileLocator.MultiReleaseAware, ClassFileLocator.NoOp, ClassFileLocator.PackageDiscriminating, ClassFileLocator.Resolution, ClassFileLocator.Simple
NO_MULTI_RELEASE
CLASS_FILE_EXTENSION, META_INF_VERSIONS
Modifier | Constructor and Description |
---|---|
protected |
ForJarFile(int[] version,
JarFile jarFile,
boolean close)
Creates a new class file locator for the given jar file.
|
|
ForJarFile(JarFile jarFile)
Creates a new class file locator for the given jar file.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected byte[] |
doLocate(String path)
Resolves a possible multi-release entry, if it exists.
|
static ClassFileLocator |
of(File file)
Creates a new class file locator for the given jar file.
|
static ClassFileLocator |
of(File file,
ClassFileVersion classFileVersion)
Creates a new class file locator for the given jar file.
|
static ClassFileLocator |
of(JarFile jarFile,
ClassFileVersion classFileVersion)
Creates a new class file locator for the given jar file.
|
static ClassFileLocator |
ofClassPath()
Resolves a class file locator for the class path that reads class files directly from the file system.
|
static ClassFileLocator |
ofClassPath(String classPath)
Resolves a class file locator for the class path that reads class files directly from the file system.
|
static ClassFileLocator |
ofRuntimeJar()
Resolves a class file locator for the runtime jar.
|
locate
public ForJarFile(JarFile jarFile)
jarFile
- The jar file to read from.protected ForJarFile(int[] version, JarFile jarFile, boolean close)
version
- Contains the existing multi-release jar folders that are available for the
current JVM version in decreasing order.jarFile
- The jar file to read from.close
- Indicates if the jar file should be closed upon closing this class file locator.public static ClassFileLocator of(File file) throws IOException
file
- The jar file to read from.IOException
- If an I/O exception is thrown.public static ClassFileLocator of(File file, ClassFileVersion classFileVersion) throws IOException
file
- The jar file to read from.classFileVersion
- The class file version to consider when resolving class files in multi-release jars.IOException
- If an I/O exception is thrown.public static ClassFileLocator of(JarFile jarFile, ClassFileVersion classFileVersion) throws IOException
jarFile
- The jar file to read from.classFileVersion
- The class file version to consider when resolving class files in multi-release jars.IOException
- If an I/O exception is thrown.public static ClassFileLocator ofClassPath() throws IOException
IOException
- If an I/O exception occurs.public static ClassFileLocator ofClassPath(String classPath) throws IOException
Resolves a class file locator for the class path that reads class files directly from the file system.
Note: The resulting class file locator does not include classes of the bootstrap class loader.
classPath
- The class path to scan with the elements separated by path.separator
.IOException
- If an I/O exception occurs.public static ClassFileLocator ofRuntimeJar() throws IOException
IOException
- If an I/O exception occurs.@MaybeNull protected byte[] doLocate(String path) throws IOException
doLocate
in class ClassFileLocator.MultiReleaseAware
path
- The path of the class file.null
if it does not exist.IOException
- If an I/O exception occurs.public void close() throws IOException
IOException
Copyright © 2014–2025. All rights reserved.