Bug 560822 - Parallelization in DirectoryBundleContainer leads to sporadic classpath changes on Eclipse startup
Summary: Parallelization in DirectoryBundleContainer leads to sporadic classpath chang...
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.9   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 4.16 M1   Edit
Assignee: Julian Honnen CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2020-03-05 10:44 EST by Nils Ruhr CLA
Modified: 2021-02-05 08:39 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nils Ruhr CLA 2020-03-05 10:44:31 EST
Let's say you have a plug-in project importing the bundle org.eclipse.osgi. Your target platform (which is a directory of plug-ins) also includes three fragments, each with org.eclipse.osgi as its host. (In our case the three fragments are org.eclipse.equinox.region, org.eclipse.equinox.weaving.hook, com.diffplug.osgi.extension.sun.misc.)
Therefore the classpath consists of org.eclipse.osgi and the three fragments.

The fragments are resolved and added to the classpath here:
org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.addDependency(BundleDescription, HashSet<BundleDescription>, Map<BundleDescription, ArrayList<Rule>>, ArrayList<IClasspathEntry>, boolean):

(...) BundleDescription[] fragments = hasExtensibleAPI(desc) ? desc.getFragments() : new BundleDescription[0]; (...)

The order of the fragments coming from desc.getFragments() dependes on the order of the TargetBundles coming from DirectoryBundleContainer.resolveBundles. Because of the added parallelization (https://bugs.eclipse.org/bugs/show_bug.cgi?id=535325) the order is de facto different every time you start Eclipse.

JDT notices the changed order of the classpath entries and produces a REORDER change event (flag org.eclipse.jdt.core.IJavaElementDelta.F_REORDER).

In our case the plug-in project importing org.eclipse.osgi is an Xtext project. Because of the reordering Xtext subsequently triggers a full build, which, in our case, happens nearly every time we start Eclipse.
Comment 1 Eclipse Genie CLA 2020-03-05 11:19:23 EST
New Gerrit change created: https://git.eclipse.org/r/158873
Comment 3 Vikas Chandra CLA 2020-04-08 08:15:10 EDT
Julian, can you please verify this fix?
Comment 4 Julian Honnen CLA 2020-04-08 08:37:11 EDT
verified by debugging

Version: 2020-06 (4.16)
Build id: I20200407-1800
Comment 5 Hannes Wellmann CLA 2021-02-05 04:27:37 EST
Shouldn't the same be done for features in the 'resolveFeatures()' method?
I did not encountered any issues with it, I only recognized it from reading the code.

If you agree, I can open another bug and provide a patch.
Comment 6 Vikas Chandra CLA 2021-02-05 08:04:46 EST
(In reply to Hannes Wellmann from comment #5)
> Shouldn't the same be done for features in the 'resolveFeatures()' method?
> I did not encountered any issues with it, I only recognized it from reading
> the code.
> 
> If you agree, I can open another bug and provide a patch.

Julian, can you please respond to this!
Comment 7 Julian Honnen CLA 2021-02-05 08:17:43 EST
(In reply to Hannes Wellmann from comment #5)
> Shouldn't the same be done for features in the 'resolveFeatures()' method?
> I did not encountered any issues with it, I only recognized it from reading
> the code.
> 
> If you agree, I can open another bug and provide a patch.
Yes, please do so. I don't see any functional problem if the feature order is not stable, but we should make the code consistent.
Comment 8 Hannes Wellmann CLA 2021-02-05 08:39:02 EST
I just created Bug 570963 and submitted a patch.