Bug 98547 - StringIndexOutOfBoundsException when using References or Call Hiearchy
Summary: StringIndexOutOfBoundsException when using References or Call Hiearchy
Status: RESOLVED FIXED
Alias: None
Product: AJDT
Classification: Tools
Component: UI (show other bugs)
Version: 1.2.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 89326 91395 92482 92759 106164 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-06-06 12:51 EDT by Barry Kaplan CLA
Modified: 2005-09-02 11:04 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Barry Kaplan CLA 2005-06-06 12:51:41 EDT
I get this stack trace when peforming a References or Open CallHierachy in a
aspectj project. Performing a clean-build clears up the problem. It only (so
far) has occured in an aspectj project.

It does not matter what file is has focus when the search is performed. 

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(Unknown Source)
    at
org.eclipse.jdt.internal.core.util.Util.getNameWithoutJavaLikeExtension(Util.java:840)
    at
org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.<init>(JavaSearchNameEnvironment.java:62)
    at
org.eclipse.jdt.internal.core.search.matching.MatchLocator.initialize(MatchLocator.java:853)
    at
org.eclipse.jdt.internal.core.search.matching.SuperTypeNamesCollector.collect(SuperTypeNamesCollector.java:154)
    at
org.eclipse.jdt.internal.core.search.matching.MethodLocator.initializePolymorphicSearch(MethodLocator.java:48)
    at
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1013)
    at
org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94)
    at
org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:208)
    at
org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:421)
    at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:532)
    at
org.eclipse.jdt.internal.ui.search.JavaSearchQuery.run(JavaSearchQuery.java:135)
    at
org.eclipse.search2.internal.ui.InternalSearchUI$InternalSearchJob.run(InternalSearchUI.java:93)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:67)
Comment 1 Michael Moser CLA 2005-07-08 09:10:52 EDT
Same here when doing a "Java Search" (I was searching for a method name in the 
current working set):

Eclipse Platform
Version: 3.1.0
Build id: I20050627-1435

Eclipse AspectJ Development Tools
Version: 1.2.1
Build id: 20050707105537
AspectJ version: 1.5.0M2

!ENTRY org.eclipse.core.runtime 4 2 2005-07-08 15:03:40.190
!MESSAGE An internal error occurred during: "Java Search".
!STACK 0
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java(Compiled Code))
	at 
org.eclipse.jdt.internal.core.util.Util.getNameWithoutJavaLikeExtension
(Util.java:839)
	at 
org.eclipse.jdt.internal.core.search.matching.PossibleMatch.getQualifiedName
(PossibleMatch.java:101)
	at org.eclipse.jdt.internal.core.search.matching.PossibleMatch.<init>
(PossibleMatch.java:41)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches
(MatchLocator.java:1097)
	at 
org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches
(JavaSearchParticipant.java:94)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches
(BasicSearchEngine.java:208)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search
(BasicSearchEngine.java:424)
	at org.eclipse.jdt.core.search.SearchEngine.search
(SearchEngine.java:532)
	at org.eclipse.jdt.internal.ui.search.JavaSearchQuery.run
(JavaSearchQuery.java:135)
	at 
org.eclipse.search2.internal.ui.InternalSearchUI$InternalSearchJob.run
(InternalSearchUI.java:93)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)


Cheers,
Michael
Comment 2 Matthew Webster CLA 2005-07-29 04:12:09 EDT
I have seen the same problem with Eclise 3.1 and AJDT 1.2.1. If you restart 
Eclipse the problem seems to go away until you next build an AspectJ project. 
Sometimes I don't get an exception but Search fails to find things!
Comment 3 Sian January CLA 2005-08-02 04:45:31 EDT
I have also seen this happen once or twice and I believe it should be possible 
to fix, however I have not been able to reproduce it.  Has anyone else been 
able to create a test case which I would be able to use?
Comment 4 Sian January CLA 2005-08-03 05:57:19 EDT
*** Bug 89326 has been marked as a duplicate of this bug. ***
Comment 5 Sian January CLA 2005-08-05 05:58:37 EDT
*** Bug 92759 has been marked as a duplicate of this bug. ***
Comment 6 Sian January CLA 2005-08-05 06:00:09 EDT
*** Bug 91395 has been marked as a duplicate of this bug. ***
Comment 7 Helen Beeken CLA 2005-08-05 07:30:46 EDT
This seems to cause the same exception (or one very similar) and is reproducable
every time (I originally thought it was related to bug 98261):

- create a java project that contains one class C
- Install the TJP example
- Open GetInfo in the editor
- Delete the TJP project
- Rename the class C by right clicking on C and do Refactor > Rename

This causes the StringOutOfBoundsException:

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1768)
at
org.eclipse.jdt.internal.core.util.Util.getNameWithoutJavaLikeExtension(Util.java:839)
at
org.eclipse.jdt.internal.core.search.matching.PossibleMatch.getQualifiedName(PossibleMatch.java:101)
at
org.eclipse.jdt.internal.core.search.matching.PossibleMatch.<init>(PossibleMatch.java:41)
at
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1097)
at
org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94)
at
org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:208)
at
org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:424)
at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:532)
at
org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.findAffectedCompilationUnits(RefactoringSearchEngine.java:72)
at
org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor.checkConflictingTypes(RenameTypeProcessor.java:593)
at
org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor.analyzeAffectedCompilationUnits(RenameTypeProcessor.java:584)
at
org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor.checkFinalConditions(RenameTypeProcessor.java:330)
at
org.eclipse.jdt.internal.corext.refactoring.rename.RenameCompilationUnitProcessor.checkFinalConditions(RenameCompilationUnitProcessor.java:258)
at
org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:169)
at
org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84)
at
org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114)
at
org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:189)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1719)
at
org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:86)
at
org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)

Comment 8 Sian January CLA 2005-08-05 11:09:01 EDT
*** Bug 106164 has been marked as a duplicate of this bug. ***
Comment 9 Sian January CLA 2005-08-08 11:42:40 EDT
I fixed this by adding .aj as a java-like file extension in the start method 
of AspectJPlugin.  Unfortunately I wasn't able to add it through the extension 
points mechanism because JDT has not yet completed this support (see JDT bug 
71460).  I have added the extension commented out to the AJDT Core plugin.xml 
file, and added an XXX comment to the method I wrote instead.
Comment 10 Matt Chapman CLA 2005-08-23 06:47:23 EDT
It has turned out that registering .aj as a java extension causes too many other
problems, including bugs 107005, 107604, 107634, and 107636, so it looks like
we'll have to undo that. The change causes JDT to create CompilationUnits for
.aj files, which means our support for creating AJCompilationUnits doesn't work
fully. Undoing the change will of course mean this nasty String index out of
range problem will come back, which we'll have to re-investigate. Pursuing a JDT
fix might be a better option.
Comment 11 Helen Beeken CLA 2005-08-24 05:24:36 EDT
*** Bug 92482 has been marked as a duplicate of this bug. ***
Comment 12 Matt Chapman CLA 2005-08-26 06:14:32 EDT
The earlier change has now been backed out, so this problem is unfortunately
back with us. The proper fix is to JDT, as in bug 107735. The fix has been
applied in the Eclipse 3.2 line, and it will hopefully be backported to 3.1.1.
Comment 13 Matt Chapman CLA 2005-09-02 11:04:10 EDT
The JDT fix has now made it into the maintenance line, so will be included in
Eclipse 3.1.1.

Until then, if you're *really* hampered by this, you could patch your eclipse
installation by replacing your JDT Core jar file (under eclipse/plugins) with
this patched version:

http://download.eclipse.org/technology/ajdt/bug98547/org.eclipse.jdt.core_3.1.0.jar