@@ -85,7 +85,7 @@ class RequiredPluginsClasspathContainer {
8585 private static final String JUNIT4_PLUGIN = "org.junit" ;
8686 private static final VersionRange JUNIT_4_VERSION = new VersionRange ("[4.0,5)" ); //$NON-NLS-1$
8787 @ SuppressWarnings ("nls" )
88- private static final Set <String > JUNIT5_RUNTIME_PLUGINS = Set .of ("org.junit" , //
88+ private static final List <String > JUNIT5_RUNTIME_PLUGINS = List .of ("org.junit" , //
8989 "junit-platform-launcher" ,
9090 "org.junit.platform.launcher" ,
9191 "junit-jupiter-engine" , // BSN of the bundle from Maven-Central
@@ -223,7 +223,7 @@ private List<IClasspathEntry> computePluginEntriesByModel() throws CoreException
223223 return List .of ();
224224 }
225225
226- Map <BundleDescription , List <Rule >> map = retrieveVisiblePackagesFromState (desc );
226+ Map <BundleDescription , LinkedHashSet <Rule >> map = retrieveVisiblePackagesFromState (desc );
227227
228228 // Add any library entries contributed via classpath contributor
229229 // extension (Bug 363733)
@@ -338,8 +338,8 @@ private static synchronized Stream<IClasspathContributor> getClasspathContributo
338338 return Stream .concat (fClasspathContributors .stream (), PDECore .getDefault ().getClasspathContributors ());
339339 }
340340
341- private Map <BundleDescription , List <Rule >> retrieveVisiblePackagesFromState (BundleDescription desc ) {
342- Map <BundleDescription , List <Rule >> visiblePackages = new HashMap <>();
341+ private Map <BundleDescription , LinkedHashSet <Rule >> retrieveVisiblePackagesFromState (BundleDescription desc ) {
342+ Map <BundleDescription , LinkedHashSet <Rule >> visiblePackages = new HashMap <>();
343343 StateHelper helper = BundleHelper .getPlatformAdmin ().getStateHelper ();
344344 addVisiblePackagesFromState (helper , desc , visiblePackages );
345345 if (desc .getHost () != null ) {
@@ -349,7 +349,7 @@ private Map<BundleDescription, List<Rule>> retrieveVisiblePackagesFromState(Bund
349349 }
350350
351351 private void addVisiblePackagesFromState (StateHelper helper , BundleDescription desc ,
352- Map <BundleDescription , List <Rule >> visiblePackages ) {
352+ Map <BundleDescription , LinkedHashSet <Rule >> visiblePackages ) {
353353 if (desc == null ) {
354354 return ;
355355 }
@@ -359,11 +359,9 @@ private void addVisiblePackagesFromState(StateHelper helper, BundleDescription d
359359 if (exporter == null ) {
360360 continue ;
361361 }
362- List <Rule > list = visiblePackages .computeIfAbsent (exporter , e -> new ArrayList <>());
362+ LinkedHashSet <Rule > list = visiblePackages .computeIfAbsent (exporter , e -> new LinkedHashSet <>());
363363 Rule rule = getRule (helper , desc , export );
364- if (!list .contains (rule )) {
365- list .add (rule );
366- }
364+ list .add (rule );
367365 }
368366 }
369367
@@ -375,7 +373,7 @@ private Rule getRule(StateHelper helper, BundleDescription desc, ExportPackageDe
375373 }
376374
377375 protected void addDependencyViaImportPackage (BundleDescription desc , Set <BundleDescription > added ,
378- Map <BundleDescription , List <Rule >> map , List <IClasspathEntry > entries ) throws CoreException {
376+ Map <BundleDescription , LinkedHashSet <Rule >> map , List <IClasspathEntry > entries ) throws CoreException {
379377 if (desc == null || !added .add (desc )) {
380378 return ;
381379 }
@@ -393,12 +391,12 @@ protected void addDependencyViaImportPackage(BundleDescription desc, Set<BundleD
393391 }
394392
395393 private void addDependency (BundleDescription desc , Set <BundleDescription > added ,
396- Map <BundleDescription , List <Rule >> map , List <IClasspathEntry > entries ) throws CoreException {
394+ Map <BundleDescription , LinkedHashSet <Rule >> map , List <IClasspathEntry > entries ) throws CoreException {
397395 addDependency (desc , added , map , entries , true );
398396 }
399397
400398 private void addDependency (BundleDescription desc , Set <BundleDescription > added ,
401- Map <BundleDescription , List <Rule >> map , List <IClasspathEntry > entries , boolean useInclusion )
399+ Map <BundleDescription , LinkedHashSet <Rule >> map , List <IClasspathEntry > entries , boolean useInclusion )
402400 throws CoreException {
403401 if (desc == null || !added .add (desc )) {
404402 return ;
@@ -441,7 +439,7 @@ private void addDependency(BundleDescription desc, Set<BundleDescription> added,
441439 }
442440 }
443441
444- private boolean addPlugin (BundleDescription desc , boolean useInclusions , Map <BundleDescription , List <Rule >> map ,
442+ private boolean addPlugin (BundleDescription desc , boolean useInclusions , Map <BundleDescription , LinkedHashSet <Rule >> map ,
445443 List <IClasspathEntry > entries ) throws CoreException {
446444 IPluginModelBase model = PluginRegistry .findModel ((Resource ) desc );
447445 if (model == null || !model .isEnabled ()) {
@@ -469,7 +467,7 @@ private boolean addPlugin(BundleDescription desc, boolean useInclusions, Map<Bun
469467 return true ;
470468 }
471469
472- private List <Rule > getInclusions (Map <BundleDescription , List <Rule >> map , IPluginModelBase model ) {
470+ private List <Rule > getInclusions (Map <BundleDescription , LinkedHashSet <Rule >> map , IPluginModelBase model ) {
473471 BundleDescription desc = model .getBundleDescription ();
474472 if (desc == null || "false" .equals (System .getProperty ("pde.restriction" )) //$NON-NLS-1$ //$NON-NLS-2$
475473 || !(fModel instanceof IBundlePluginModelBase ) || TargetPlatformHelper .getTargetVersion () < 3.1 ) {
@@ -479,12 +477,12 @@ private List<Rule> getInclusions(Map<BundleDescription, List<Rule>> map, IPlugin
479477 if (desc .getHost () != null ) {
480478 desc = (BundleDescription ) desc .getHost ().getSupplier ();
481479 }
482- List <Rule > rules = map .getOrDefault (desc , List . of ());
483- return (rules .isEmpty () && !ClasspathUtilCore .hasBundleStructure (model )) ? null : rules ;
480+ LinkedHashSet <Rule > rules = map .getOrDefault (desc , new LinkedHashSet <> ());
481+ return (rules .isEmpty () && !ClasspathUtilCore .hasBundleStructure (model )) ? null : new ArrayList <>( rules ) ;
484482 }
485483
486484 private void addHostPlugin (HostSpecification hostSpec , Set <BundleDescription > added ,
487- Map <BundleDescription , List <Rule >> map , List <IClasspathEntry > entries ) throws CoreException {
485+ Map <BundleDescription , LinkedHashSet <Rule >> map , List <IClasspathEntry > entries ) throws CoreException {
488486 BaseDescription desc = hostSpec .getSupplier ();
489487
490488 if (desc instanceof BundleDescription host ) {
@@ -628,7 +626,7 @@ private void addJunit5RuntimeDependencies(Set<BundleDescription> added, List<ICl
628626 }
629627
630628 // add dependency with exclude all rule
631- Map <BundleDescription , List <Rule >> rules = Map .of (desc , List . of ());
629+ Map <BundleDescription , LinkedHashSet <Rule >> rules = Map .of (desc , new LinkedHashSet <> ());
632630 addPlugin (desc , true , rules , entries );
633631 }
634632 }
@@ -692,7 +690,7 @@ private void addTransitiveDependenciesWithForbiddenAccess(Set<BundleDescription>
692690 while (transitiveDeps .hasNext ()) {
693691 BundleDescription desc = transitiveDeps .next ();
694692 if (added .add (desc )) {
695- Map <BundleDescription , List <Rule >> rules = Map .of (desc , List . of ());
693+ Map <BundleDescription , LinkedHashSet <Rule >> rules = Map .of (desc , new LinkedHashSet <> ());
696694 addPlugin (desc , true , rules , entries );
697695 }
698696 }
@@ -706,21 +704,24 @@ private void addExtraModel(BundleDescription desc, Set<BundleDescription> added,
706704 if (added .contains (bundleDesc )) {
707705 return ;
708706 }
709- Map <BundleDescription , List <Rule >> rules = new HashMap <>();
707+ Map <BundleDescription , LinkedHashSet <Rule >> rules = new HashMap <>();
710708 findExportedPackages (bundleDesc , desc , rules );
711709 addDependency (bundleDesc , added , rules , entries , true );
712710 }
713711 }
714712
715713 protected final void findExportedPackages (BundleDescription desc , BundleDescription projectDesc ,
716- Map <BundleDescription , List <Rule >> map ) {
714+ Map <BundleDescription , LinkedHashSet <Rule >> map ) {
717715 if (desc != null ) {
718716 Queue <BundleDescription > queue = new ArrayDeque <>();
719717 queue .add (desc );
720718 while (!queue .isEmpty ()) {
721719 BundleDescription bdesc = queue .remove ();
720+ if (map .containsKey (bdesc )) {
721+ continue ;
722+ }
722723 ExportPackageDescription [] expkgs = bdesc .getExportPackages ();
723- List <Rule > rules = new ArrayList <>();
724+ LinkedHashSet <Rule > rules = new LinkedHashSet <>();
724725 for (ExportPackageDescription expkg : expkgs ) {
725726 boolean discouraged = restrictPackage (projectDesc , expkg );
726727 IPath path = IPath .fromOSString (expkg .getName ().replace ('.' , '/' ) + "/*" ); //$NON-NLS-1$
0 commit comments