Bug 13233 - IllegalArgumentException on variable declaration in evaluation
Summary: IllegalArgumentException on variable declaration in evaluation
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P2 normal (vote)
Target Milestone: 2.0 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-10 08:41 EDT by Adam Kiezun CLA
Modified: 2004-02-23 16:33 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 Adam Kiezun CLA 2002-04-10 08:41:17 EDT
20020409
1. junit 3.7
2. MoneyTest
3. breakpoint in line 33
4. debug
5. select line 12: 	private MoneyBag fMB2;
6. display

java.lang.IllegalArgumentException
	at org.eclipse.jdt.core.dom.VariableDeclarationStatement.setModifiers
(VariableDeclarationStatement.java:134)
	at 
org.eclipse.jdt.core.dom.ASTConverter.convertToVariableDeclarationStatement
(ASTConverter.java:2382)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java
(Compiled Code))
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java
(Compiled Code))
	at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations
(ASTConverter.java:215)
	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:330)
	at 
org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.getCompiledEx
pression(ASTEvaluationEngine.java:159)
	at 
org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.evaluate
(ASTEvaluationEngine.java:59)
	at org.eclipse.jdt.internal.debug.ui.actions.EvaluateAction.run
(EvaluateAction.java:225)
	at org.eclipse.jdt.internal.debug.ui.actions.DisplayAction.run
(DisplayAction.java:122)
	at org.eclipse.jdt.internal.debug.ui.actions.EvaluateAction.run
(EvaluateAction.java:503)
	at org.eclipse.ui.internal.PluginAction.runWithEvent
(PluginAction.java:204)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection
(ActionContributionItem.java:407)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent
(ActionContributionItem.java(Compiled Code))
	at 
org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent
(ActionContributionItem.java(Compiled Code))
	at 
org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent
(ActionContributionItem.java(Compiled Code))
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.runDeferredEvents(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.Main.main(Main.java:390)
Comment 1 Darin Wright CLA 2002-04-10 19:27:35 EDT
We do not support variable decls in AST evaluations - but we should handle it 
gracefully.
Comment 2 Jared Burns CLA 2002-04-12 11:58:47 EDT
Simpler test case:

public class FieldDeclaration {
  public static void main(String[] args) {
    System.out.println("Test"); // Breakpoint here
  }
}

Debug to the above code and display the text "private int x;" in the display
view. We generate the following code and pass it to AST.parseCompilationUnit.

public class FieldDeclaration{
static void ___run(java.lang.String[] args) throws Throwable {
private int x;
}
public static void main (String[] args){
}
}

This is not valid code, but it shouldn't blow up. It should return an error message.

Reassigning to JDT Core.
Comment 3 Olivier Thomann CLA 2002-04-12 14:41:18 EDT
Then which modifiers do you expect for the variable 'x'? The method 
VariableDeclarationStatement.setModifiers ensures that only final is a valid modifier for a 
local variable.
What do you suggest to fix this problem?
Comment 4 Olivier Thomann CLA 2002-04-15 12:15:18 EDT
Wew will tag the variable declaration statement node to be MALFORMED and the compilation unit 
will contain an error message in its message list.
Fixed and released in HEAD.
Comment 5 Olivier Thomann CLA 2004-02-23 16:33:30 EST
In latest 3.0 code, the setModifiers(...) method doesn't throw an
IllegalArgumentException anymore and the node is not tagged as MALFORMED.