Re: [equinox-dev] Question regarding class loader and getPackages()

2008-06-02 Thread BJ Hargrave
[EMAIL PROTECTED] wrote on 2008/06/02 08:58:36 AM:

 [image removed] 
 
 [equinox-dev] Question regarding class loader and getPackages()
 
 Jan Stette 
 
 to:
 
 Equinox development mailing list
 
 2008/06/02 08:59 AM
 
 Sent by:
 
 [EMAIL PROTECTED]
 
 Please respond to Equinox development mailing list 
equinox-dev@eclipse.org
 
 I'm trying to call Package.getPackages() in some code in an OSGi 
 bundle.  This calls into getPackages on the classloader, where I'm 
 observing that:
 
 1.  The call is not overridden in the Equinox classloader, so the 
 default implementation in java.lang.ClassLoader is used.  Hence, 
 only the bundle's own packages, and the system packages are returned.

I don't think imported packages should be listed since they are imported 
from other bundles.

 2.  Only packages from which at least one class has been loaded are 
 returned.  So, if a class hasn't been loaded from a given package, 
 it won't be included in the returned list.
 
 I haven't found anything in the OSGi or Java language specs that 
 specify this, but I expected all packages that the bundle 
 classloader can see to be returned, something aking to the java doc 
 description of Package.getPackages(): Get all the packages 
 currently known for the caller's ClassLoader instance. Those 

The packages currently known are those for which at least one successful 
class load has occurred. There is no reliable or specified way for a class 
loader to know all the classes which it can successfully load.

 packages correspond to classes loaded via or accessible by name to that 
 ClassLoader instance.  Which seems to suggest that both packages of
 classes that haven't been loaded yet, and packages imported by the 
 bundle class loader should be listed.
 
 I realise that the Package Admin service is an alternative for this,
 but I'm surprised if these details can't be accessed through the 
 class loader... 
 
 Could anyone shed some light on this, please?
 
 Regards,
 Jan
 ___
 equinox-dev mailing list
 equinox-dev@eclipse.org
 https://dev.eclipse.org/mailman/listinfo/equinox-dev

-- 

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance
[EMAIL PROTECTED]

office: +1 386 848 1781
mobile: +1 386 848 3788


___
equinox-dev mailing list
equinox-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/equinox-dev


Re: [equinox-dev] Question regarding class loader and getPackages()

2008-06-02 Thread Jan Stette
2008/6/2 BJ Hargrave [EMAIL PROTECTED]:


 [EMAIL PROTECTED] 1.  The call is not overridden in the
 Equinox classloader, so the
  default implementation in java.lang.ClassLoader is used.  Hence,
  only the bundle's own packages, and the system packages are returned.

 I don't think imported packages should be listed since they are imported
 from other bundles.


Does it matter which bundles the packages come from?  From the client of the
classloader, I would have thought this should be transparent, i.e. that it
returns all packages that are visible through this classloader.  From the
javadoc for java.lang.ClassLoader.getPackages():  Returns all of the
Packages defined by this class loader and its ancestors.  In an OSGi
environment, wouldn't it be natural to include classloaders from bundles
depended on as well?

Anyway, is this a question better suited for osgi-dev instead of this list?

Regards,
Jan
___
equinox-dev mailing list
equinox-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/equinox-dev