I have heard that the corba spec does not support downloadable stub files and that is why we use the PortableRemoteObject.narrow method to perform a safe cast.
This is in case the stub file doesn't exist on the client machine.
What exactly is meant by a safe cast? Is there something that happens behind the scenes here?
You're right that the CORBA spec does not define the concept of downloadable stubs. However, the spec does support the concept of downloadable value type implementations (you'd know value types if you're CORBA savvy, but otherwise, just ignore it ;)
In Borland Enterprise Server (which is built on top of VisiBroker - a CORBA implementation), the PRO.narrow() call can automagically download stub files on the fly from a server via the RMI codeBase property on the client.
In fact, the PRO.narrow() call is required by the spec since some RMI/IIOP implementations require it (we didn't "require" it in the beginning although we were IIOP based, but that led developers to write code that was not spec compliant/portable and hence we started to "enforce" the PRO.narrow() for all remote interfaces).