### Question:
ClassUtils { public static void getClassesWithAnnotation(String packageName, Class<? extends Annotation> annotationClass, ClassVisitor visitor) throws ClassLoadingException { LOGGER.trace("Finding classes with annotation: {}, in package: {}", annotationClass, packageName); try { ClassLoader classLoader = getClassLoader(); String packagePath = packageName.replace(DOT, SLASH); Enumeration<URL> resources = classLoader.getResources(packagePath); while (resources.hasMoreElements()) { URL resource = resources.nextElement(); String protocol = resource.getProtocol(); String path = URLDecoder.decode(resource.getPath(), CHARSET); if ("jar".equals(protocol)) { int startIndex = path.startsWith("file:") ? "file:".length() : 0; int endIndex = path.endsWith("jar") ? 0 : path.indexOf("!"); File jarFilePath = new File(path.substring(startIndex, endIndex)); findClassesInJar(jarFilePath, packagePath, annotationClass, visitor); } else if ("file".equals(protocol)) { findClassesInFile(new File(path), packageName, annotationClass, visitor); } else { throw new UnsupportedOperationException("Not supported reading from: " + protocol); } } } catch (IOException e) { throw new ClassLoadingException(e); } }  static void getClassesWithAnnotation(String packageName,
                                              Class<? extends Annotation> annotationClass,
                                              ClassVisitor visitor); static boolean isSimpleValueType(Class<?> clazz); static boolean isPrimitiveOrWrapper(Class<?> clazz); static boolean isPrimitiveWrapper(Class<?> clazz);  }### Answer:
@Test public void testScanDirectory() { try { List<Class<?>> classes = new ArrayList<>(); ClassUtils.getClassesWithAnnotation( "com.orctom.laputa.utils", RunListener.ThreadSafe.class, classes::add ); assertThat(classes.size(), greaterThan(0)); } catch (ClassLoadingException e) { e.printStackTrace(); } }
@Test public void testScanJar() { try { List<Class<?>> classes = new ArrayList<>(); ClassUtils.getClassesWithAnnotation( "org.junit.runner.notification", RunListener.ThreadSafe.class, classes::add ); assertThat(classes.size(), greaterThan(0)); } catch (ClassLoadingException e) { e.printStackTrace(); } }