@SuppressWarnings("unchecked")
   private static <E> Class<E>[] getClasses(String packageName)
         throws ClassNotFoundException, IOException, URISyntaxException {
      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      assert classLoader != null;
      String path = packageName.replace('.', '/');
      Enumeration<URL> resources = classLoader.getResources(path);
      List<File> dirs = new ArrayList<File>();
      while (resources.hasMoreElements()) {
         URL resource = resources.nextElement();
         dirs.add(new File(resource.toURI()));
      }
      ArrayList<Class<E>> classes = new ArrayList<Class<E>>();
      for (File directory : dirs) {
         classes.addAll(TestRig.<E>findClasses(directory, packageName));
      }
      return classes.toArray((Class<E>[])new Class[classes.size()]);
   }