code: public static List<Class<?>> getClasses(String packageName) throws IOException, ClassNotFoundException {
          List<Class<?>> classes = new ArrayList<>();
          String packageDirName = packageName.replace('.', '/');
          Enumeration<URL> dirs = Thread.currentThread().getContextClassLoader().getResources(packageDirName);
          while (dirs.hasMoreElements()) {
              URL url = dirs.nextElement();
              String protocol = url.getProtocol();
              if ("file".equals(protocol)) {
                  String filePath = URLDecoder.decode(url.getFile(), "UTF-8");
                  addClassesInPackageByFile(packageName, filePath, classes);
              } else if ("jar".equals(protocol)) {
                  JarFile jar = ((JarURLConnection) url.openConnection()).getJarFile();
                  Enumeration<JarEntry> entries = jar.entries();
                  while (entries.hasMoreElements()) {
                      JarEntry entry = entries.nextElement();
                      String name = entry.getName();
                      if (name.charAt(0) == '/') {
                          name = name.substring(1);
                      }
                      if (name.startsWith(packageDirName)) {
                          int idx = name.lastIndexOf('/');
                          if (idx != -1) {
                              packageName = name.substring(0, idx).replace('/', '.');
                          }
                          if (name.endsWith(".class") && !entry.isDirectory()) {
                              String className = name.substring(packageName.length() + 1, name.length() - 6);
                              classes.add(Class.forName(packageName + '.' + className));
                          }
                      }
                  }
              }
          }
          return classes;
      }
docs: 从包中获取所有的类
  
  @param packageName 包名
  
  @return {@link List}
  
  @throws IOException 异常
  @throws ClassNotFoundException 异常