Class ClassFileLocator.ForFolder

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, ClassFileLocator
    Enclosing interface:
    ClassFileLocator

    @Enhance
    public static class ClassFileLocator.ForFolder
    extends ClassFileLocator.MultiReleaseAware
    A class file locator that finds files from a standardized Java folder structure with folders donating packages and class files being saved as <classname>.class files within their package folder.
    • Field Detail

      • folder

        private final java.io.File folder
        The base folder of the package structure.
    • Constructor Detail

      • ForFolder

        public ForFolder​(java.io.File folder)
        Creates a new class file locator for a folder structure of class files.
        Parameters:
        folder - The base folder of the package structure.
      • ForFolder

        protected ForFolder​(int[] version,
                            java.io.File folder)
        Creates a new class file locator for a folder structure of class files.
        Parameters:
        version - Contains the existing multi-release jar folders that are available for the current JVM version in decreasing order.
        folder - The base folder of the package structure.
    • Method Detail

      • of

        public static ClassFileLocator of​(java.io.File folder,
                                          ClassFileVersion classFileVersion)
                                   throws java.io.IOException
        Creates a new class file locator for a folder structure of class files. The created locator considers the provided class file version when resolving class files and if multiple versions are available
        Parameters:
        folder - The base folder of the package structure.
        classFileVersion - The class file version to consider for multi-release JAR files.
        Returns:
        An appropriate class file locator.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • doLocate

        @MaybeNull
        protected byte[] doLocate​(java.lang.String path)
                           throws java.io.IOException
        Resolves a possible multi-release entry, if it exists.
        Specified by:
        doLocate in class ClassFileLocator.MultiReleaseAware
        Parameters:
        path - The path of the class file.
        Returns:
        The class file's binary representation or null if it does not exist.
        Throws:
        java.io.IOException - If an I/O exception occurs.
      • close

        public void close()