Mandatory attribute matching not working for  DynamicImport-Package
-------------------------------------------------------------------

                 Key: FELIX-676
                 URL: https://issues.apache.org/jira/browse/FELIX-676
             Project: Felix
          Issue Type: Bug
          Components: Framework
    Affects Versions: felix-1.0.4
         Environment: NA
            Reporter: Sahoo
             Fix For: felix-1.2.0


Section #3.8.2 of R4 spec says the following:

/All mandatory arbitrary attributes (as specified by the exporter, see 
Mandatory Attributes on page 45) must be specified in the dynamic import 
definition and match./

I suspect it is *not* working in Felix yet. I am using Felix v1.0.4. Mandatory 
attributes are considered while resolving static imports, but not for dynamic 
imports. I have two bundles that have identical contents, except that bundle 
#10 uses regular import, where as bundle #11 uses dynamic import. They both are 
trying to load a class foo.A. Package foo is exported by bundle #12 and it has 
a mandatory attribute defined like this:
/
Export-Package = foo;password=foo;mandatory:=password/

As shown below, when I start bundle #10, I get resolution error, where as 
bundle #11 happily wires to bundle #12.

-> start 10
org.osgi.framework.BundleException: Unresolved package in bundle 10: package; 
(package=foo)
-> start 11
DEBUG: WIRE: 11.0 -> org.osgi.framework -> 0
DEBUG: WIRE: 12.0 -> foo -> 12.0
DEBUG: WIRE: 11.0 -> foo -> 12.0
class foo.A is loaded by 12.0

The diff between manifest files of bundle #10 and #11 is supplied below:

diff dynamic-importer/target/classes/META-INF/MANIFEST.MF 
static-importer/target/classes/META-INF/MANIFEST.MF
5,6c5,6
< Import-Package: org.osgi.framework;version="1.3"
< Bnd-LastModified: 1218274803828
---
> Import-Package: foo,org.osgi.framework;version="1.3"
> Bnd-LastModified: 1218274805799
8c8
< Bundle-Name: dynamic-importer
---
> Bundle-Name: static-importer
12,13c12,13
< Bundle-SymbolicName: sahoo.dynamic-import-mandatory-attr.dynamic-impor
<  ter
---
> Bundle-SymbolicName: sahoo.dynamic-import-mandatory-attr.static-import
>  er
15d14
< DynamicImport-Package: *

I am attaching a simple test case demonstrating the same.

I suspect it has to do with the way filters are used to match requirements with 
capabilities. The filter is not aware of mandatory attributes, so it matches 
even when they are not specified.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to