You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Guillaume Nodet (JIRA)" <ji...@apache.org> on 2013/06/18 08:41:21 UTC

[jira] [Reopened] (FELIX-1131) ServiceReference.isAssignableTo fails when using a factory that can not see the exported class and the bundle exporting the service does not have a direct wire to this class

     [ https://issues.apache.org/jira/browse/FELIX-1131?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guillaume Nodet reopened FELIX-1131:
------------------------------------


I have another use case which may be possibly improved.
 * bundle A defines a package in version v1, exports it using a factory and registers a service with an interface from this package
  * bundle B defines the same package with version v2, exports it using a factory and registers a service with this pacakge
  * bundle C imports that package and grabs a service reference. Both references are deemed compatible by the framework

The reason why this use case could be improved is that both bundles A and B can see the package and the service object is supposed to implement the interface.  So this is different from the original use case where the registrant bundle did not even see the package.
This checks is not performed because felix only verify imported packages, not exported packages.  I'll try to see if I can provide a patch.

                
> ServiceReference.isAssignableTo fails when using a factory that can not see the exported class and the bundle exporting the service does not have a direct wire to this class
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: FELIX-1131
>                 URL: https://issues.apache.org/jira/browse/FELIX-1131
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-1.6.0
>            Reporter: Guillaume Nodet
>            Assignee: Richard S. Hall
>
>  * bundle A defines an interface R and a class S in different packages, whith S implementing R
>  * bundle B defines a class T extending S, it has an import statement on S package, but not on R package
>  * bundle C defines a ServiceFactory that export T service without any import on any package from R, S, T
> in this case, the line 426 of ServiceRegistrationImpl is executed:
>                        allow = getServiceRegistration().isClassAccessible(requestClass);
> which looks like:
>    protected boolean isClassAccessible(Class clazz)
>    {
>        try
>        {
>            // Try to load from the service object or service factory class.
>            Class sourceClass = (m_factory != null)
>                ? m_factory.getClass() : m_svcObj.getClass();
>            Class targetClass = Util.loadClassUsingClass(sourceClass, clazz.getName());
>            return (targetClass == clazz);
>        }
>        catch (Exception ex)
>        {
>            // Ignore this and return false.
>        }
>        return false;
>    }
> So felix checks if the classloader used to load the factory can also load the interface, which is not the case in my example.
> So isClassAccessible returns false and the event is not dispatched to the service listener.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira