Skip to content

Instantly share code, notes, and snippets.

@saksmt
Created October 1, 2014 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saksmt/baebd25deca65a792aee to your computer and use it in GitHub Desktop.
Save saksmt/baebd25deca65a792aee to your computer and use it in GitHub Desktop.
Java: get all implementations of interface
interface Interface {}
class InterfaceImpl1 implements Interface {}
class InterfaceImpl2 implements Interface {}
class Main {
private static List<Class<? extends Interface>> interfaceImplementations;
static {
interfaceImplementations = new ArrayList(Interface.class.getClasses()); // <- Doesn't work :(
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment