public static Set<Class<?>> scanPackage(ClassLoader classLoader, String pkg) throws IOException {
        return new ClassGraph()
                .enableClassInfo()
                .acceptPackages(pkg)
                .rejectPackages("com.sun", "com.apple")
                .overrideClassLoaders(classLoader)
                .scan()
                .getAllClasses()
                .stream().map(info -> safeClassForName(classLoader, info.getName()))
                .collect(Collectors.toSet());
    }
Return the classes from the given package and subpackages using the supplied classloader

@param classLoader classloader to be used
@param pkg package to scan
@return set of found classes
@throws IOException
querydsl-codegen/src/main/java/com/querydsl/codegen/ClassPathUtils.java