Bug 218824 - [DOM/AST] incorrect code leads to IllegalArgumentException during AST creation
Summary: [DOM/AST] incorrect code leads to IllegalArgumentException during AST creation
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M6   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-13 12:31 EST by Olivier Thomann CLA
Modified: 2008-03-25 11:12 EDT (History)
1 user (show)

See Also:


Attachments
Proposed patch (6.53 KB, patch)
2008-03-19 05:34 EDT, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2008-02-13 12:31:46 EST
Using 3.4M5, copy/paste the following code into a java editor:

public class A {
	public void takeParam(int i) {
		// do something
	}

	void test() {
		char c = 'a';
		   public void takeParam(int i) {
			     // do something
			   }

			   void test() {
			     char c = 'a';
			    takeParam((int) c);
			   }takeParam((int) c);
	}
}

I got it by doing a paste operation at the wrong location.

On the next reconcile, an IAE is thrown.

java.lang.IllegalArgumentException
	at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:2611)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:493)
	at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:317)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2297)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1549)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2491)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:522)
	at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:178)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2676)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1260)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:256)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:894)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:653)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:540)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:533)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:474)
	at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:462)
	at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:126)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:168)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run(SelectionListenerWithASTManager.java:153)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

The problem must be due to invalid positions inside the recovery.
Comment 1 David Audel CLA 2008-03-19 05:34:47 EDT
Created attachment 92877 [details]
Proposed patch
Comment 2 David Audel CLA 2008-03-19 05:39:50 EDT
Released for 3.4M6.

Test added
  ASTConverterBugsTest#testBug218824a()

During recovery the declarationSourceEnd of a method declaration was not set when this method had no body.
Comment 3 Jerome Lanneluc CLA 2008-03-25 11:12:35 EDT
Verified for 3.4M6 using I20080325-0100