Page 368 in Ice 3.1.0 document:
Code:
12.8.1Instantiating a Servant
Instantiating a servant means to allocate an instance:
Node servant = new NodeI("Fred");
This code creates a new NodeI instance and assigns its address to a reference of
type Node. This works because NodeI is derived from Node, so a Node reference
can refer to an instance of type NodeI. However, if we want to invoke a
member function of the NodeI class at this point, we must use a NodeI reference:
NodeI servant = new NodeI("Fred");
Whether you use a Node or a NodeI reference depends purely on whether you
want to invoke a member function of the NodeI class: if not, a Node reference
works just as well as a NodeI reference.
That is, the document emphasizes that if we want to invoke a member function of the XXXI class, we must use a XXXI reference instead of XXX interface reference. Can you explain a little more why ?
Further, in %ICEJ_HOME%\demo\book\simple_filesystem\Server.jav a:
Code:
File file = new FileI("README", root);
String[] text;
text = new String[] { "This file system contains a collection of poetry." };
try {
file.write(text, null);
} catch (GenericError e) {
System.err.println(e.reason);
}
Are they inconsistent ?
Thank you !