You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Elena Sayapina (JIRA)" <ji...@apache.org> on 2007/06/22 06:42:26 UTC

[jira] Commented: (HARMONY-4248) [classlib][regex] java.util.regex.Pattern.compile(regex, flags) throws unexpected exceptions on certain pattern

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

Elena Sayapina commented on HARMONY-4248:
-----------------------------------------

Test case testCompileFlags of functional test org.apache.harmony.test.func.api.java.util.regex.Pattern.PatternTest (https://issues.apache.org/jira/browse/HARMONY-3528) fails because of this bug. 


> [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
>
> 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.