title: can't cast to implemented interface
body: <p>i'm very confused...</p>
  
  <p>I have a class which directly implements an interface:</p>
  
  <pre><code>public class Device implements AutocompleteResult
  {...}
  </code></pre>
  
  <p>Here is proof that I'm looking at the right variables:</p>
  
  <pre><code>Object match = ...;
  log.debug(match.getClass()); // Outputs 'Device'
  log.debug(match.getClass().getInterfaces()[0]); // Outputs 'AutocompleteResult'
  </code></pre>
  
  <p>Yet when I try to cast an instance of the class to the interface:</p>
  
  <pre><code>AutocompleteResult result = (AutocompleteResult) match;
  </code></pre>
  
  <p>I get a ClassCastException!</p>
  
  <pre><code>ClassCastException: Device cannot be cast to AutocompleteResult
  </code></pre>
  
  <p>Also, <code>isAssignableFrom</code> returns false and i'm not sure why:</p>
  
  <pre><code>log.debug(AutocompleteResult.class.isAssignableFrom(Device.class));
  </code></pre>
  
  <p>from the <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Class.html#isAssignableFrom%28java.lang.Class%29">doc</a>:</p>
  
  <blockquote>
    <p><strong>Determines if the</strong> class or <strong>interface represented by this Class object is</strong> either the same as, or is a superclass or <strong>superinterface of, the class or interface represented by the specified Class parameter.</strong></p>
  </blockquote>
  
  <p>Shouldn't I always be able to cast a object to an interface its class implements?</p>
  
  <p>Thanks.</p>