public void destroy(URI uri) throws ClassLoaderBuilderException { ClassLoader classLoader = classLoaderRegistry.getClassLoader(uri); int val = tracker.decrement(classLoader); if (val == 0 && metaDataStore.find(uri) == null) { // Note the MetaDataStore is used to determine if a contribution classloader must be tracked. If a contribution is registered in the // store, it is installed as an extension of the base runtime distribution and should only be uninstalled explicitly. try { classLoaderRegistry.unregister(uri); // release the previously resolved contribution resolver.release(uri); } catch (ResolutionException e) { throw new ClassLoaderBuilderException("Error releasing artifact: " + uri.toString(), e); } for (ClassLoaderListener listener : listeners) { listener.onUndeploy(classLoader); } } else if (val == 0) { // single VM, do not remove the classloader since it is used by the installed contribution. Just notify listeners for (ClassLoaderListener listener : listeners) { listener.onUndeploy(classLoader); } } }