android / activation helpers / return values ?

Stephan Bergmann sbergman at redhat.com
Sun Aug 5 23:21:13 PDT 2012


On 08/04/2012 09:16 PM, Michael Meeks wrote:
> 	No ExtensionManager: exception 'component context fails to
> 	supply singleton com.sun.star.deployment.ExtensionManager of
> 	type ...
>
> 	Is it intended that that would throw an exception rather than returning
> NULL ? that was apparently not clear to either to Caolan, or me reading
> it :-)

The new-style service constructors/singleton getters never return null 
but throw DeplyomentException.  (Old createInstance stuff is vague on 
whether to return null or throw an exception, both happening in 
practice.  Maybe the code in question used to work with a null-returning 
createInstance line, and then has been changed to use the new style getter.)

> 	Of course - Android has no real need for the extension manager, we'll
> bundle a static image - so this sort of thing is expected; so just a
> question: is a nil return, or an exception ideal ? and/or is some
> QUERY_THROW type annotation wanted ? :-)

The general contract is that the services/singletons specified in UNOIDL 
are available from the global service manager.  That implies that 
throwing a DeploymentException ("something fundamental is broken with 
this installation") is better than returning null.  One could rethink 
that for platform feature fragmentation (rethink it into both 
directions: on the one hand, throwing an exception is not ideal; on the 
other hand, ignoring the exception for non-Android is not ideal, 
either), but I'm not sure it is worth it.

In any case, I'd augment the patch to catch just DeploymentException, 
turn the fprintf into a SAL_WARN, and add a comment that the exception 
is only expected to happen on Android.

Stephan



More information about the LibreOffice mailing list