harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nellya Udovichenko (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-4248) [classlib][regex] java.util.regex.Pattern.compile(regex, flags) throws unexpected exceptions on certain pattern
Date Fri, 22 Jun 2007 12:47:26 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-4248?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Nellya Udovichenko updated HARMONY-4248:
----------------------------------------

    Attachment: H-4248-test.patch
                H-4248.patch

According to specification if the value of match flag isn't valid then IllegalArgumentException
is thrown in Pattern.compile() method. The corresponding check-up is added in the attached
patch. Therefore the results of the test work are following under spec at Harmony:

Pattern.compile("(?x:a?):", 1 << 8)
java.lang.IllegalArgumentException: Invalid match flags value
        at java.util.regex.Pattern.compile(Pattern.java:277)
        at PatternTest.main(PatternTest.java:11)
Test Failed
Pattern.compile("(?x:a?):", (1 << 8) | (1 << 7) | (1 << 6) |(1 <<
5) | (1 << 4)
| (1<< 2))
java.lang.IllegalArgumentException: Invalid match flags value
        at java.util.regex.Pattern.compile(Pattern.java:277)
        at PatternTest.main(PatternTest.java:21)
Test Failed

The regression test is uncommented in the attached test patch.

Please can anybody verify the patches?


> [classlib][regex] java.util.regex.Pattern.compile(regex, flags) throws unexpected exceptions
on certain pattern
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4248
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4248
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Elena Sayapina
>         Attachments: H-4248-test.patch, H-4248.patch
>
>
> Pattern.compile("(?x:a?):", flag); throws PatternSyntaxException or NullPointerException
if flag bit values other than those corresponding to the defined match flags are set in flags
> Please, consider the following code:
> import java.util.regex.Pattern;
> public class patternTest {
> 	
>     	static Pattern p;
> 	
> 	public static void main(String[] args) {
> 		
> 		try {
> 			System.out.println("Pattern.compile(\"(?x:a?):\", 1 << 8)");
> 			p = Pattern.compile("(?x:a?):", 1 << 8);
> 			System.out.println("Test passed");
> 		} catch (Exception e) {
> 			e.printStackTrace();
> 			System.out.println("Test Failed");
> 		}
> 		
> 		try {
> 			System.out.println("Pattern.compile(\"(?x:a?):\", (1 << 8) | (1 << 7)
| (1 << 6) |(1 << 5) | (1 << 4) | (1<< 2))");
> 			p = Pattern.compile("(?x:a?):", (1 << 8) | (1 << 7) | (1 << 6) |
(1 << 5) | (1 << 4) | (1<< 2));
> 			System.out.println("Test passed");
> 		} catch (Exception e) {
> 			e.printStackTrace();
> 			System.out.println("Test Failed");
> 		}
> 	}
> }
> Output on Harmony-r548930:
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or
its licensors,
> as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r548930, (Jun 20 2007), Windows/ia32/msvc 1310, release build
> http://harmony.apache.org
> Pattern.compile("(?x:a?):", 1 << 8)
> java.util.regex.PatternSyntaxException: unmatched ) near index: 6
> (?x:a?):
>       ^
>         at java.util.regex.Pattern.processSubExpression(Pattern.java:584)
>         at java.util.regex.Pattern.processSubExpression(Pattern.java:600)
>         at java.util.regex.Pattern.processExpression(Pattern.java:378)
>         at java.util.regex.Pattern.compileImpl(Pattern.java:283)
>         at java.util.regex.Pattern.compile(Pattern.java:264)
>         at patternTest.main(patternTest.java:11)
> Test Failed
> Pattern.compile("(?x:a?):", (1 << 8) | (1 << 7) | (1 << 6) |(1 <<
5) | (1 << 4) | (1<< 2))
> java.lang.NullPointerException
>         at java.util.regex.Lexer.isDecomposedCharBoundary(Lexer.java:1290)
>         at java.util.regex.Pattern.processDecomposedChar(Pattern.java:536)
>         at java.util.regex.Pattern.processSubExpression(Pattern.java:566)
>         at java.util.regex.Pattern.processExpression(Pattern.java:378)
>         at java.util.regex.Pattern.compileImpl(Pattern.java:283)
>         at java.util.regex.Pattern.compile(Pattern.java:264)
>         at patternTest.main(patternTest.java:20)
> Test Failed
> Output on RI:
> java version "1.5.0_11"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)
> Pattern.compile("(?x:a?):", 1 << 8)
> Test passed
> Pattern.compile("(?x:a?):", (1 << 8) | (1 << 7) | (1 << 6) |(1 <<
5) | (1 << 4) | (1<< 2))
> Test passed
> Note that RI throws no exception but according to the Java API Spec 1.5 it should throw
IllegalArgumentException:
> "public static Pattern compile(String regex, int flags)
> ...
> flags - Match flags, a bit mask that may include CASE_INSENSITIVE, MULTILINE, DOTALL,
UNICODE_CASE, and CANON_EQ 
> Throws: 
> IllegalArgumentException - If bit values other than those corresponding to the defined
match flags are set in flags ..."

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message