Michael Hoennig wrote:
Hi Stephan,


Here you query an XTextCursorfrom a TabStop struct? That should throw
an exception or at least return null, don't know the UNO spec for the
case where queryInterface is used on a non interface.

Undefined behaviour (i.e.: never do that in your code). The current implementation will most probably return null.


don't you think an exception would be better?  It does not make sense to
query an interface from anything else then an interface.  Only qerying
from null might make sense to be defined as returning null rather than an
exception.

UnoRuntime.queryInterface(type, null) is defined to work (and will return null).


The decision to make UnoRuntime.queryInterface(type, obj) with a non--UNO-interface type undefined behaviour (instead of defining it to throw a certain exception) is a balance between flexibility and efficiency of UnoRuntime's implementation on the one hand and maximum reliable error reporting on the other hand. (Also, any sensible implementation of UnoRuntime.queryInterface has only three choices how to behave in case of a non--UNO-interface type: return obj unchanged, return null, or throw an exception. Given the standard call sequence

  ((X) UnoRuntime.queryInterface(X.class, obj)).methodOfX()

each of the three alternatives will result in an exception pretty soon.)

-Stephan

Michael

--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to