Bug 34574 - Importing another version of a plugin doesn't re-index jar
Summary: Importing another version of a plugin doesn't re-index jar
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Wassim Melhem CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-11 05:38 EST by Jerome Lanneluc CLA
Modified: 2003-03-19 14:47 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jerome Lanneluc CLA 2003-03-11 05:38:17 EST
Build 2.1 RC2

1. Start fresh workspace
2. PDE Import org.eclipse.jdt.core from Eclipse 2.0
3. Open Type... "CreateWorkingCopyOperation"
Observe: The type should not be present
4. PDE Import org.eclipse.jdt.core from Eclipse. 2.1 RC2
5. Open Type... "CreateWorkingCopyOperation"
Observe: The type is not present, but it should
Comment 1 Jerome Lanneluc CLA 2003-03-11 06:10:23 EST
A request to re-index jdtcore.jar is made, the index state is set to 
REBUILDING, but it looks like getIndex(...) returns the existing index 
disregarding the index state.

(Thread[ModalContext,5,main]) DISCARD   background job family - 
org.eclipse.jdt.core
(Thread[ModalContext,5,main]) DISABLING background indexing
(Thread[ModalContext,5,main]) ENABLING  background indexing
(Thread[ModalContext,5,main]) DISCARD   DONE with background job family - 
org.eclipse.jdt.core
(Thread[ModalContext,5,main]) -> index state updated to: REBUILDING for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\376686048.index
(Thread[ModalContext,5,main]) REQUEST   background job - 
indexing /org.eclipse.jdt.core/jdtcore.jar
(Thread[ModalContext,5,main]) -> index state updated to: REBUILDING for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\468491586.index
(Thread[ModalContext,5,main]) REQUEST   background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.core.resources_2.1.0/resources.jar
(Thread[ModalContext,5,main]) -> index state updated to: REBUILDING for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\1041949545.index
(Thread[ModalContext,5,main]) REQUEST   background job - indexing 
D:/eclipse/Add_on/eclipse/plugins/org.eclipse.core.resources.spysupport_1.0.1/sp
ysupport.jar
(Thread[ModalContext,5,main]) -> index state updated to: REBUILDING for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\1261936400.index
(Thread[ModalContext,5,main]) REQUEST   background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.ant.core_2.1.0/antsupport.jar
(Thread[ModalContext,5,main]) -> index state updated to: REBUILDING for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\3774629530.index
(Thread[ModalContext,5,main]) REQUEST   background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.team.core_2.1.0/team.jar
(Thread[ModalContext,5,main]) -> index state updated to: REBUILDING for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\633443889.index
(Thread[ModalContext,5,main]) REQUEST   background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.core.boot_2.1.0/boot.jar
(Thread[ModalContext,5,main]) -> index state updated to: REBUILDING for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\2790214621.index
(Thread[ModalContext,5,main]) REQUEST   background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.core.runtime_2.1.0/runtime.jar
(Thread[ModalContext,5,main]) -> index state updated to: REBUILDING for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\4159451907.index
(Thread[ModalContext,5,main]) REQUEST   background job - indexing 
D:/jdk1.3.1/jre/lib/rt.jar
(Thread[Java indexing,4,main]) 8 awaiting jobs
(Thread[Java indexing,4,main]) STARTING background job - 
indexing /org.eclipse.jdt.core/jdtcore.jar
(Thread[Java indexing,4,main]) -> no indexing required (index already exists) 
for /org.eclipse.jdt.core/jdtcore.jar
(Thread[Java indexing,4,main]) FINISHED background job - 
indexing /org.eclipse.jdt.core/jdtcore.jar
(Thread[Java indexing,4,main]) 7 awaiting jobs
(Thread[Java indexing,4,main]) STARTING background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.core.resources_2.1.0/resources.jar
(Thread[Java indexing,4,main]) -> no indexing required (index already exists) 
for 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.core.resources_2.1.0/resources.jar
(Thread[Java indexing,4,main]) FINISHED background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.core.resources_2.1.0/resources.jar
(Thread[Java indexing,4,main]) 6 awaiting jobs
(Thread[Java indexing,4,main]) STARTING background job - indexing 
D:/eclipse/Add_on/eclipse/plugins/org.eclipse.core.resources.spysupport_1.0.1/sp
ysupport.jar
(Thread[Java indexing,4,main]) -> no indexing required (index already exists) 
for 
D:/eclipse/Add_on/eclipse/plugins/org.eclipse.core.resources.spysupport_1.0.1/sp
ysupport.jar
(Thread[Java indexing,4,main]) FINISHED background job - indexing 
D:/eclipse/Add_on/eclipse/plugins/org.eclipse.core.resources.spysupport_1.0.1/sp
ysupport.jar
(Thread[Java indexing,4,main]) 5 awaiting jobs
(Thread[Java indexing,4,main]) STARTING background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.ant.core_2.1.0/antsupport.jar
(Thread[Java indexing,4,main]) -> no indexing required (index already exists) 
for D:/eclipse/sdk/eclipse/plugins/org.eclipse.ant.core_2.1.0/antsupport.jar
(Thread[Java indexing,4,main]) FINISHED background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.ant.core_2.1.0/antsupport.jar
(Thread[Java indexing,4,main]) 4 awaiting jobs
(Thread[Java indexing,4,main]) STARTING background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.team.core_2.1.0/team.jar
(Thread[Java indexing,4,main]) -> no indexing required (index already exists) 
for D:/eclipse/sdk/eclipse/plugins/org.eclipse.team.core_2.1.0/team.jar
(Thread[Java indexing,4,main]) FINISHED background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.team.core_2.1.0/team.jar
(Thread[Java indexing,4,main]) 3 awaiting jobs
(Thread[Java indexing,4,main]) STARTING background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.core.boot_2.1.0/boot.jar
(Thread[Java indexing,4,main]) -> no indexing required (index already exists) 
for D:/eclipse/sdk/eclipse/plugins/org.eclipse.core.boot_2.1.0/boot.jar
(Thread[Java indexing,4,main]) FINISHED background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.core.boot_2.1.0/boot.jar
(Thread[Java indexing,4,main]) 2 awaiting jobs
(Thread[Java indexing,4,main]) STARTING background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.core.runtime_2.1.0/runtime.jar
(Thread[Java indexing,4,main]) -> no indexing required (index already exists) 
for D:/eclipse/sdk/eclipse/plugins/org.eclipse.core.runtime_2.1.0/runtime.jar
(Thread[Java indexing,4,main]) FINISHED background job - indexing 
D:/eclipse/sdk/eclipse/plugins/org.eclipse.core.runtime_2.1.0/runtime.jar
(Thread[Java indexing,4,main]) 1 awaiting jobs
(Thread[Java indexing,4,main]) STARTING background job - indexing 
D:/jdk1.3.1/jre/lib/rt.jar
(Thread[Java indexing,4,main]) -> no indexing required (index already exists) 
for D:/jdk1.3.1/jre/lib/rt.jar
(Thread[Java indexing,4,main]) FINISHED background job - indexing 
D:/jdk1.3.1/jre/lib/rt.jar
(Thread[Java indexing,4,main]) -> index state updated to: SAVED for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\4159451907.index
(Thread[Java indexing,4,main]) -> index state updated to: SAVED for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\633443889.index
(Thread[Java indexing,4,main]) -> index state updated to: SAVED for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\2790214621.index
(Thread[Java indexing,4,main]) -> index state updated to: SAVED for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\1041949545.index
(Thread[Java indexing,4,main]) -> index state updated to: SAVED for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\468491586.index
(Thread[Java indexing,4,main]) -> index state updated to: SAVED for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\3774629530.index
(Thread[Java indexing,4,main]) -> index state updated to: SAVED for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\376686048.index
(Thread[Java indexing,4,main]) -> index state updated to: SAVED for: 
D:\eclipse\runtime-
workspace\.metadata\.plugins\org.eclipse.jdt.core\1261936400.index

Moving to Kent to investigate.
Comment 2 Kent Johnson CLA 2003-03-11 10:09:23 EST
It has always worked this way.

Since rt.jar is part of every project and would be re-indexed anytime a project 
changed its classpath, a check is in place to skip jar files if an existing 
index is found in the cache.
Comment 3 Jerome Lanneluc CLA 2003-03-11 11:38:53 EST
It used to work in 2.0.2 because PDE import was doing the operation in one 
batch. Thus the classpath didn't appear as changed, only jdtcore.jar was 
reported to the DeltaProcessor as a CHANGED resource delta. In this case, the 
DeltaProcessor forces the index to be removed from disk and from the cache 
(using IndexManager.removeIndex(IPath)), then it requests the jar to be indexed 
(using IndexManager.indexLibrary(...)).

In 2.1, PDE import is doing the operation in 3 steps: it first sets the 
classpath to an empty one, it replaces the jar, and it resets the classpath to 
the final one. Because of that empty classpath setting, we don't see that the 
jar has changed (it is not on the classpath when the DeltaProcessor runs), thus 
it is not reindexed.
Comment 4 Jerome Lanneluc CLA 2003-03-11 12:14:30 EST
Changing PluginImportOperation to not set the classpath to an empty one fixes 
the problem.

Proposed fix: Change the last part of PluginImportOperation.createJavaProject
(...) to comment out the setting of an empty classpath.

if (isJavaProject) {
//	IJavaProject jProject = JavaCore.create(project);
//	if (jProject.getRawClasspath() != null
//		&& jProject.getRawClasspath().length > 0)
//		jProject.setRawClasspath(new IClasspathEntry[0], monitor);
	modelIds.add(model.getPluginBase().getId());
}

Moving to PDE to integrate this fix.
Comment 5 Dejan Glozic CLA 2003-03-11 12:19:27 EST
Are you sure there are no side-effects to this? The code that checks if there 
are classpath entries for an IJavaProject seems there for a purpose. Why are we 
getting into this branch to start with? The check will only set the empty 
classpath if one is detected and has entries. Why would IJavaProject for a 
newly created project have entires to begin with?
Comment 6 Jerome Lanneluc CLA 2003-03-11 12:40:07 EST
Sorry I don't know the purpose of this check (I expected that someone on your 
side would know). It might be to handle the case where autobuild is on and you 
import source. But this is the wrong way to do it. The whole import operation 
should be done in one IWorkspaceRunnable (It used to be like that in 2.0.2)

A newly created project will have a classpath that has one entry corresponding 
to the project (it was decided this is the most common case when creating a new 
project).
Comment 7 Dejan Glozic CLA 2003-03-11 12:45:21 EST
The project entry you describe is wrong most of the time for PDE - that is why 
we are removing it.

We did have one workspace runnable in 2.0.2 but had to split because we needed 
to split import and classpath computation steps. We compute classpaths based on 
the state of the workspace and external plug-ins, and neither PDE nor JDT 
models can react to changes in the workspace until resource change notification 
is fired. Hence we perform import in one operation, let the notification be 
fired, then compute classpaths using newly updated model information.
Comment 8 Jerome Lanneluc CLA 2003-03-11 12:50:24 EST
But you set the classpath anyway later. So why would you remove it first?
Comment 9 Dejan Glozic CLA 2003-03-11 12:52:33 EST
I don't know :-) (I am just scared to remove that code without knowing what it 
is for).

I will pass this to Wassim because he might remember.
Comment 10 Philipe Mulet CLA 2003-03-19 11:07:40 EST
Jdt/core issue is being addressed independantly in bug 35132.

Still PDE shouldn't cause such a refresh in the model by flushing CP entirely 
(should only update it).
Comment 11 Wassim Melhem CLA 2003-03-19 14:47:07 EST
PDE no longer clears the classpath in the first stage of importing.
This was fixed for RC3 for bug 34128.