Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 204257

Summary: [formatter] Problems to write \u inside <pre> in JavaDOC, when using the formatter
Product: [Eclipse Project] JDT Reporter: Mauro Molinari <mauromol>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, jerome_lanneluc, markus.kell.r, Olivier_Thomann, srikanth_sankaran
Version: 3.3   
Target Milestone: 3.5.1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Mauro Molinari CLA 2007-09-21 06:51:45 EDT
Build ID: I20070625-1500

Steps To Reproduce:
1. Create the following:

public class A
{
  /**
   * <pre>
   *   \u
   * </pre>
   */
  public void a()
  {
  }
}

2. Eclipse gives an "Invalid unicode" error on the line with \u

3. Replace "\" with &#92; to remove the error:

public class A
{
  /**
   * <pre>
   *   &#92;u
   * </pre>
   */
  public void a()
  {
  }
}

4. Invoke the code formatter

OBSERVED BEHAVIOUR:
&#92; is replaced with \, and the error is given again.

EXPECTED BEHAVIOUR:
I don't really understand why the formatter should replace &#92; with \, while other characters (like &) are conversely replaced by the corresponding HTML entity.
I would like to be able to write \u inside a <pre> and safely use the code formatter.
Comment 1 Olivier Thomann CLA 2007-09-21 08:43:05 EDT
You should disable the option to format code snippet inside javadoc comment.
\u is indeed an invalid unicode character.
Comment 2 Jerome Lanneluc CLA 2007-09-21 12:27:58 EDT
I think the point is that we should not replace "&#92;" with "\".
Comment 3 Olivier Thomann CLA 2007-09-21 14:49:25 EDT
&#92; is replaced by '\' in order to be able to process the source.
I think one way to fix it would be to replace &#92; with "\\" to prevent unicode substitution.
Comment 4 Mauro Molinari CLA 2007-09-24 03:00:32 EDT
I'm not sure, but if you substitute \u with \\u I think JavaDOC will display "\\u", not "\u"...

IMHO, I also think that if I explicitly write &#92;, it should be because I don't want to write a line of code but something else.

Mauro.
Comment 5 Olivier Thomann CLA 2007-09-24 12:37:00 EDT
What I meant is that on code snippet formatting inside javadoc, we do:
- conversion from htm to java
- formatting of the code snippet
- conversion from java to html

On the first conversion, replacing &#92; with "\\" should prevent to unicode substitution for the second step and the last conversion would convert again "\\" to &#92;.

This is an idea. I haven't actually tried if this would fix this issue.
Comment 6 Eric Jodet CLA 2008-06-04 05:42:16 EDT
transfer to frederic as it's a formatter bug
Comment 7 Markus Keller CLA 2009-06-08 09:56:37 EDT

*** This bug has been marked as a duplicate of bug 196308 ***
Comment 8 Ayushman Jain CLA 2009-08-03 06:39:35 EDT
Verified for 3.6M1 using build I20090802-2000
Comment 9 Srikanth Sankaran CLA 2009-08-04 00:29:44 EDT
Should not have been set as VERIFIED because target is not 3.6M1 but 3.5.
Comment 10 Srikanth Sankaran CLA 2009-08-04 00:31:16 EDT
Restoring duplicate status.

*** This bug has been marked as a duplicate of bug 196308 ***
Comment 11 Kent Johnson CLA 2009-08-27 12:06:42 EDT
Verified for 3.5.1 using build M20090826-1100