Package net.bytebuddy.dynamic
Class ClassFileLocator.ForModuleFile
- java.lang.Object
-
- net.bytebuddy.dynamic.ClassFileLocator.ForModuleFile
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,ClassFileLocator
- Enclosing interface:
- ClassFileLocator
@Enhance public static class ClassFileLocator.ForModuleFile extends java.lang.Object implements ClassFileLocator
A class file locator that locates classes within a Java jmod file. This class file locator should not be used for reading modular jar files for whichClassFileLocator.ForJarFile
is appropriate.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.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
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<java.lang.String>
BOOT_LOCATIONS
A list of potential locations of the boot path for different platforms.private static java.lang.String
JMOD_FILE_EXTENSION
The file extension of a modular Java package.private java.util.zip.ZipFile
zipFile
The represented jmod file.-
Fields inherited from interface net.bytebuddy.dynamic.ClassFileLocator
CLASS_FILE_EXTENSION
-
-
Constructor Summary
Constructors Constructor Description ForModuleFile(java.util.zip.ZipFile zipFile)
Creates a new class file locator for a jmod file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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)
Returns a class file locator for the given module file.static ClassFileLocator
ofBootPath()
Creates a new class file locator for this VM's boot module path.static ClassFileLocator
ofBootPath(java.io.File bootPath)
Creates a new class file locator for a Java boot module path.static ClassFileLocator
ofModulePath()
Resolves a class file locator for this VM's Java module path that reads class files directly from the file system.static ClassFileLocator
ofModulePath(java.lang.String modulePath)
Resolves a class file locator for a Java module path that reads class files directly from the file system.static ClassFileLocator
ofModulePath(java.lang.String modulePath, java.lang.String baseFolder)
Resolves a class file locator for a Java module path that reads class files directly from the file system.
-
-
-
Field Detail
-
JMOD_FILE_EXTENSION
private static final java.lang.String JMOD_FILE_EXTENSION
The file extension of a modular Java package.- See Also:
- Constant Field Values
-
BOOT_LOCATIONS
private static final java.util.List<java.lang.String> BOOT_LOCATIONS
A list of potential locations of the boot path for different platforms.
-
zipFile
private final java.util.zip.ZipFile zipFile
The represented jmod file.
-
-
Method Detail
-
ofBootPath
public static ClassFileLocator ofBootPath() throws java.io.IOException
Creates a new class file locator for this VM's boot module path.- Returns:
- A class file locator for this VM's boot module path.
- Throws:
java.io.IOException
- If an I/O error occurs.
-
ofBootPath
public static ClassFileLocator ofBootPath(java.io.File bootPath) throws java.io.IOException
Creates a new class file locator for a Java boot module path.- Parameters:
bootPath
- The boot path folder.- Returns:
- A class file locator for this VMs boot module path.
- Throws:
java.io.IOException
- If an I/O error occurs.
-
ofModulePath
public static ClassFileLocator ofModulePath() throws java.io.IOException
Resolves a class file locator for this VM's Java module 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.
- Returns:
- A class file locator for the class path.
- Throws:
java.io.IOException
- If an I/O exception occurs.
-
ofModulePath
public static ClassFileLocator ofModulePath(java.lang.String modulePath) throws java.io.IOException
Resolves a class file locator for a Java module path that reads class files directly from the file system. All elements of the module path are resolved relative to this VM's
user.dir
.Note: The resulting class file locator does not include classes of the bootstrap class loader.
- Parameters:
modulePath
- The module path to scan with the elements separated bypath.separator
.- Returns:
- A class file locator for the class path.
- Throws:
java.io.IOException
- If an I/O exception occurs.
-
ofModulePath
public static ClassFileLocator ofModulePath(java.lang.String modulePath, java.lang.String baseFolder) throws java.io.IOException
Resolves a class file locator for a Java module 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.
- Parameters:
modulePath
- The module path to scan with the elements separated bypath.separator
.baseFolder
- The relative location of the elements on the module path.- Returns:
- A class file locator for the class path.
- Throws:
java.io.IOException
- If an I/O exception occurs.
-
of
public static ClassFileLocator of(java.io.File file) throws java.io.IOException
Returns a class file locator for the given module file.- Parameters:
file
- The module file.- Returns:
- A class file locator for the given module
- Throws:
java.io.IOException
- If an I/O error occurs.
-
locate
public ClassFileLocator.Resolution locate(java.lang.String name) throws java.io.IOException
Locates the class file for a given type and returns the binary data of the class file.- Specified by:
locate
in interfaceClassFileLocator
- Parameters:
name
- The name of the type to locate a class file representation for.- Returns:
- Any binary representation of the type which might be illegal.
- Throws:
java.io.IOException
- If reading a class file causes an error.
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-