harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Svetlana Samoilenko (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-101) NPE in java.util.regex.Pattern.compile()
Date Fri, 17 Feb 2006 12:29:24 GMT
NPE in java.util.regex.Pattern.compile()

         Key: HARMONY-101
         URL: http://issues.apache.org/jira/browse/HARMONY-101
     Project: Harmony
        Type: Bug
  Components: Classlib  
    Reporter: Svetlana Samoilenko

According to 1.4.2 and 1.5 specifications for java.util.regex.Pattern.matches(String regex,CharSequence
An invocation of this convenience method of the form 
        Pattern.matches(regex, input);
behaves in exactly the same way as the expression 

Harmony throws unspecified NPE for Pattern.compile and returns false instead of true for Pattern.matches().

Code to reproduce: 
import java.util.regex.Pattern;
public class test2 {
    public static void main(String[] args) {             
        System.out.println("boolean is true="+Pattern.matches("[,&&\\p{Punct}]", ","));
        System.out.println("boolean is true="+Pattern.compile("[,&&\\p{Punct}]").matcher(",").matches());
 Steps to Reproduce: 
1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
2. Compile test2.java using BEA 1.4 javac 
> javac -d . test2.java 
3. Run java using compatible VM (J9) 
> java -showversion test2

C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
java version "1.4.2_04" 
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) 
BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads,
GC strategy: parallel) 
boolean is true=true
boolean is true=true

C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
boolean is true=false
        at test2.main(test2.java:5)

Suggested junit test case:
------------------------ PatternTest.java -------------------------------------------------

import junit.framework.*; 
import java.util.regex.Pattern;

public class PatternTest extends TestCase { 
    public static void main(String[] args) { 
    public void test_compile () { 
        assertTrue(Pattern.matches("[,&&\\p{Punct}]", ","));

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message