+
+ // keep only bundles with the highest version
+ Map<String, Bundle> startableBundles = new HashMap<>();
+ bundles: for (Bundle bundle : bundleContext.getBundles()) {
+ if (bundle.getVersion() == null)
+ continue bundles;
+ String bsn = bundle.getSymbolicName();
+ if (!startableBundles.containsKey(bsn)) {
+ startableBundles.put(bsn, bundle);
+ } else {
+ if (bundle.getVersion().compareTo(startableBundles.get(bsn).getVersion()) > 0) {
+ startableBundles.put(bsn, bundle);
+ }
+ }
+ }
+
+ for (Bundle bundle : startableBundles.values()) {