Community
Participate
Working Groups
Using I20080606-0100. On Ganymede RC3 full source workspace, a StringIndexOutOfBoundException occurs while formatting CU org/eclipse/emf/common/util/URI.Java: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.<init>(String.java:208) at org.eclipse.jdt.internal.formatter.Scribe.printCodeSnippet(Scribe.java:1680) at org.eclipse.jdt.internal.formatter.Scribe.printJavadocHtmlTag(Scribe.java:3092) at org.eclipse.jdt.internal.formatter.Scribe.printJavadocHtmlTag(Scribe.java:3001) at org.eclipse.jdt.internal.formatter.Scribe.printJavadocBlock(Scribe.java:2346) at org.eclipse.jdt.internal.formatter.Scribe.printJavadocComment(Scribe.java:2694) at org.eclipse.jdt.internal.formatter.Scribe.printComment(Scribe.java:1873) at org.eclipse.jdt.internal.formatter.Scribe.printComment(Scribe.java:1769) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:4107) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:209) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.format(CodeFormatterVisitor.java:542) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.formatTypeMembers(CodeFormatterVisitor.java:2016) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.format(CodeFormatterVisitor.java:1170) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:5179) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1198) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:3056) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:656) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.format(CodeFormatterVisitor.java:799) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.formatCompilationUnit(DefaultCodeFormatter.java:331) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:203) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:186) ...
The problem exists since 3.4M7 when the new comment formatter has been activated. The javadoc text end is not properly initialized in the commentParse() method of AbstracCommentParser...
Created attachment 104144 [details] Small test case to reproduce the problem
Do you have a similar configuration than bug 199392 (i.e. a project which name ends with '.jar')? Would it be possible that you give it a try with 3.4RC3 on your workspace and let me know if you still get the problem? Thanks in advance
(In reply to comment #3) Ooops wrong bug, forget this comment...
Created attachment 104887 [details] Proposed patch The StringIndexOutOfBoundException was initially due to the fact that the javadocTextEnd field was not properly reset at the beginning of commentParse() method in AbstractCommentParser. However, only fixing this was not really appropriate as it exhibits the real origin of the problem: the text end position was sometimes incorrect while pushing the text... So, in this patch, the position of the end of text has been reviewed and fixed everywhere it's used... Note that although the change is made in the root of hierarchy of comment parsers it does only affect text position/length and does not represent a too risky change.
Created attachment 105505 [details] Updated patch Same patch than previous one but without unrelated test classes changes...
Released for 3.5M1 in HEAD stream.
+1 to backport to 3.4.1
Released for 3.4.1
Verified for 3.5M1 using I20080805-1307
Reopen to close as RESOLVED/FIXED. Will be closed as VERIFIED during 3.4.1 verification pass.
Fixed.
Verified for 3.4.1 using M20080827-2000