Class ReflectionUtility


  • public class ReflectionUtility
    extends Object
    A utility class for finding all classes within a given package.

    This implementation is based on the solution provided at Stack Overflow.

    Author:
    Luca Frosini (ISTI - CNR)
    • Constructor Detail

      • ReflectionUtility

        public ReflectionUtility()
    • Method Detail

      • getClassesForPackage

        public static List<Class<?>> getClassesForPackage​(Package packageObject)
                                                   throws ClassNotFoundException
        Attempts to list all the classes in the specified package as determined by the context class loader
        Parameters:
        packageObject - the package to search
        Returns:
        a list of classes that exist within that package
        Throws:
        ClassNotFoundException - if something went wrong
      • getClassesForPackage

        public static List<Class<?>> getClassesForPackage​(String pckgname)
                                                   throws ClassNotFoundException
        Attempts to list all the classes in the specified package as determined by the context class loader
        Parameters:
        pckgname - the package name to search
        Returns:
        a list of classes that exist within that package
        Throws:
        ClassNotFoundException - if something went wrong