4040import java .util .Optional ;
4141import java .util .Queue ;
4242import java .util .Set ;
43+ import java .util .concurrent .atomic .AtomicLong ;
4344import java .util .function .BiPredicate ;
4445import java .util .function .Function ;
4546import java .util .function .Predicate ;
@@ -580,15 +581,16 @@ private static Set<BundleDescription> reresolveBundlesPreferringIncludedBundles(
580581 launchState .setPlatformProperties (tpState .getPlatformProperties ());
581582
582583 // Collect all bundles explicitly included in the launch
584+ AtomicLong id = new AtomicLong (1 );
583585 for (IPluginModelBase plugin : includedPlugins ) {
584- addPluginBundle (plugin , launchState , launchBundlePlugins , tpState );
586+ addPluginBundle (plugin , launchState , launchBundlePlugins , tpState , id );
585587 }
586588 Set <BundleDescription > launchBundles = new HashSet <>(launchBundlePlugins .keySet ());
587589
588590 // Iterate workspace- and TP-models separately to avoid shadowing of TP models by workspace models
589591 Stream .of (modelManager .getWorkspaceModels (), modelManager .getExternalModels ()).flatMap (Arrays ::stream ) //
590592 .filter (IPluginModelBase ::isEnabled ).filter (p -> !includedPlugins .contains (p )) //
591- .forEach (plugin -> addPluginBundle (plugin , launchState , launchBundlePlugins , tpState ));
593+ .forEach (plugin -> addPluginBundle (plugin , launchState , launchBundlePlugins , tpState , id ));
592594
593595 launchState .getResolver ().setSelectionPolicy (Comparator
594596 // prefer bundles explicitly included in the launch
@@ -602,13 +604,13 @@ private static Set<BundleDescription> reresolveBundlesPreferringIncludedBundles(
602604 return launchBundles ;
603605 }
604606
605- private static void addPluginBundle (IPluginModelBase plugin , State launchState , Map <BundleDescription , IPluginModelBase > launchBundlePlugin , State tpState ) {
607+ private static void addPluginBundle (IPluginModelBase plugin , State launchState , Map <BundleDescription , IPluginModelBase > launchBundlePlugin , State tpState , AtomicLong id ) {
606608 BundleDescription bundle = plugin .getBundleDescription ();
607609 if (bundle != null ) {
608610 if (bundle .getContainingState () != tpState ) { // consistency check
609611 throw new IllegalStateException ("Plugins have different TP state" ); //$NON-NLS-1$
610612 }
611- BundleDescription launchBundle = launchState .getFactory ().createBundleDescription (bundle );
613+ BundleDescription launchBundle = launchState .getFactory ().createBundleDescription (id . getAndIncrement (), bundle );
612614 launchBundle .setUserObject (plugin );
613615 if (!launchState .addBundle (launchBundle )) {
614616 throw new IllegalStateException ("Failed to add bundle to launch state: " + launchBundle ); //$NON-NLS-1$
0 commit comments