Bug 148215 - [search] Exception while searching for declarations of referenced types in binary java elements packaged in a jar
Summary: [search] Exception while searching for declarations of referenced types in bi...
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.1   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-22 09:55 EDT by Emmanuel Geay CLA
Modified: 2006-09-11 13:53 EDT (History)
1 user (show)

See Also:


Attachments
Jar file to reproduce the problem (1.64 KB, application/octet-stream)
2006-06-23 06:59 EDT, Frederic Fusier CLA
no flags Details
Proposed patch (4.61 KB, patch)
2006-06-23 07:01 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Emmanuel Geay CLA 2006-06-22 09:55:25 EDT
Hi,

I'd like to have access to declarations of referenced types in methods. Consequently after reading the docs, I wrote next piece of code:

        final SearchEngine searchEngine = new SearchEngine();
	final RequiredTypesRequestor searchRequestor = new RequiredTypesRequestor( ... );
    	try {
        searchEngine.searchDeclarationsOfReferencedTypes( method, searchRequestor, monitor );
    	} catch ( JavaModelException except ) {
        // logging
      }

Unfortunately I receive the exception below when the method is a binary method encapsulated into a jar [but it also occurs with any other java element packaged into that jar]. Jar with which I carefully attached a source code.

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(Unknown Source)
	at java.lang.String.substring(Unknown Source)
	at org.eclipse.jdt.internal.core.util.HandleFactory.createOpenable(HandleFactory.java:134)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1159)
	at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchDeclarations(BasicSearchEngine.java:1108)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchDeclarationsOfReferencedTypes(BasicSearchEngine.java:1161)
	at org.eclipse.jdt.core.search.SearchEngine.searchDeclarationsOfReferencedTypes(SearchEngine.java:896)
...

I work with Eclipse 3.2RC7.

Thanks in advance for your help.
Comment 1 Olivier Thomann CLA 2006-06-22 10:31:01 EDT
Could you please provide a test case?
Thanks.
Comment 2 Frederic Fusier CLA 2006-06-22 10:58:40 EDT
I've already got test case from Emmanuel about this issue and asked him to open a bug...
Thanks Olivier
Comment 3 Frederic Fusier CLA 2006-06-23 06:59:54 EDT
Created attachment 45160 [details]
Jar file to reproduce the problem

Any of searchDeclarationsOf* method performed on this jar file would throw a JavaModelException...
Comment 4 Frederic Fusier CLA 2006-06-23 07:01:36 EDT
Created attachment 45161 [details]
Proposed patch

Tests added on JavaSearchBugsTests use previous attached Jar file put in /JavaSearchBugs/lib folder...
Comment 5 Frederic Fusier CLA 2006-06-23 07:03:35 EDT
Philippe, I think this is obviously a candidate for 3.2.1, isn't it?
Comment 6 Philipe Mulet CLA 2006-06-23 07:05:37 EDT
+1 for 3.2.1
Comment 7 Frederic Fusier CLA 2006-06-23 10:11:00 EDT
Released for 3.2.1 in TARGET_321 branch
Comment 8 Frederic Fusier CLA 2006-06-23 11:37:08 EDT
Released for 3.3 M1 in HEAD
Comment 9 Frederic Fusier CLA 2006-08-07 04:35:34 EDT
Verified for 3.3 M1 using build I20060807-0010
Comment 10 Olivier Thomann CLA 2006-09-11 13:53:45 EDT
Verified for 3.2.1 using build M20060908-1655.