title: java: comparing classes with == or .equals(): is there a difference?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3738919/does-java-guarantee-that-object-getclass-object-getclass">Does Java guarantee that Object.getClass() == Object.getClass()?</a>  </p>
  </blockquote>
  
  
  
  <p>I know you're supposed to use <code>equals()</code> in general, but is there any way two <code>Class&lt;?&gt;</code> objects could be equal with <code>equals()</code> but not equal with <code>==</code>?</p>
  
  <p>edit: I am specifically looking to find out whether two class objects exist such that</p>
  
  <pre><code>Class&lt;?&gt; cl1 = ...
  Class&lt;?&gt; cl2 = ...
  cl1.equals(cl2)    -&gt;  true
  cl1 == cl2         -&gt;  false
  </code></pre>
  
  <p>This does <em>not</em> seemed to be covered by the possible duplicate question. (which is closely related)</p>
  
  <p>Also it may <em>not</em> be true that the class objects were obtained by <code>someObject.getClass()</code> -- it could be that one was the result of <code>Class.forName(...)</code> and the other from some series of reflective actions like <a href="http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Method.html#getReturnType%28%29" rel="noreferrer"><code>Method.getReturnType()</code></a>.</p>