Bug 126330 - Type reference not found in jar file if sources was not already opened
Summary: Type reference not found in jar file if sources was not already opened
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 130978 (view as bug list)
Depends on:
Blocks: 130978
  Show dependency tree
 
Reported: 2006-02-03 06:28 EST by Frederic Fusier CLA
Modified: 2006-04-07 07:20 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2006-02-03 06:28:44 EST
Build ID does not matter, I guess this happens for a while...

I have following simple test case:
A.java
  class A {}
B.java
  class B {
    A a;
  }

Of course searching for reference to A find match in B.java.
Now I export this test case in a jar with source, attach the exported jar to a new project. In package explorer I get:
P
  + test.jar
    + A
    + B
Select A without having opened any file of this jar, search for references in project => I get 0 match!
Now I open editor on B or A and search again => I find 1 match...
Close all editor and search again => I still find the match!

This is not a normal behavior, search engine should find the match even if no source has been opened before...
Comment 1 Frederic Fusier CLA 2006-02-03 12:51:41 EST
This is a problem with source attachement. In PackageFragmentRoot.getSourceMapper method first call, mapper == null but unfortunately sourcePath is also null...
Search Engine then considers there's no source and uses ClassFileMatchLocator which  fails to find this kind of reference (known limitation...).

Note that it works properly after having opened editor either on A.java or B.java even after a shutdown/restart of eclipse session. It only fails just after having created the project or closed/reopened it...
Comment 2 Jerome Lanneluc CLA 2006-02-06 07:07:05 EST
Changed PackageFragmentRoot#getSourceMapper() to attach the root to itself if none specified. Also removed code in ClassFile#openBuffer(...) that was duplicating this work and improved SourceMapper to pass in the IBinaryType when possible.

Added regression test JavaSearchBugs#test126330() and changed existing Java search tests that assumed that attaching a null souurce path would not find the source by extracting the source of existing jars in a different zip file.
Comment 3 Frederic Fusier CLA 2006-02-14 10:32:12 EST
Verified for 3.2 M5 using build I20060214-0010.
Comment 4 Jerome Lanneluc CLA 2006-04-07 07:20:11 EDT
*** Bug 130978 has been marked as a duplicate of this bug. ***