Bug 70598 - [Encoding] ArrayIndexOutOfBoundsException while testing BOM on *.txt files
Summary: [Encoding] ArrayIndexOutOfBoundsException while testing BOM on *.txt files
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0.1   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-22 01:29 EDT by Genady Beryozkin CLA
Modified: 2004-09-06 10:30 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 Genady Beryozkin CLA 2004-07-22 01:29:25 EDT
I've got a user who reported me the following error in the log file.
I think this may be a bug in the JDT code.

Here is the stack trace:

!SESSION Jul 19, 2004 08:10:00.991 --------------------------------------------
-
eclipse.buildId=I200406251208
java.version=1.4.2_05
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US

!ENTRY org.eclipse.core.runtime 4 2 Jul 19, 2004 08:10:00.991
!MESSAGE Problems occurred when invoking code from plug-
in: "org.eclipse.core.runtime".
!STACK 0
java.lang.ArrayIndexOutOfBoundsException: 0
	at 
org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsCharArray
(Util.java:359)
	at org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent
(Util.java:178)
	at org.eclipse.jdt.internal.core.BasicCompilationUnit.getContents
(BasicCompilationUnit.java:105)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse
(Parser.java:5685)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse
(Parser.java:5667)
	at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse
(Parser.java:4393)
	at org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver.resolve
(HierarchyResolver.java:621)
	at 
org.eclipse.jdt.internal.core.hierarchy.RegionBasedHierarchyBuilder.createTypeH
ierarchyBasedOnRegion(RegionBasedHierarchyBuilder.java:82)
	at 
org.eclipse.jdt.internal.core.hierarchy.RegionBasedHierarchyBuilder.build
(RegionBasedHierarchyBuilder.java:56)
	at 
org.eclipse.jdt.internal.core.hierarchy.RegionBasedTypeHierarchy.compute
(RegionBasedTypeHierarchy.java:72)
	at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.refresh
(TypeHierarchy.java:1234)
	at 
org.eclipse.jdt.internal.core.CreateTypeHierarchyOperation.executeOperation
(CreateTypeHierarchyOperation.java:90)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run
(JavaModelOperation.java:700)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation
(JavaModelOperation.java:739)
	at org.eclipse.jdt.internal.core.JavaProject.newTypeHierarchy
(JavaProject.java:2289)
	at org.eclipse.jdt.internal.core.JavaProject.newTypeHierarchy
(JavaProject.java:2267)
	at net.genady.rmi.ProjectUtils.findRemoteClasses(ProjectUtils.java:137)
	at net.genady.rmi.ProjectUtils.findRemoteClasses(ProjectUtils.java:90)
	at net.genady.rmi.RMIBuilder.build(RMIBuilder.java:75)
	at org.eclipse.core.internal.events.BuildManager$2.run
(BuildManager.java:564)
	at org.eclipse.core.internal.runtime.InternalPlatform.run
(InternalPlatform.java:615)
	at org.eclipse.core.runtime.Platform.run(Platform.java:747)
	at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:157)
	at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:249)
	at org.eclipse.core.internal.events.BuildManager.build
(BuildManager.java:346)
	at org.eclipse.core.internal.resources.Project.build(Project.java:81)
	at net.genady.rmi.actions.RMIBuildAction$1.run(RMIBuildAction.java:46)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread
(ModalContext.java:303)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:253)
	at org.eclipse.jface.window.ApplicationWindow$1.run
(ApplicationWindow.java:588)
	at org.eclipse.swt.custom.BusyIndicator.showWhile
(BusyIndicator.java:69)
	at org.eclipse.jface.window.ApplicationWindow.run
(ApplicationWindow.java:585)
	at org.eclipse.ui.internal.WorkbenchWindow.run
(WorkbenchWindow.java:1653)
	at net.genady.rmi.actions.RMIBuildAction.run(RMIBuildAction.java:57)
	at org.eclipse.ui.internal.PluginAction.runWithEvent
(PluginAction.java:276)
	at 
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection
(ActionContributionItem.java:915)
	at org.eclipse.jface.action.ActionContributionItem.access$2
(ActionContributionItem.java:866)
	at org.eclipse.jface.action.ActionContributionItem$7.handleEvent
(ActionContributionItem.java:785)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2772)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2431)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1377)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1348)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench
(Workbench.java:254)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141)
	at org.eclipse.ui.internal.ide.IDEApplication.run
(IDEApplication.java:96)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run
(PlatformActivator.java:335)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:273)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:129)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:183)
	at org.eclipse.core.launcher.Main.run(Main.java:644)
	at org.eclipse.core.launcher.Main.main(Main.java:628)

My own code that is part of the stack trace creates a type hierarchy 
of "java.rmi.Remote" in the source region that contains all source types in 
the project.
Comment 1 Frederic Fusier CLA 2004-07-22 05:36:29 EDT
Seems to be a side effect of bug 58859 fix.
I'll fix it...
Comment 2 Genady Beryozkin CLA 2004-07-22 08:00:12 EDT
Is there any workaround that I can suggest to my user?
Comment 3 Frederic Fusier CLA 2004-07-22 09:35:52 EDT
This exception happens while trying to read content of an empty file using
"UTF-8" encoding.
First workaround: if "UTF-8" encoding is not absolutely necessary then try to
use another one.
Second workaround: if you can identify empty source files in the hierarchy
you're trying to resolve and if they are not necessary, then remove them...
Comment 4 Frederic Fusier CLA 2004-07-22 12:21:21 EDT
Fixed and released in R3_0_maintenance stream.

BOM test is now skipped when file length is 0.

[jdt-core-length]
Change done in method getInputStreamAsCharArray(InputStream,int,String) of
org.eclipse.jdt.internal.compiler.util.Util class.
Test case added in EncodingTests
Comment 5 Frederic Fusier CLA 2004-07-26 06:36:10 EDT
Released in HEAD for 3.1
Comment 6 David Audel CLA 2004-09-06 10:30:32 EDT
Verified for 3.0.1 RC1