Bug 300162 - [formatter] Java source formatting of a section or a project failes when /*"*/ is inside a string concat
Summary: [formatter] Java source formatting of a section or a project failes when /*"*...
Status: VERIFIED DUPLICATE of bug 294529
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.6 M4   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-20 06:18 EST by Ivan Motsch CLA
Modified: 2010-03-08 05:51 EST (History)
4 users (show)

See Also:


Attachments
in the test Test.java file try context menu source->Format (4.47 KB, application/octet-stream)
2010-01-20 07:46 EST, Ivan Motsch CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Motsch CLA 2010-01-20 06:18:57 EST
Build Identifier: M20090917-0800

When a java file contains the line:

    String s="X"+/*"*/"Y";

then this section cannot be formatted with shift-control-F or menu source-Format.
Even worse: when using Menu source->Format on multiple projects or working set this small line completely cancels the formatting action. Therefore the bug is not just a minor one but has massive impact on the formatting feature which cannot be reasonably used anymore when having such sections in the source code.

The code snippet that causes this effect can of course be written differentlly, but anyway the code snippet is valid java code, compiles correctly and conforms to the java syntax rules.

The exception log follows:
eclipse.buildId=M20090917-0800
java.version=1.6.0_10
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_CH
Command-line arguments:  -os win32 -ws win32 -arch x86 -console -consoleLog -debug -clean


Error
Wed Jan 20 12:04:04 CET 2010
assertion failed: 

org.eclipse.core.runtime.AssertionFailedException: assertion failed: 
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96)
	at org.eclipse.text.edits.TextEdit.<init>(TextEdit.java:148)
	at org.eclipse.text.edits.ReplaceEdit.<init>(ReplaceEdit.java:36)
	at org.eclipse.jdt.internal.formatter.Scribe.getRootEdit(Scribe.java:1010)
	at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.format(CodeFormatterVisitor.java:812)
	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.formatCompilationUnit(DefaultCodeFormatter.java:333)
	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:205)
	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:188)
	at org.eclipse.jdt.internal.corext.util.CodeFormatterUtil.reformat(CodeFormatterUtil.java:288)
	at org.eclipse.jdt.internal.ui.text.java.JavaFormattingStrategy.format(JavaFormattingStrategy.java:65)
	at org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatMaster(MultiPassContentFormatter.java:193)
	at org.eclipse.jface.text.formatter.MultiPassContentFormatter.format(MultiPassContentFormatter.java:135)
	at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:882)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1450)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOperation(JavaSourceViewer.java:186)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:199)
	at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:131)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java:129)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
	at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:470)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:824)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:880)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:569)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:510)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:125)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1191)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1040)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1368)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4053)
	at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:346)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3946)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4589)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2410)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3471)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	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:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)



Reproducible: Always

Steps to Reproduce:
1. add the code in any java source file: String s="X"+/*"*/"Y";
2. select the section
3. type shift-control-F
Comment 1 Remy Suen CLA 2010-01-20 07:36:21 EST
I can't seem to reproduce this on I20100115-1100.

Bugs with the Java tooling goes to JDT.
Comment 2 Ivan Motsch CLA 2010-01-20 07:46:13 EST
Created attachment 156630 [details]
in the test Test.java file try context menu source->Format

This is a Plug-In project containing a source file Test.java that reporduces this bug.
Comment 3 Jose M Beleta CLA 2010-01-21 07:56:34 EST
Same thing happens when you have a comment like the following in a line:

/** ***/

More specifically the comment has to start with a slash and two contiguous asterisks as a minimum and end with at least three contiguous asterisks and the slash. At least one blank is needed and no other character must appear to cause the error.
Comment 4 Frederic Fusier CLA 2010-02-08 06:29:05 EST
As said in comment 1, the first problem described in comment 0 is fixed in 3.6 since bug 294529 has been fixed...

However, there's still an exception while formatting a simple test using the javadoc comment of comment 4 :

package format.test;

public class Test2 {
	public static void main(String[] args) {
		String s="X"+/** ***/"Y";
	}
}
Comment 5 Frederic Fusier CLA 2010-02-08 06:47:15 EST
To avoid confusion, I close this bug as duplicate of bug 294529 and I will open a new one for the comment 4 issue...

*** This bug has been marked as a duplicate of bug 294529 ***
Comment 6 Srikanth Sankaran CLA 2010-03-08 05:51:18 EST
Verified for 3.6M6 using build I20100305-101