code: public static <S> List<Class<? extends S>> load(Class<S> service,
              ClassLoader loader) {
          if (loader == null) {
              loader = Thread.currentThread().getContextClassLoader();
          }
          List<Class<? extends S>> services = new ArrayList<>();
          try {
              Enumeration<URL> e = loader.getResources("META-INF/services/"
                      + service.getName());
  
              while (e.hasMoreElements()) {
                  URL url = e.nextElement();
                  InputStream is = url.openStream();
                  String name = null;
                  try {
                      BufferedReader r = new BufferedReader(
                              new InputStreamReader(is, "UTF-8"));
                      while (true) {
                          String line = r.readLine();
                          if (line == null) {
                              break;
                          }
                          int comment = line.indexOf('#');
                          if (comment >= 0) {
                              line = line.substring(0, comment);
                          }
                          name = line.trim();
                          if (name.length() == 0) {
                              continue;
                          }
                          Class<?> clz = Class.forName(name, true, loader);
                          Class<? extends S> impl = clz.asSubclass(service);
  
                          services.add(impl);
                      }
                  } catch (ClassNotFoundException cnfe) {
                      throw new ServiceConfigurationError("Could not load class for service provider " + name, cnfe);
                  } finally {
                      is.close();
                  }
              }
          } catch (IOException ioe) {
              /**
               * {@link java.util.ServiceLoader} swallows this exception, so
               * will we.
               */
          }
          return services;
      }
docs: Loads the classes of the providers of a service.
  
  @param service a service type. If <code>null</code>, a
  {@link NullPointerException} will be thrown.
  @param loader a class loader. If <code>null</code>, the current thread's
  context class loader will be used.
  @return a list of classes implementing the given service type and
  class loader.
  
  @throws ServiceConfigurationError if something goes wrong with loading
  a service provider's class.