Community
Participate
Working Groups
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)
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
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!
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?
*** Bug 89326 has been marked as a duplicate of this bug. ***
*** Bug 92759 has been marked as a duplicate of this bug. ***
*** Bug 91395 has been marked as a duplicate of this bug. ***
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)
*** Bug 106164 has been marked as a duplicate of this bug. ***
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.
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.
*** Bug 92482 has been marked as a duplicate of this bug. ***
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.
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