Class ClassPath


  • @Beta
    public final class ClassPath
    extends 
    Scans the source of a and finds all loadable classes and resources.

    Warning: Current limitations:

    • Looks only for files and JARs in URLs available from instances or the .
    • Only understands file: URLs.

    In the case of directory classloaders, symlinks are supported but cycles are not traversed. This guarantees discovery of each unique loadable resource. However, not all possible aliases for resources on cyclic paths will be listed.

    Since:
    14.0
    Author:
    Ben Yu
    • Method Detail

      • from

        public static  classloader)
                              throws 
        Returns a ClassPath representing all classes and resources loadable from classloader and its ancestor class loaders.

        Warning: ClassPath can find classes and resources only from:

        • instances' file: URLs
        • the . To search the system class loader even when it is not a (as in Java 9), ClassPath searches the files from the java.class.path system property.
        Throws:
        - if the attempt to read class path resources (jar files or directories) failed.
      • getResources

        public ImmutableSet<ClassPath.ResourceInfogetResources()
        Returns all resources loadable from the current class path, including the class files of all loadable classes but excluding the "META-INF/MANIFEST.MF" file.
      • getTopLevelClasses

        public  packageName)
        Returns all top level classes whose package name is packageName.
      • getTopLevelClassesRecursive

        public  packageName)
        Returns all top level classes whose package name is packageName or starts with packageName followed by a '.'.