Bug 82389 - ArrayIndexOutOfBoundsException if empty file
Summary: ArrayIndexOutOfBoundsException if empty file
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0M1   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 1.5.1   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-07 11:52 EST by Chris Lamb CLA
Modified: 2006-03-10 10:54 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lamb CLA 2005-01-07 11:52:59 EST
On eclipse 3.0.1, using 1.2 AJDT installed via the Eclipse updating/installing 
system, if I have an empty file in a package (i.e. no package header), the 
compiler will fail with an internal compilation error indicating an error on 
the previous (well-formed) file. 
 
I'm not sure if this is an aspectj or ajdt issue, but I thought I'd start 
here.
Comment 1 Matt Chapman CLA 2005-01-17 10:09:20 EST
I haven't managed to reproduce this. What is the name of your empty file, and is
it completely empty (i.e. 0 bytes)? And can you paste the compiler error in
here? (It should still be in your workspace/.metadata/.log file)
Comment 2 Matt Chapman CLA 2005-03-23 09:18:43 EST
No response, so closing for now, as I can't progress this without the above
info. Please reopen if/when you can provide this info.
Comment 3 Chris Lamb CLA 2005-03-25 16:47:10 EST
sorry it took so long to get back on this.  I've recreated this in eclipse 3.1 with:

AJDT:
Version: 1.2.0
Build id: 20041214165937
AspectJ version: 1.5.0M1

The error is:

Severity	Description	Resource	In Folder	Location	Creation Time
2	Internal compiler error
java.lang.ArrayIndexOutOfBoundsException: 0
	at
org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsCharArray(Util.java:359)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(Util.java:178)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.batch.CompilationUnit.getContents(CompilationUnit.java:57)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.parser.TheOriginalJDTParserClass.parse(TheOriginalJDTParserClass.java:5722)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.parser.TheOriginalJDTParserClass.parse(TheOriginalJDTParserClass.java:5704)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.parser.TheOriginalJDTParserClass.dietParse(TheOriginalJDTParserClass.java:4422)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:319)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:348)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:682)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:168)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:102)
	at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:122)
	at
org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:165)
	Graph.java	MaterialsWISDM/src/gov/sandia/emc/matwisdm/datawrappers		March 25,
2005 2:38:30 PM

The name of the empty file is GraphDecoder.java; the file this fails on is
Graph.java (which is immediately before the empty file in package explorer)
Comment 4 Chris Lamb CLA 2005-03-25 16:47:53 EST
oh, and GraphDecoder.java is indeed 0 bytes.
Comment 5 Matt Chapman CLA 2005-07-13 11:04:16 EDT
The expection is coming from the compiler, so passing over to AspectJ
Comment 6 Helen Beeken CLA 2005-12-09 10:16:52 EST
This bug may already be fixed......

This bug was raised and reproduced by Chris using AspectJ 1.5.0M1 which was dated Friday 10th December 2004. At this point the compiler contained Eclipse 3.0 final JDT core. The next update of the compiler took place on 6th January 2005 and was an upgrade to the Eclipse 3.1v530a compiler which in particular included an update to the failing method:

org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsCharArray(Util.java:359)

with

if ("UTF-8".equals(encoding)) { 
....

changed to 

if (length > 0 && "UTF-8".equals(encoding)) {
....


This change was made by JDT in response to bug 70598 which was raised against jdt core 3.0 and reports exactly the exception as is reported here (obviously, except for the prefix "org.aspectj").

I'm not sure how to force UTF-8 encoding so have been unable to verify this.
Comment 7 Helen Beeken CLA 2006-03-10 10:54:16 EST
Closing this bug as fixed as per comment #6.