Bug 9240 - Search finds deleted classes
Summary: Search finds deleted classes
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-02-07 10:23 EST by Martin Aeschlimann CLA
Modified: 2002-03-11 11:54 EST (History)
0 users

See Also:


Attachments
AllTypesCacheTest.java (8.83 KB, text/plain)
2002-02-07 10:24 EST, Martin Aeschlimann CLA
no flags Details
AllTypesCache.java (5.35 KB, text/plain)
2002-02-07 10:25 EST, Martin Aeschlimann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2002-02-07 10:23:57 EST
20205
attached JUnit-test AllTypesCacheTest.java:
- load project 'org.eclipse.jdt.ui.tests' from dev.eclipse.org
- copy AllTypesCacheTest next to AddUnimplementedMethodsTest.java
- run it using the JUnit eclipse launcher (or use main() in AllTypesCacheTest 
(only if your workspace is complete and all projects are located in the default 
workspace))

1. It seems that the index of the search is not updated after a JAR has been 
removed from the classpath
failures in 'testClasspathChange()':

- assertNull("mylib.Foo still found", findTypeRef(res1, "mylib.Foo"));
- assertTrue("539 types in workspace expected, is " + res1.size(), res1.size() 
== 539);

Library myLib contains 4 classes, like 'mylib.Foo', which are still found after 
the library has been removed from the classpath.

2. append the TestCase to the AutomatedSuite
- append following line to AutomatedSuite.AutomatedSuite()
 addTest(AllTypesCacheTest.suite());
- run the whole test suite
- it failes already in the first test of AllTypesCacheTest as even more types 
are found than when run separatly. It seems that index has not been completly 
emptied on tearDown of an other test.
Comment 1 Martin Aeschlimann CLA 2002-02-07 10:24:54 EST
Created attachment 320 [details]
AllTypesCacheTest.java
Comment 2 Martin Aeschlimann CLA 2002-02-07 10:25:24 EST
Created attachment 321 [details]
AllTypesCache.java
Comment 3 Philipe Mulet CLA 2002-02-07 18:14:39 EST
Could it be related to recent changes in the delta processor ?
Comment 4 Jerome Lanneluc CLA 2002-02-11 10:09:14 EST
Which version of jdt.ui is AllTypeCacheTests for? I tried with 20020205 and I 
cannot compile it. I tried the latest jdt.ui from HEAD, and I get a 
ClassCastException.

Could you provide me with a self-contained test case?
Comment 5 Jerome Lanneluc CLA 2002-03-08 12:36:20 EST
Closing. Please re-open if you have a valid test case.
Comment 6 Martin Aeschlimann CLA 2002-03-11 04:05:25 EST
1. Load plugin 'org.eclipse.jdt.ui.tests' (its also in dev.eclipse) to your 
workspace for eclipse developement.
2. You find the latest version of AllTypesCacheTest in there. It can be runned 
from its main, if you have all requiered projects at the same locaion (No usage 
of projects pointing directly to the drop), or use the JUnit Eclipse launcher.

Doing that you get 1 failure. (1.)

3. No go to AutomatedSuite and uncomment the last line in suite.
Now also other test cases fail that succeeded before. (2)
Comment 7 Jerome Lanneluc CLA 2002-03-11 05:07:57 EST
What are the deleted types that are found? Where in the test suite code are 
they deleted?
Comment 8 Martin Aeschlimann CLA 2002-03-11 05:22:58 EST
all the element are from a JAR ('mylib.jar'.).
This JAR is put on the classpath in setup (look for JavaProjectHelper.MYLIB), 
and removed from the classpath again in the test. However, the types contained 
are still found by search.
Comment 9 Jerome Lanneluc CLA 2002-03-11 05:37:03 EST
That's not what I'm seeing. I see that the 3 extra types are:
534: path= /TestProject2/src/pack1/ReqProjType.java; pkg= pack1; enclosing= 
ReqProjType; name= Inner
535: path= /TestProject2/src/pack1/ReqProjType.java; pkg= pack1; enclosing= 
ReqProjType.Inner; name= InnerInner
536: path= /TestProject2/src/pack1/ReqProjType.java; pkg= pack1; enclosing= ; 
name= ReqProjType

Where are these types created and deleted?
Comment 10 Martin Aeschlimann CLA 2002-03-11 05:56:16 EST
These types come from JavaModelUtilTest.
Comment 11 Jerome Lanneluc CLA 2002-03-11 11:54:46 EST
First problem was because the same workspace scope was used before and after a 
classpath was changed. It was caching all the indexes visible in the workspace. 
Changed it (and all the scopes) so that they listen for the java element deltas 
and update their internal state when needed.

Second problem was because the index of a project was not removed from disk 
when the project was deleted. As a result, when the same project was re-
created, it would reuse the index and find extra-types. Now deleting the index 
when the project is deleted.