public List<Class<?>> findAvailableImplementations(Class<?> interfase) throws IOException {
  _resourcesNotLoaded.clear();
  List<Class<?>> implementations=new ArrayList<>();
  List<String> strings=findAvailableStrings(interfase.getName());
  for (  String className : strings) {
    try {
      Class<?> impl=_classLoader.loadClass(className);
      if (interfase.isAssignableFrom(impl)) {
        implementations.add(impl);
      }
 else {
        _resourcesNotLoaded.add(className);
      }
    }
 catch (    Exception notAvailable) {
      _resourcesNotLoaded.add(className);
    }
  }
  return implementations;
}

public List < Class < ? > > findAvailableImplementations ( Class < ? > interfase ) throws IOException { _resourcesNotLoaded . clear ( ) ; List < Class < ? > > implementations = new ArrayList < > ( ) ; List < String > strings = findAvailableStrings ( interfase . getName ( ) ) ; for ( String className : strings ) { try { Class < ? > impl = _classLoader . loadClass ( className ) ; if ( interfase . isAssignableFrom ( impl ) ) { implementations . add ( impl ) ; } else { _resourcesNotLoaded . add ( className ) ; } } catch ( Exception notAvailable ) { _resourcesNotLoaded . add ( className ) ; } } return implementations ; }
assumes the class specified points to a file in the classpath that contains the name of a class that implements or is a subclass of the specfied class . < p / > any class that cannot be loaded or are not assignable to the specified class will be skipped and placed in the ' resourcesnotloaded ' collection . < p / > example classpath : < p / > meta - inf / java . io . inputstream # contains the classname org . acme . acmeinputstream meta - inf / java . io . inputstream # contains the classname org . widget . neatoinputstream meta - inf / java . io . inputstream # contains the classname com . foo . barinputstream < p / > resourcefinder finder = new resourcefinder ( " meta - inf / " ) ; list classes = finder . findallimplementations ( java . io . inputstream . class ) ; classes . contains ( " org . acme . acmeinputstream " ) ; / / true classes . contains ( " org . widget . neatoinputstream " ) ; / / true classes . contains ( " com . foo . barinputstream " ) ; / / true
