Do you export and import the package your bundle Activator is contained (I assume this is a BundleActivator)? If so then the old copy of the package is still left available (as an exported package). The new version of the bundle will end up importing and using the old package. This is why you would still see the old class loader for the Activator class upon start of the new version of the bundle.
Tom From: Erwin Hogeweg <[email protected]> To: OSGi Developer Mail List <[email protected]>, Date: 02/03/2013 10:56 AM Subject: [osgi-dev] Static variable not so static after bundle update. Sent by: [email protected] Hi, I ran into an issue after I updated a bundle. After some digging I found that a static variable didn't have the expected value after the update. I have a feel for what is going on, but I can't quite connect all the dots. So here is what's happening: I have an Activator with a static self. public Activator(...){ private static Activator self; ... public void start(...){ self = this; ... } public void stop(...){ self = null; ...} public static Activator getInstance(){ return self; } When the framework starts up, everything works as expected. When the bundle that contains this activator is updated though, the returned value for self = null. When I remove the null assignment in the stop() method, the getInstance() method returns the self reference from before the bundle update. So somehow, the framework holds on to the initial Activator class, and keeps using this 'old' reference, even when the getInstance() call is made from within the bundle itself. When I inspect the classloader inside the getInstance() method it shows the same reference before and after the update, which is suspicious, and probably the cause of the problem. I am not necessarily looking for a solution because there is a better way to solve this problem, but I would like to understand exactly what is going here. I don't quite get it yet. Any insight is highly appreciated. Kind Regards, Erwin _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
<<inline: graycol.gif>>
_______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
