Bug 66766 - PDE classpath container changes not always triggering builds
Summary: PDE classpath container changes not always triggering builds
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.0 RC3   Edit
Assignee: PDE-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-11 15:16 EDT by Jim des Rivieres CLA
Modified: 2004-06-18 11:00 EDT (History)
2 users (show)

See Also:


Attachments
Patch for pde-core (1.79 KB, patch)
2004-06-16 12:19 EDT, Wassim Melhem CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jim des Rivieres CLA 2004-06-11 15:16:53 EDT
Build I200406110010

0. New workspace. Autobuild OFF.
1. Set Plug-in Dev > Target Platform preference to include just these plug-ins:
org.eclipse.core.runtime
org.eclipse.osgi
org.eclipse.osgi.services
org.eclipse.osgi.util
org.eclipse.swt
org.eclipse.swt.win32

2. Load org.eclipse.jface project from dev.eclipse.org repo

3. In Package explorer expand org.eclipse.jface/Plug-in Dependencies.

Observe: dependencies includes swt.jar

4. Build All

Observe: No compile errors.

5. Load org.eclipse.swt and org.eclipse.swt.win32 projects from 
dev.eclipse.org repo.

Observe: As the projects are being loaded, JFace plug-in dependencies drop 
swt.jar and picks up org.eclipse.swt project.

6. Build All

Observe: Fatal compile errors. SWT cannot be build (this is expected). JFace 
cannot be built either because it depends on SWT (also expected).

7. Delete org.eclipse.swt and swt.win32 projects from workspace.

Observe: After the project has been deleted, dependencies drops 
org.eclipse.swt project.

Expectation: By symmetry, it pick up swt.jar when it drops org.eclipse.swt 
project. This is problem #1.

8. Build All

Observe: Numerous compile errors. Cannot resolve references to SWT classes.

9. Close JFace project.
10. Open JFace project.

Observe: Package explorer shows org.eclipse.jface plug-in dependencies as 
including org.eclipse.swt. Goodness again, or so it seems. This shows that PDE 
is correctly computing classpath container when project is opened.

11. Build all

Observe: The build is a no-op. Numerous compile errors remain.

Expectation: Given the switch between swt.jar and the project, JFace needs to 
be thoroughly re-compiled, which should take several seconds. This looks like 
problem #2. I believe the built state was saved when the project was closed, 
and restored when it was reopened. The fact that PDE now computes different 
contents for the classpath container is not, but should, invalidate that built 
state.

12. Clean and build

Observe: JFace compiles without errors.
Observe: No compile errors. Goodness again.
Comment 1 Wassim Melhem CLA 2004-06-15 17:39:13 EDT
I was able to reproduce this.  Need to investigate and fix.

Dejan, +1 for RC3?
Comment 2 Dejan Glozic CLA 2004-06-15 17:40:38 EDT
Depends on the nature of fix. Append the results of the investigation and 
value/risk ratio.
Comment 3 Wassim Melhem CLA 2004-06-15 21:29:53 EDT
Value: Extremely High
Risk: Extremely Low

While, on the surface, this seemed like a flaw in classpath computation or pde 
container updating, the opposite is actually true.  In fact, the classpath 
computation exposed a flaw in the way we store/read version numbers.

Let me explain...
Back toward the end of the M9 cycle, the Core team introduced a new syntax to 
represent bundle version/match.
Old format: bundle-version:3.0.0;match=compatible
New format: bundle-version="[3.0.0,4.0.0)"

When we scan/resolve the target platform to populate our old models with the 
new data, here is how map the new format to our 2.1-compliant data 
structures:  Given the range, we take the minimum (ie. 3.0.0) to map it to the 
old meaning of version.  With a very simple algorithm, the "match" is deduced 
from the range.  In this case, this range maps to the old "COMPATIBLE".

This is all fine.

The problem arises when PDE reads the manifests from workspace plug-ins 
directly.  In these cases, we are storing the version as-is.  So if 
org.eclipse.swt.win32 is in the workspace, we store its version 
as "[3.0.0,4.0.0)".  So when we come to find all fragments belonging to 
org.eclipse.swt to search for the swt libraries, we don't get any match 
because when we pass [3.0.0,4.0.0) to PluginVersionIdentifier, an exception is 
thrown, so we fall back on a string comparison, which of course fails.

Here is a breakdown of what was happening in Jim's scenario:
1. He checks out org.eclipse.jface from cvs.  It classpath is complete because 
the external org.eclipse.swt.win32 and org.eclipse.swt have the right versions 
stored.

2. He then checks out org.eclipse.swt and swt.win32 from cvs.  Classpath here 
is also correct because we don't add workspace fragments directly to the 
classpath.  So the org.eclipse.swt plugin project gets directly added to the 
classpath of org.eclipse.jface.  Note that so far, the flaw in the way we 
store the version/match attributes in the swt.win32 has not been exposed.

3. Delete org.eclipse.swt and org.eclipse.swt.win32.  By the way, the problem 
is only exposed when the fragment is deleted after its parent plugin.
Now, the swt plugin is deleted, so the classpath computation of 
org.eclipse.jface is triggered.  

PDE doesn't find swt.jar in the external org.eclipse.swt, of course, because 
the JAR is shipped in the fragment in the SDK.  So we start looking for the 
JAR in the fragment(s).  

We first look for fragments in the workspace as they mask the external ones.  
The org.eclipse.swt.win32 fragment is still not technically deleted at this 
point, so we call our PDE.compare() utility on it to make sure that it matches 
the version and the compatibility with the org.eclipse.swt plugin.  This 
comparison fails because we are comparing [3.0.0, 4.0.0) with 3.0.0.  So no 
workspace fragments were found for the plugin.  And of course, no external 
fragments are hit because the workspace fragment had masked the external one.

So the classpath is now incomplete as PDE could not find swt.jar.

Therefore, the fix would entail fixing BundleFragment.getVersion() and 
BundleFragment.getRule() to parse the version ranges of the new manifest 
format and return corresponding values that are familiar to every other aspect 
of PDE.
Comment 4 John Wiegand CLA 2004-06-15 21:51:44 EDT
+1
Comment 5 Wassim Melhem CLA 2004-06-16 12:19:07 EDT
Created attachment 12281 [details]
Patch for pde-core

Dejan, please review patch.
Comment 6 Dejan Glozic CLA 2004-06-16 14:05:42 EDT
+1
Comment 7 Wassim Melhem CLA 2004-06-16 14:37:30 EDT
Marking as fixed.
Will be in today's 4 pm build.
Jim, please verify the fix and thank you for catching this bug in time.
Comment 8 Cherie Wong CLA 2004-06-18 11:00:29 EDT
Verified on I20040618-0800.