title: instance::class.java vs. instance.javaClass
body: <p>Given Kotlin 1.1. For an <code>instance</code> of some class, <code>instance::class.java</code> and <code>instance.javaClass</code> seem to be nearly equivalent:</p>
  
  <pre><code>val i = 0
  println(i::class.java) // int
  println(i.javaClass) // int
  println(i::class.java === i.javaClass) // true
  </code></pre>
  
  <p>There is a subtle difference, however:</p>
  
  <pre><code>val c1: Class&lt;out Int&gt; = i::class.java
  val c2: Class&lt;Int&gt; = i.javaClass
  </code></pre>
  
  <p><code>instance.javaClass</code> is negligibly shorter, but <code>instance::class.java</code> is more consistent with the corresponding usage on a type. While you can use <code>.javaClass</code> on some types, the result may not be what you would expect:</p>
  
  <pre><code>println(i::class.java === Int::class.java) // true
  println(i.javaClass === Int.javaClass) // false
  println(Int::class.java === Int.javaClass) // false
  println(Int.javaClass) // class kotlin.jvm.internal.IntCompanionObject
  </code></pre>
  
  <p>So, I would argue that it is better to never use <code>.javaClass</code> for more consistency. Are there any arguments against that?</p>