Bug 13247 - IllegalArgumentException while creating AST
Summary: IllegalArgumentException while creating AST
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-10 09:17 EDT by Martin Aeschlimann CLA
Modified: 2002-04-10 14:31 EDT (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 Martin Aeschlimann CLA 2002-04-10 09:17:02 EDT
20020409
1. create this code (project contains JUnit source)
2. do Quick Fix on 'fActiveTestDeathCount1', wait for the hover on 'Create 
field...'

-----
package junit.extensions;

import junit.framework.*;

public class ActiveTestSuite  {
	
	public void run(TestResult result) {
		fActiveTestDeathCount1= 0;    
	}
        
        public void runTest(final Test test, final TestResult result) {}
                Thread t= new Thread() {
                        public void run() {
                                try {
                                        // inlined due to limitation in VA/Java 
                                        //ActiveTestSuite.super.runTest(test, 
result);
                                        test.run(result);
                                } finally {
                                        ActiveTestSuite.this.runFinished(test);
                                }
                        }
                };
                t.start();
        }
}



java.lang.IllegalArgumentException
	at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:1034)
	at org.eclipse.jdt.core.dom.ASTConverter.convertToFieldDeclaration
(ASTConverter.java:2365)
	at 
org.eclipse.jdt.core.dom.ASTConverter.checkAndAddMultipleFieldDeclaration
(ASTConverter.java:243)
	at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations
(ASTConverter.java:209)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:155)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:73)
	at org.eclipse.jdt.core.dom.AST.parseCompilationUnit(AST.java:234)
	at 
org.eclipse.jdt.internal.ui.text.correction.NewVariableCompletionProposal.addEdi
ts(NewVariableCompletionProposal.java:186)
	at 
org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.getChange
(CUCorrectionProposal.java:56)
	at 
org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.getCompilationU
nitChange(CUCorrectionProposal.java:130)
	at 
org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.getAdditionalPr
oposalInfo(CUCorrectionProposal.java:72)
	at 
org.eclipse.jface.text.contentassist.AdditionalInfoController.computeInformation
(AdditionalInfoController.java:185)
	at 
org.eclipse.jface.text.AbstractInformationControlManager.showInformation
(AbstractInformationControlManager.java:536)
	at org.eclipse.jface.text.contentassist.AdditionalInfoController$1.run
(AdditionalInfoController.java:145)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages
(Synchronizer.java(Compiled Code))
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java
(Compiled Code))
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
(Compiled Code))
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java
(Compiled Code))
	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.UIMain.main(UIMain.java:52)
Comment 1 Olivier Thomann CLA 2002-04-10 11:50:35 EDT
Using a fresh new workspace with build 0409, I could not reproduce this exception. The field is 
created properly. However I had to change the test case for :
package 
junit.extensions;

import junit.framework.*;
public class ActiveTestSuite 
{
	public void run(TestResult result) {
fActiveTestDeathCount1= 0;   
}
       
public void 
runTest(final Test test, final TestResult result) {
Thread t= new Thread() {
public void 
run() {
try {
// inlined due to limitation in 
VA/Java
//ActiveTestSuite.super.runTest(test, result);
test.run(result);
} 
finally 
{
ActiveTestSuite.this.runFinished(test);
}
}
};
t.start();
}
}

If you can 
reproduce it in your workspace, please try again with a fresh new workspace containing only this 
test case. If it works, please provide the whole workspace. 
Comment 2 Martin Aeschlimann CLA 2002-04-10 13:08:10 EDT
I can reproduce it with an empty workspace:
Only the one CU.
There are many build errors, but the result is the same.

Send you the zipped workspace.
Comment 3 Olivier Thomann CLA 2002-04-10 14:11:12 EDT
I reproduced the bug now. Thanks for the workspace. The problem is located in the recovery in the 
Parser. The field declaration has an invalid declarationEnd and then the ASTConverter is trying 
to create a field for which the length is negative. That is not possible and explains the 
IllegalArgumentException. The ASTConverter assumes that the CompilationUnit retrieved from 
the Parser is properly initialized.
Comment 4 Olivier Thomann CLA 2002-04-10 14:21:10 EDT
Ok, I located the bug. It was in updateTypeDeclaration() in the class RecoveredType. The field 
declaration source end was set, but not the field declaration end. Setting the field declaration 
end with the same value than the field declaration source end fixed the problem.
I will release 
as soon as all tests are passed.
Comment 5 Olivier Thomann CLA 2002-04-10 14:31:01 EDT
Fixed and released in HEAD.
Comment 6 Olivier Thomann CLA 2002-04-10 14:31:38 EDT
Set the milestone.