Community
Participate
Working Groups
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)
We do not support variable decls in AST evaluations - but we should handle it gracefully.
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.
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?
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.
In latest 3.0 code, the setModifiers(...) method doesn't throw an IllegalArgumentException anymore and the node is not tagged as MALFORMED.