JDK-4957542 : REGRESSION: java.util.regex.Pattern sometimes returns incorrect result.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2003-11-20
  • Updated: 2003-11-20
  • Resolved: 2003-11-20
Related Reports
Duplicate :  
Description

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) 
======================================================================

Comments
EVALUATION Submitter is correct. This has already been fixed under bug number 4872664. ###@###.### 2003-11-20
20-11-2003