public List<Class<?>> findAllImplementations(Class<?> interfase) throws IOException, ClassNotFoundException {
  List<Class<?>> implementations=new ArrayList<>();
  List<String> strings=findAllStrings(interfase.getName());
  for (  String className : strings) {
    Class<?> impl=_classLoader.loadClass(className);
    if (!interfase.isAssignableFrom(impl)) {
      throw new ClassCastException("Class not of type: " + interfase.getName());
    }
    implementations.add(impl);
  }
  return implementations;
}

public List < Class < ? > > findAllImplementations ( Class < ? > interfase ) throws IOException , ClassNotFoundException { List < Class < ? > > implementations = new ArrayList < > ( ) ; List < String > strings = findAllStrings ( interfase . getName ( ) ) ; for ( String className : strings ) { Class < ? > impl = _classLoader . loadClass ( className ) ; if ( ! interfase . isAssignableFrom ( impl ) ) { throw new ClassCastException ( "Class not of type: " + interfase . getName ( ) ) ; } implementations . add ( impl ) ; } 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 assigned to the specified interface will be cause an exception to be thrown . < 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
