title: Kotlin: Generics, reflection and the difference between type T and T:Any
body: <p>If I try to access the javaClass of a generic type T the Kotlin compiler complains that T is not a subtype of kotlin.Any   </p>
  
  <pre><code>class Foo&lt;T&gt; (val t: T ){
      val cls = t.javaClass // Error, T is not a subtype of kotlin.Any
  }
  </code></pre>
  
  <p>If define T as a subtype of Any everything works ok.</p>
  
  <pre><code>class Bar&lt;T:Any&gt; (val t: T ){
      val cls = t.javaClass // OK
  }
  </code></pre>
  
  <p>Q1) If type ´T´ is not a subtype of ´Any´ which class/classes can it be a subtype of ? </p>
  
  <p>Q2) Do a javaClass exist for all instances of T and if so how do I access it ? </p>