@HashCodeAndEqualsPlugin.Enhance public static class ClassFileLocator.ForJarFile extends java.lang.Object implements ClassFileLocator
ClassFileLocator.AgentBased, ClassFileLocator.Compound, ClassFileLocator.ForClassLoader, ClassFileLocator.ForFolder, ClassFileLocator.ForJarFile, ClassFileLocator.ForModule, ClassFileLocator.ForModuleFile, ClassFileLocator.ForUrl, ClassFileLocator.NoOp, ClassFileLocator.PackageDiscriminating, ClassFileLocator.Resolution, ClassFileLocator.Simple
Modifier and Type | Field and Description |
---|---|
private java.util.jar.JarFile |
jarFile
The jar file to read from.
|
private static java.util.List<java.lang.String> |
RUNTIME_LOCATIONS
A list of potential locations of the runtime jar for different platforms.
|
CLASS_FILE_EXTENSION
Constructor and Description |
---|
ForJarFile(java.util.jar.JarFile jarFile)
Creates a new class file locator for the given jar file.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
ClassFileLocator.Resolution |
locate(java.lang.String name)
Locates the class file for a given type and returns the binary data of the class file.
|
static ClassFileLocator |
of(java.io.File file)
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(java.lang.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.
|
private static final java.util.List<java.lang.String> RUNTIME_LOCATIONS
private final java.util.jar.JarFile jarFile
public ForJarFile(java.util.jar.JarFile jarFile)
jarFile
- The jar file to read from.public static ClassFileLocator of(java.io.File file) throws java.io.IOException
file
- The jar file to read from.java.io.IOException
- If an I/O exception is thrown.public static ClassFileLocator ofClassPath() throws java.io.IOException
java.io.IOException
- If an I/O exception occurs.public static ClassFileLocator ofClassPath(java.lang.String classPath) throws java.io.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
.java.io.IOException
- If an I/O exception occurs.public static ClassFileLocator ofRuntimeJar() throws java.io.IOException
java.io.IOException
- If an I/O exception occurs.public ClassFileLocator.Resolution locate(java.lang.String name) throws java.io.IOException
locate
in interface ClassFileLocator
name
- The name of the type to locate a class file representation for.java.io.IOException
- If reading a class file causes an error.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException