Class ClassFileLocator.ForModuleFile

java.lang.Object
net.bytebuddy.dynamic.ClassFileLocator.ForModuleFile
All Implemented Interfaces:
Closeable, AutoCloseable, ClassFileLocator
Enclosing interface:
ClassFileLocator

@Enhance public static class ClassFileLocator.ForModuleFile extends 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 which ClassFileLocator.ForJarFile is appropriate.
  • Field Details

    • JMOD_FILE_EXTENSION

      private static final String JMOD_FILE_EXTENSION
      The file extension of a modular Java package.
      See Also:
    • BOOT_LOCATIONS

      private static final List<String> BOOT_LOCATIONS
      A list of potential locations of the boot path for different platforms.
    • zipFile

      private final ZipFile zipFile
      The represented jmod file.
  • Constructor Details

    • ForModuleFile

      public ForModuleFile(ZipFile zipFile)
      Creates a new class file locator for a jmod file.
      Parameters:
      zipFile - The represented jmod file.
  • Method Details

    • ofBootPath

      public static ClassFileLocator ofBootPath() throws 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:
      IOException - If an I/O error occurs.
    • ofBootPath

      public static ClassFileLocator ofBootPath(File bootPath) throws 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:
      IOException - If an I/O error occurs.
    • ofModulePath

      public static ClassFileLocator ofModulePath() throws 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:
      IOException - If an I/O exception occurs.
    • ofModulePath

      public static ClassFileLocator ofModulePath(String modulePath) throws 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 by path.separator.
      Returns:
      A class file locator for the class path.
      Throws:
      IOException - If an I/O exception occurs.
    • ofModulePath

      public static ClassFileLocator ofModulePath(String modulePath, String baseFolder) throws 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 by path.separator.
      baseFolder - The relative location of the elements on the module path.
      Returns:
      A class file locator for the class path.
      Throws:
      IOException - If an I/O exception occurs.
    • of

      public static ClassFileLocator of(File file) throws 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:
      IOException - If an I/O error occurs.
    • locate

      public ClassFileLocator.Resolution locate(String name) throws IOException
      Locates the class file for a given type and returns the binary data of the class file.
      Specified by:
      locate in interface ClassFileLocator
      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:
      IOException - If reading a class file causes an error.
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException