This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug java/15724] New: Inconsistancy between regex match in java.util.regexp between gcj and Sun's java.


Playing around with the new java.util.regexp support I found that there is a 
pretty major difference in the pattern matching of String.matches(regexp) 
between gcj and Sun's java. 
 
It appears to me that on Sun's VM, you have to match the whole string from 
beginning to end, and on gcj, just a subset of the string. 
 
Actually I consider the way gcj is doing it to be "correct", but if you want 
consistancy with Sun's java, then it is not. 
 
Here's small program: 
 
import java.util.*; 
 
public class test { 
   
  public static void main(String[] args) { 
    String data="key=value"; 
     
    if (data.matches("^key=.*")) { 
      System.out.println("Match"); 
    } 
    else { 
      System.out.println("Doesn't match"); 
    } 
     
    if (data.matches("^key=")) { 
      System.out.println("Match"); 
    } 
    else { 
      System.out.println("Doesn't match"); 
    } 
  } 
 
 
The output on Sun's VM: 
Match 
Doesn't match 
 
The output when compiled in gcj: 
Match 
Match 
 
 
If you need the configuration info for my gcc: 
johnm:common]$ gcc -v 
Reading specs 
from /opt/gcc-3.5.0-20040528/lib/gcc/i686-pc-linux-gnu/3.5.0/specs 
Configured with: ../gcc-3.5.0-20040528/configure 
--prefix=/opt/gcc-3.5.0-20040528 --libexecdir=/opt/gcc-3.5.0-20040528/lib 
--enable-shared --enable-threads=posix --enable-__cxa_atexit 
--enable-clocale=gnu --enable-languages=c,c++,java 
Thread model: posix 
gcc version 3.5.0 20040528 (experimental)

-- 
           Summary: Inconsistancy between regex match in java.util.regexp
                    between gcj and Sun's java.
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: john at austin dot homelinux dot net
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15724


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]