Bug 79395 - IllegalArgumentException in CompilationUnitResolver.parse (line 323)
Summary: IllegalArgumentException in CompilationUnitResolver.parse (line 323)
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-24 10:41 EST by Douglas Pollock CLA
Modified: 2004-12-15 11:56 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Douglas Pollock CLA 2004-11-24 10:41:12 EST
I200411170800, GTK+ 2.4.9, IBM VM 1.4.2 
 
I'm not sure, but I believe I was replacing a file with code from head.  I then 
got this exception in the log. 
 
 
!ENTRY org.eclipse.core.runtime 4 2 2004-11-22 11:41:18.31 
!MESSAGE An internal error occurred during: "Override indicator installation 
job 
". 
!STACK 0 
java.lang.IllegalArgumentException 
        at 
org.eclipse.jdt.core.dom.CompilationUnitResolver.parse(CompilationUni 
tResolver.java:323) 
        at 
org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:7 
37) 
        at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:574) 
        at 
org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvi 
der.java:565) 
        at 
org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider 
.java:494) 
        at 
org.eclipse.jdt.internal.ui.javaeditor.JavaEditor$8.run(JavaEditor.ja 
va:4023) 
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:66)
Comment 1 Olivier Thomann CLA 2004-11-24 11:47:42 EST
This is what happened if the source unit is null.
Move to JDT/UI for investigation. Need to find out how the unit can be null.
Comment 2 Dani Megert CLA 2004-11-25 10:49:36 EST
It's not the source which is null but the element that no longer exists. If
there's no source an IllegalStateException is correctly thrown. Reading the API
for createAST(...) I expect the same to happened when the element no longer exists:

	 * @exception IllegalStateException if the settings provided
	 * are insufficient, contradictory, or otherwise unsupported

Another solution would be to spec to throw a JavaModelException.isDoesNotExist()
but throwing an IllegalArgumentException seems not appropriate.
Comment 3 Olivier Thomann CLA 2004-11-25 16:32:05 EST
Found a path that led to a sourceUnit equals to null.
I added a check that throws a IllegalStateException if the sourceUnit is null
(the element doesn't exist anymore or if a JavaModelException has be thrown
trying to get the source).
Could not build a reproducable test case.
Fixed and released in HEAD.
Comment 4 Dani Megert CLA 2004-11-26 04:12:35 EST
Sometimes we compute the AST in a background job. A possible test could be to
suspend such a job (e.g. by putting a breakpoint into ASTProvider.createsAST)
then delete the CU and resume the job which creates the AST.
Comment 5 Jerome Lanneluc CLA 2004-12-15 11:56:02 EST
The case where the source unit could be null is attempting to create an AST on
an IClassFile that doesn't exist. 

Verified (in I20041214-2000) that ASTParser#internalCreateAST(IProgressMonitor)
correctly throws an IllegalStateException if the IClassFile doesn't exist.