Bug 14642 - StringIndexOutOfBoundsException when attempting to view some classes
Summary: StringIndexOutOfBoundsException when attempting to view some classes
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows NT
: P3 major (vote)
Target Milestone: 2.0 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-25 12:43 EDT by William Whittle CLA
Modified: 2002-04-26 14:31 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description William Whittle CLA 2002-04-25 12:43:27 EDT
Sometimes, when attempting to open a source file via the packages view or via 
the step into option while debugging, an internal error occurs. Eclipse 
consistently gives the error when attempting to open that file. Other files 
open normally. I'm using build 20020416 (M5) with JDK 1.3:

  java version "1.3.1_01"
  Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
  Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)

The stack trace from Eclipse:
java.lang.StringIndexOutOfBoundsException: String index out of range: 21
	at java.lang.String.charAt(String.java:516)
	at org.eclipse.jdt.internal.core.ClassFile.getType(ClassFile.java:290)
	at org.eclipse.jdt.internal.core.NameLookup.seekTypesInBinaryPackage
(NameLookup.java:593)
	at org.eclipse.jdt.internal.core.NameLookup.seekTypes
(NameLookup.java:546)
	at org.eclipse.jdt.internal.core.NameLookup.findType
(NameLookup.java:431)
	at org.eclipse.jdt.internal.core.NameLookup.findType
(NameLookup.java:359)
	at org.eclipse.jdt.internal.core.SearchableEnvironment.find
(SearchableEnvironment.java:49)
	at org.eclipse.jdt.internal.core.SearchableEnvironment.findType
(SearchableEnvironment.java:128)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType
(LookupEnvironment.java:85)
	at 
org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage
(PackageBinding.java:166)
	at 
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findOnDemandImport
(CompilationUnitScope.java:272)
	at 
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findSingleTypeImpo
rt(CompilationUnitScope.java:327)
	at 
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInImports
(CompilationUnitScope.java:222)
	at 
org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInTypes
(CompilationUnitScope.java:258)
	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:559)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.resolve
(CompilationUnitProblemFinder.java:151)
	at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure
(CompilationUnit.java:80)
	at org.eclipse.jdt.internal.core.Openable.openWhenClosed
(Openable.java:394)
	at org.eclipse.jdt.internal.core.WorkingCopy.openWhenClosed
(WorkingCopy.java:319)
	at org.eclipse.jdt.internal.core.Openable.open(Openable.java:330)
	at org.eclipse.jdt.internal.core.WorkingCopy.open(WorkingCopy.java:281)
	at org.eclipse.jdt.internal.core.CompilationUnit.getWorkingCopy
(CompilationUnit.java:574)
	at 
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.createEle
mentInfo(CompilationUnitDocumentProvider.java:428)
	at org.eclipse.ui.texteditor.AbstractDocumentProvider.connect
(AbstractDocumentProvider.java:247)
	at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput
(AbstractTextEditor.java:1503)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.doSetInput
(JavaEditor.java:479)
	at 
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.doSetInput
(CompilationUnitEditor.java:932)
	at org.eclipse.ui.texteditor.AbstractTextEditor.init
(AbstractTextEditor.java:1146)
	at org.eclipse.ui.internal.EditorManager.createSite
(EditorManager.java:485)
	at org.eclipse.ui.internal.EditorManager.access$1
(EditorManager.java:483)
	at org.eclipse.ui.internal.EditorManager$2.run(EditorManager.java:467)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:56)
	at org.eclipse.ui.internal.EditorManager.openInternalEditor
(EditorManager.java:460)
	at org.eclipse.ui.internal.EditorManager.openInternalEditor
(EditorManager.java:529)
	at org.eclipse.ui.internal.EditorManager.openEditor
(EditorManager.java:361)
	at org.eclipse.ui.internal.EditorManager.openEditor
(EditorManager.java:264)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor
(WorkbenchPage.java:1559)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor
(WorkbenchPage.java:1523)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor
(EditorUtility.java:130)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor
(EditorUtility.java:102)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor
(EditorUtility.java:89)
	at org.eclipse.jdt.internal.ui.packageview.OpenResourceAction.run
(OpenResourceAction.java:51)
	at 
org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.handleDoubleClick
(PackageExplorerPart.java:736)
	at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.access$1
(PackageExplorerPart.java:731)
	at 
org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4.doubleClick
(PackageExplorerPart.java:358)
	at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick
(StructuredViewer.java:286)
	at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect
(StructuredViewer.java:444)
	at org.eclipse.jface.viewers.AbstractTreeViewer$1.widgetDefaultSelected
(AbstractTreeViewer.java:627)
	at org.eclipse.swt.widgets.TypedListener.handleEvent
(TypedListener.java:92)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:75)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:637)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1412)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1208)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:836)
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:819)
	at org.eclipse.core.internal.boot.InternalBootLoader.run
(InternalBootLoader.java:777)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:319)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:190)
	at org.eclipse.core.launcher.Main.run(Main.java:549)
	at org.eclipse.core.launcher.Main.main(Main.java:390)
Comment 1 Olivier Thomann CLA 2002-04-25 13:50:13 EDT
Could you please provide a test case? A file that failed all the time. I need to be able to reproduce 
it, if you want us to fix it.
Thanks for the report.
Comment 2 William Whittle CLA 2002-04-26 06:22:02 EDT
I can't give you a file that makes it fail I'm afraid as it's proprietry code. 
But it is conststently failing on the same file, so it's not happening at 
random.

What I have noticed is that if I removed all the import statements from the 
file, then Eclipse would load it. Then, as I added each import statement using 
the 'Add Import' feature, then every now and then it would give the exception. 
The same would happen if I used the 'Organise Imports' feature.

I hope that helps. 
Comment 3 Olivier Thomann CLA 2002-04-26 10:27:45 EDT
Could you please tell me if you use names containing '$'? Could you double-check if you can 
reproduce the problem by using the same imports in another class? If yes, then could you please 
give me the corresponding imports? We need to isolate a test case. Without it, it is almost 
impossible to reproduce the problem, and therefore to fix it.
Thanks for your help.
Comment 4 William Whittle CLA 2002-04-26 10:55:28 EDT
In the classes that I've tried to load there are no $ characters in any names. 
But, we do have some classes that end with a $ character that are in Jar files 
in the classpath for the project. So I guess it could be that these are causing 
it problems what with the compiler using $ for enclosed class names. I've tried 
those import statememnts in a new class and that class fails to load now too. 
But none of those imports contain a $.

I've noticed that Eclipse had problems in the package view showing the package 
outline if the package has these classes that end in $ in it.

I've tried to create a new project containing classes that end in $ and Eclipse 
is OK with that (if the classes are written outside of Eclipse first); they 
load in fine.
Comment 5 Olivier Thomann CLA 2002-04-26 11:02:22 EDT
Ok, I think I can understand what is going on. I will try to build a test case 
that fails in the same way. My guess is that as soon as you have a class name 
ending with a '$' in a jar file in your classpath, Eclipse fails with the same 
exception. Is it possible to get your jar or is it proprietary code?
Comment 6 William Whittle CLA 2002-04-26 11:10:38 EDT
Yes, that seems to be what's happening. The Jar file is, I'm afraid, 
proprietry. When expanding a package in it in the packages view the display 
looks like:
 + [+] package.name
    +-[#] ClassNameOne
    +-[#] ClassNameTwo
    |-

There should be lots more classes under ClassNameTwo.
Comment 7 Olivier Thomann CLA 2002-04-26 11:14:49 EDT
I reproduced the problem and it comes from the fact that the '$' sign is not expected to be at the end 
of the class name. Creating a jar containing such a class blew up Eclipse when I tried to create a 
class extending this class after adding the jar in the classpath of the project.
Thanks for your 
help. It should not be long to fix the problem.
Comment 8 Olivier Thomann CLA 2002-04-26 14:31:11 EDT
Regression tests added.
Fixed and released in HEAD.
Comment 9 Olivier Thomann CLA 2002-04-26 14:31:20 EDT
Fixed.