On Apr 18, 2013, at 16:00 , Robert Munteanu <[email protected]> wrote:
>>> ...The reason I need to hold on to the bundle is to load classes using >>> that its classloader at a later point in time... >> >> Can't you do that using getClass().getClassLoader() on a class that's inside >> that bundle? >> >> I *think* keeping references to Bundle objects is fine if you track them with >> a BundleTracker, but that sounds somewhat complicated. > > I actually need to load a class using the classloader from a different bundle > (B2) than the current one (B1). > > At some point in time B1 might be called on to load a class from B2 so the > only way I knew how to do this was to use bundle references and > Bundle.getClass(). > > Yes, it's done to appease a legacy bundle which is not OSGi-friendly :| . I'd recommend using Bundle.loadClass() to load classes using another bundle's class loader. As for using them as keys in maps, the Bundle interface extends Comparable so technically I don't see an issue there. Greetings, Marcel --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

