On Wednesday 25 April 2007 10:18, Stuart McCulloch wrote:
> BTW, if you export a package, it's good practice to also import it in case
> another bundle provides the same package. If you don't import then your
> package may end up in a separate class space.

Yes, and if you use internal jars, whose packages you don't export, then you 
can't place those classes into your APIs/SPIs as ClassCastException will 
happen when the client bundle tries to assign them to other namespaced 
classes, e.g.

String classname = Abc.class.getName();
ServiceReference ref = context.getServiceReference( classname );
if( ref != null )
{
    Abc abc = (Abc) context.getService( ref );
}

will give you a ClassCastException even though the ref is holding a Abc 
instance, but in different classloader namespace.



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
_______________________________________________
OSGi Developer Mail List
[email protected]
http://www2.osgi.org/mailman/listinfo/osgi-dev

Reply via email to