title: How can I get all implementations of an interface at runtime in Kotlin
body: <p>I know I can get all subclasses of a <code>sealed class</code> in Kotlin, but I'm looking for a way to get all implementations of an interface. </p>
  
  <p>So instead of ...</p>
  
  <pre><code>sealed class HotDrinkFactory {
      abstract fun prepare(amount: Int): HotDrink
  }
  
  class TeaFactory : HotDrinkFactory() {
      override fun prepare(amount: Int): HotDrink {
          ...
      }
  }
  
  class CoffeeFactory : HotDrinkFactory() {
      override fun prepare(amount: Int): HotDrink {
          ...
      }
  }
  
  fun main(args: Array&lt;String&gt;) {
      val hotDrinkFactories = HotDrinkFactory::class.sealedSubclasses
      hotDrinkFactories.forEach { println(it::class.qualifiedName) }
  }
  </code></pre>
  
  <p>... I would like to have </p>
  
  <pre><code>interface HotDrinkFactory {
      fun prepare(amount: Int): HotDrink
  }
  
  class TeaFactory : HotDrinkFactory {
      override fun prepare(amount: Int): HotDrink {
          ...
      }
  }
  
  class CoffeeFactory : HotDrinkFactory {
      override fun prepare(amount: Int): HotDrink {
          ...
      }
  }
  
  fun main(args: Array&lt;String&gt;) {
      val hotDrinkFactories = HotDrinkFactory::class.&lt;&lt;&lt; Something here? &gt;&gt;&gt;
      hotDrinkFactories.forEach { println(it::class.qualifiedName) }
  }
  </code></pre>