Modified isAssignableTo() to check if the provider bundle is the exporter
of the requestor bundle's wire.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@549491 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java b/framework/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java
index a466161..e171684 100644
--- a/framework/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java
@@ -150,20 +150,26 @@
// object uses the same class as the requester.
else if (providerWire == null)
{
- try
+ // If the provider is not the exporter of the requester's package,
+ // then try to use the service registration to see if the requester's
+ // class is accessible.
+ if (!((BundleImpl) m_bundle).getInfo().hasModule(requesterWire.getExporter()))
{
- // Load the class from the requesting bundle.
- Class requestClass =
- ((BundleImpl) requester).getInfo().getCurrentModule().getClass(className);
- // Get the service registration and ask it to check
- // if the service object is assignable to the requesting
- // bundle's class.
- allow = getServiceRegistration().isClassAccessible(requestClass);
- }
- catch (Exception ex)
- {
- // This should not happen, filter to be safe.
- allow = false;
+ try
+ {
+ // Load the class from the requesting bundle.
+ Class requestClass =
+ ((BundleImpl) requester).getInfo().getCurrentModule().getClass(className);
+ // Get the service registration and ask it to check
+ // if the service object is assignable to the requesting
+ // bundle's class.
+ allow = getServiceRegistration().isClassAccessible(requestClass);
+ }
+ catch (Exception ex)
+ {
+ // This should not happen, filter to be safe.
+ allow = false;
+ }
}
}
// Case 3: Include service reference if the wires have the