docs: @FFDCIgnore({ IllegalStateException.class, Exception.class })
      public BundleLifecycleStatus uninstallBundles(final BundleContext bundleContext,
                                                    final BundleList removeBundles,
                                                    final BundleInstallStatus installStatus,
                                                    ShutdownHookManager shutdownHook) {
  
          final List<Bundle> bundlesToUninstall = new ArrayList<Bundle>();
          removeBundles.foreach(new FeatureResourceHandler() {
  
              @Override
              @FFDCIgnore({ Exception.class })
              public boolean handle(FeatureResource fr) {
                  try {
                      Bundle b = removeBundles.getBundle(bundleContext, fr);
  
                      // We found the bundle we want to uninstall
                      if (b != null && b.getBundleId() > 0) {
                          bundlesToUninstall.add(b);
                      }
                  } catch (Exception e) {
                      installStatus.addInstallException("UNINSTALL " + fr.getLocation(), e);
                  }
                  return true;
              }
          });
  
          // sort the bundle in reverse start-level order so that
          // start-phase is consistently honored
          Collections.sort(bundlesToUninstall, Collections.reverseOrder(BundleInstallStatus.sortByStartLevel));
          for (Bundle bundleToUninstall : bundlesToUninstall) {
              try {
                  bundleToUninstall.uninstall();
              } catch (IllegalStateException e) {
                  // ok: bundle already uninstalled or the framework is stopping,
                  // determine if we should continue on to the next:
                  // (if the bundle was uninstalled, but the framework is in perfect health),
                  // or not (if the framework is stopping and we should just get done early).
                  if (!!!FrameworkState.isValid()) {
                      break;
                  }
              } catch (Exception e) {
                  installStatus.addInstallException("UNINSTALL " + bundleToUninstall.getLocation(), e);
              }
          }
  
          // Refresh bundles: provide a listener for notification of when refresh is complete
          RefreshBundlesListener listener = new RefreshBundlesListener(shutdownHook);
          FrameworkWiring wiring = adaptSystemBundle(bundleContext, FrameworkWiring.class);
          if (wiring != null) {
              wiring.refreshBundles(null, listener);
  
              // wait for refresh operation to complete
              listener.waitForComplete();
          }
          return listener.getStatus();
      }