REGRESSION: java.util.regex.Pattern sometimes returns incorrect result.

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P3
    • None
    • Affects Version/s: 1.4.2
    • Component/s: core-libs



      Name: gm110360 Date: 11/20/2003


      FULL PRODUCT VERSION :
      1.4.0 - 1.4.1_05 is OK.
      1.4.2 - 1.4.2_02 is incorrect.


      A DESCRIPTION OF THE PROBLEM :
      following regular expression matching example should return true.

      "\u3042".matches("[^a]")

      jdk1.4.0 - jdk1.4.1_05 implementation returns true.
      But, since 1.4.2, that expression returns false.

      IMHO, java.util.regex.Pattern$BitClass#match(...) has a bug.

      >> boolean match(Matcher matcher, int i, CharSequence seq) {
      >> if (i < matcher.to) {
      >> int c = seq.charAt(i);
      >> if (c > 255)
      >> return false;

      would be something like ...

      >> boolean match(Matcher matcher, int i, CharSequence seq) {
      >> if (i < matcher.to) {
      >> int c = seq.charAt(i);
      >> if (c > 255)
      >> return complementMe;



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
       % java Test





      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Test {
        static public final void main(final String [] args) {
          System.out.println("\u3042".matches("[^a]"));
        }
      }

      ---------- END SOURCE ----------

      Release Regression From : 1.4.1_05
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Incident Review ID: 226891)
      ======================================================================

            Assignee:
            Michael Mccloskey (Inactive)
            Reporter:
            Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: