You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by Felix Meschberger <fm...@gmail.com> on 2008/01/01 19:42:49 UTC

uses directive on Export-Package

Hi all,

I have an incertainty regarding the "uses" directive in Export-Package
manifest headers: The current 1.1.0 SNAPSHOT of the Bundle Plugin (also
the 1.0.0 release) creates a "uses" entry for each referenced package of
a class.

Consider now two packages org.sample and org.sample.impl. The org.sample
package is exported, the org.sample.impl package is private and not
exported. If a class in the org.sample calls into a class of the
org.sample.impl package, the bundle plugin generates an export statement
for the org.sample package:

    Export-Package: org.sample;uses:="org.sample.impl"

Is this correct ?

If I understand it correctly, listing a package in the "uses" directive
is not required, as long as the package does not occurr in any method
signature or field type. In fact, I think the use of the org.sample.impl
package is an implementation detail, which should not be "leaked" into
the Export-Package statement.

Any hints or help ? Thanks.

Regards and a happy new year
Felix


Re: uses directive on Export-Package

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Wednesday 02 January 2008 02:42, Felix Meschberger wrote:
> If I understand it correctly, listing a package in the "uses" directive
> is not required, as long as the package does not occurr in any method
> signature or field type. In fact, I think the use of the org.sample.impl
> package is an implementation detail, which should not be "leaked" into
> the Export-Package statement.

I am of the same understanding as you, and I have noticed this behavior of BND 
as well, but as Stuart points out, it doesn't "hurt" other than the extremely 
large Export-Package entries.

Perhaps Kriens can provide a motivation. I suspect that BND is just collecting 
all, and just doesn't have a last pass where only the private packages are 
discarded from the uses lists. Should be fairly simple to add... :o)


Cheers
-- 
Niclas Hedhman, Software Developer

I  live here; http://tinyurl.com/2qq9er
I  work here; http://tinyurl.com/2ymelc
I relax here; http://tinyurl.com/2cgsug

Re: uses directive on Export-Package

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Stuart,

Thanks for the answer. Let's see what Peter thinks ... Maybe it is, as
Niclas points out, that the uses lists should be scanned for private
packages...

I also see that it does not hurt, but it leaks information, which in my
understanding of OSGi is somewhat counter the OSGi idea.

Regards
Felix

Am Mittwoch, den 02.01.2008, 11:36 +0800 schrieb Stuart McCulloch:
> On 02/01/2008, Felix Meschberger <fm...@gmail.com> wrote:
> >
> > Hi all,
> >
> > I have an incertainty regarding the "uses" directive in Export-Package
> > manifest headers: The current 1.1.0 SNAPSHOT of the Bundle Plugin (also
> > the 1.0.0 release) creates a "uses" entry for each referenced package of
> > a class.
> >
> > Consider now two packages org.sample and org.sample.impl. The org.sample
> > package is exported, the org.sample.impl package is private and not
> > exported. If a class in the org.sample calls into a class of the
> > org.sample.impl package, the bundle plugin generates an export statement
> > for the org.sample package:
> >
> >     Export-Package: org.sample;uses:="org.sample.impl"
> >
> > Is this correct ?
> >
> > If I understand it correctly, listing a package in the "uses" directive
> > is not required, as long as the package does not occurr in any method
> > signature or field type. In fact, I think the use of the org.sample.impl
> > package is an implementation detail, which should not be "leaked" into
> > the Export-Package statement.
> >
> > Any hints or help ? Thanks.
> 
> 
> Hi Felix,
> 
> As I understand it, the BND tool adds all non-exported packages that are
> referred to by the exported package to its "uses" list - and this may result
> in more packages in "uses" than is strictly necessary, as it will also
> include
> classes that will never leak outside of the package.
> 
> The extra packages shouldn't cause any problems (they're just additional
> constraints in case internal objects happen to leak outside the public API)
> 
> If you'd like to set your own "uses" clause, or feel strongly about internal
> classes appearing in the "uses" list then I'd suggest you discuss this with
> PeterK, as it would require a change to the BND tool itself.
> 
> HTH
> 
> Regards and a happy new year
> > Felix
> >
> >
> 
> 


Re: uses directive on Export-Package

Posted by Stuart McCulloch <st...@jayway.net>.
On 02/01/2008, Felix Meschberger <fm...@gmail.com> wrote:
>
> Hi all,
>
> I have an incertainty regarding the "uses" directive in Export-Package
> manifest headers: The current 1.1.0 SNAPSHOT of the Bundle Plugin (also
> the 1.0.0 release) creates a "uses" entry for each referenced package of
> a class.
>
> Consider now two packages org.sample and org.sample.impl. The org.sample
> package is exported, the org.sample.impl package is private and not
> exported. If a class in the org.sample calls into a class of the
> org.sample.impl package, the bundle plugin generates an export statement
> for the org.sample package:
>
>     Export-Package: org.sample;uses:="org.sample.impl"
>
> Is this correct ?
>
> If I understand it correctly, listing a package in the "uses" directive
> is not required, as long as the package does not occurr in any method
> signature or field type. In fact, I think the use of the org.sample.impl
> package is an implementation detail, which should not be "leaked" into
> the Export-Package statement.
>
> Any hints or help ? Thanks.


Hi Felix,

As I understand it, the BND tool adds all non-exported packages that are
referred to by the exported package to its "uses" list - and this may result
in more packages in "uses" than is strictly necessary, as it will also
include
classes that will never leak outside of the package.

The extra packages shouldn't cause any problems (they're just additional
constraints in case internal objects happen to leak outside the public API)

If you'd like to set your own "uses" clause, or feel strongly about internal
classes appearing in the "uses" list then I'd suggest you discuss this with
PeterK, as it would require a change to the BND tool itself.

HTH

Regards and a happy new year
> Felix
>
>


-- 
Cheers, Stuart