code: private <T> Set<Class<? extends T>> load(Class<T> serviceClass) {
          String serviceFile = SERVICES + "/" + serviceClass.getName();
  
          LinkedHashSet<Class<? extends T>> providers = new LinkedHashSet<Class<? extends T>>();
  
          try {
              Enumeration<URL> enumeration = classLoader.getResources(serviceFile);
              while (enumeration.hasMoreElements()) {
                  final URL url = enumeration.nextElement();
                  final InputStream is = url.openStream();
                  BufferedReader reader = null;
  
                  try {
                      reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
                      String line = reader.readLine();
                      while (null != line) {
                          line = skipCommentAndTrim(line);
  
                          if (line.length() > 0) {
                              try {
                                  Class<? extends T> provider = classLoader.loadClass(line).asSubclass(serviceClass);
                                  providers.add(provider);
                              } catch (ClassCastException e) {
                                  ClassLoader other = serviceClass.getClassLoader();
                                  if (!classLoader.getClass().equals(serviceClass.getClassLoader())) {
                                      throw new IllegalStateException("Service " + line
                                          + " was loaded by different classloader (" + (other == null ? "bootstrap"
                                              : other.getClass().getName()) + ") then service interface "
                                          + serviceClass.getName() + " (" + classLoader.getClass().getName()
                                          + "), unable to cast classes");
                                  }
                                  throw new IllegalStateException("Service " + line + " does not implement expected type "
                                      + serviceClass.getName());
                              }
                          }
                          line = reader.readLine();
                      }
                  } finally {
                      if (reader != null) {
                          reader.close();
                      }
                  }
              }
          } catch (Exception e) {
              throw new RuntimeException("Could not load services for " + serviceClass.getName(), e);
          }
          return providers;
      }
docs: -------------------------------------------------------------------------------------||