Let's say you have a reference to an object in memory, but the reference type is something like <CODE>java.lang.Object</CODE>. Not real useful if you want specific behavior from the actual thing in memory: let's say it's really a <CODE>java.awt.Button</CODE> object).
So you'd normally just run something like: <CODE>Button btn = (Button)objThing;</CODE> to get a Button reference back.
Now: let's say that all you know about objThing is that it's a subclass of <CODE>java.awt.Component</CODE>. You'd like to figure out what class it specifically belongs to at runtime, then apply that knowledge "dynamically" to perform the downcast. In other words, you want to replace the casting directive <CODE>(Button)</CODE> above with the more general instruction (cast to whatever subclass we found).
We can get the information at runtime; that's no problem. What we can't do is use it inside a casting operator; there's no provision for it. I haven't gone looking for the technical justification in print, but I can imagine it. In short, the type safety Java wants to enforce would be jeopardized by allowing the programmer to declare "no particular type at the moment" in a downcast operation. Actually, the compiler wouldn't stand for it.
You can simulate the effect, but it's not trivial to do so. Furthermore, in order to make it work, you still have to agree somewhere at compile-time on a common type. Fully dynamic downcasting isn't possible under those circumstances.
------------------
Michael Ernest, co-author of:
The Complete Java 2 Certification Study Guide [This message has been edited by Michael Ernest (edited January 10, 2001).]