Uploaded image for project: 'Clover'
  1. Clover
  2. CLOV-1835

Unicode 0x200B (zero-width whitespace) causes instrumentation failure

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • Low
    • open-source
    • None
    • Instrumentation
    • None
    • Severity 3 - Minor

    Description

      JDK 6 implements Unicode 4.0. In this version of Unicode, the zero-width whitespace character (0x200B) is being treated as a whitespace.

      JDK 7 implements Unicode 6.0. In this version of Unicode, the zero-width whitespace has been reclassified to the 'format character' group (other characters in this group are, for example, left-/right- text direction markers).

      Thus, Java compiler in JDK 6 allows to use 0x200B as a normal whitespace character, e.g. separating symbols.

      The Java compiler since JDK 7 silently ignores the 0x200B, which means that it cannot be used to separate symbols anymore. However you can put this character virtually in any place, e.g.:

      void this<200B>Is<200B>MyMethod();
      

      Clover fails on parsing the 200B character:

      Xyz.java:287:90:unexpected char: 0x200B
      at com.atlassian.clover.instr.java.Instrumenter.instrument(Instrumenter.java:166)
      at com.atlassian.clover.CloverInstr.execute(CloverInstr.java:76)
      at com.atlassian.clover.CloverInstr.mainImpl(CloverInstr.java:54)
      at ...
      

      Planned fix:

      • Ignore 200B characters in Java 7+. Treat 200B character as space in Java 6.
      • Question: Shall it be based on source level setting or the JDK detected?
      • Question: which other control characters needs to be ignored by Clover?
      • Question: which other whitespace characters (other than space, \t, \n, \r) shall be recognized by Clover parser?

      Workaround:

      Remove all 200B character occurrences from the source code.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mparfianowicz Marek Parfianowicz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: