ClassCastException upon casting object to its own type
<p>I got a <code>ClassCastException</code> upon casting an object of type Node to a DatanodeDescriptor.
When I examine the object in the debugger it is of type DatanodeDescriptor and contains valid data. What could be the problem?</p>

<pre><code>Node n = null;
...
...
n = innerNode.getLeaf(index, null);
DatanodeDescriptor d = (DatanodeDescriptor)n;
</code></pre>

<p>EDIT: I added a line to check</p>

<pre><code>if (n instanceof DatanodeDescriptor)System.out.println("It is")
</code></pre>

<p>and it printed successfully before it gave the exception</p>
