ArrayStoreException when updating a bundle
===

Using Apache Felix I'm getting an ArrayStoreException when updating a bundle. It occurs in a different bundle to the one updated. The affected bundle has a service listener which reacts to a new service being registered by the updated bundle. The listener performs some code which ends in the ArrayStoreException. Here's the stack trace:

    ERROR: Bundle com.elsten.bliss.platform [47] EventDispatcher: Error during dispatch. (java.lang.ArrayStoreException: com.elsten.bliss.music.policy.tag.tagtype.TagTypePolicy)
    java.lang.ArrayStoreException: com.elsten.bliss.music.policy.tag.tagtype.TagTypePolicy
            at com.elsten.bliss.main.Main.getPolicies(Main.java:473)
            at com.elsten.bliss.main.Main.<init>(Main.java:150)
            at com.elsten.bliss.main.Main.startup(Main.java:143)
            at com.elsten.bliss.main.Activator$VersionServiceTracker.addingService(Activator.java:58)
            at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:980)
            at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:906)
            at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:262)
            at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:234)
            at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:941)
            at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:932)
            at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:793)
            at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:543)
            at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4260)
            at org.apache.felix.framework.Felix.registerService(Felix.java:3275)
            at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346)
            at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:352)
            at com.elsten.osgi.Activator.start(Activator.java:28)
            at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:641)
            at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
            at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
            at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
            at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:931)
            at org.apache.felix.bundlerepository.impl.ResolverImpl.deploy(ResolverImpl.java:647)
            at com.elsten.bliss.updater.OnlineUpdater$2.run(OnlineUpdater.java:100)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
            at java.lang.Thread.run(Thread.java:679)

The code in getPolicies (**which is a static method**) accessess a **static final** variable:

    private static final MusicPolicy tagTypePolicy = new TagTypePolicy();
    private static MusicPolicy[] policies;
    private static MusicPolicy[] getPolicies(Version version) {
    
    	if(policies==null) {
    		final HttpClientConfiguration httpClientConfig = HttpClientConfigurations.userAgentAndAcceptGzip(version);
    		policies = new MusicPolicy[] {
    			tagTypePolicy
    		};
    	}
    	return policies;
    }


My guess is that this is related to classloading; the MusicPolicy or TagTypePolicy classes do not match after the update. I'm a little confused why this would be the case; given these are **private** static variables I though my code could do what it liked. It's only when the statics are exported to other bundles, I thought, that trouble could happen.