Community
Participate
Working Groups
public class Test{ public static void main(String[] args) { assert(true); BigDecimal f = null; } } if i have an assert in my source-code the "Organize imports" functionality does not work anymore. If i comment-out it does. System: java.runtime.version=1.4.2-beta-b19 os.name=Windows XP Version: 2.1.0 Build id: 200303272130 and 200306051737 i tested
Can't reproduce this. My guess is that you set the compiler compliance settings (Preferences > Java > Compiler > Compliance) to 1.4 including the source compatibility to 1.4. Note that if you have this setting, you can not use assert(true) anymore as assert is a keyword in 1.4 source mode.
Seems to be a AST problem: Set the source compliance mode to 1.4 and create an AST of the code: java.lang.IllegalArgumentException at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:1469) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1799) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1709) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:720) at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations (ASTConverter.java:243) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:182) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:80) at org.eclipse.jdt.core.dom.AST.parseCompilationUnit(AST.java:267) at org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation.<init> (OrganizeImportsOperation.java:458) at org.eclipse.jdt.internal.corext.codemanipulation.OrganizeImportsOperation.<init> (OrganizeImportsOperation.java:462) at org.eclipse.jdt.ui.actions.OrganizeImportsAction.run (OrganizeImportsAction.java:406) at org.eclipse.jdt.ui.actions.OrganizeImportsAction.run (OrganizeImportsAction.java:248) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:193) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:169) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.ui.internal.WWinKeyBindingService.pressed (WWinKeyBindingService.java:214) at org.eclipse.ui.internal.WWinKeyBindingService$5.widgetSelected (WWinKeyBindingService.java:332) at org.eclipse.ui.internal.AcceleratorMenu$2.handleEvent (AcceleratorMenu.java:68) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:848) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2036) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1742) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1399) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1382) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583)
What are your settings? Do you use source 1.4 or 1.3? In 1.4, you should have a compile error. I will investigate.
Fixed and released in HEAD contents. Regression tests added.
Forget about it. assert(true); is seen as a assert statement with a parenthesized expression. So there is no compile error and I fixed it.
Verified.
*** Bug 42647 has been marked as a duplicate of this bug. ***
I have the fix ready to be backported to 2.1. maintenance stream.
*** Bug 45340 has been marked as a duplicate of this bug. ***
*** Bug 45529 has been marked as a duplicate of this bug. ***
Backported to 2.1.3.
Verified for 2.1.3 with build I200402251535.
Build was M200402251535 and not I200402251535....
*** Bug 72458 has been marked as a duplicate of this bug. ***