You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Nellya Udovichenko (JIRA)" <ji...@apache.org> on 2007/01/22 15:34:30 UTC

[jira] Commented: (HARMONY-1149) [classlib][regex] unexpected PatternSyntaxException for String.replaceFirst()/replaceAll()

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

Nellya Udovichenko commented on HARMONY-1149:
---------------------------------------------

I think this is actually RI bug. In JDK 1.5 it doesn't correctly execute check-up of the back reference '\1' at regular expression parsing. 
Therefore, it allows one reference more than expected. 

So this issue is 'Non-Bug Difference' that could be closed as 'Won't Fix', isn't it?


> [classlib][regex] unexpected PatternSyntaxException for String.replaceFirst()/replaceAll()
> ------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1149
>                 URL: https://issues.apache.org/jira/browse/HARMONY-1149
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>         Attachments: StringTest.patch
>
>
> The Harmony methods String.replaceFirst(String regex, String replacement) and String.replaceAll(String regex, String replacement) throws PatternSyntaxException on Harmony and works silently on RI.
> =================== test.java ======================
> import java.util.regex.*;
> public class test  {    
>     public static void main (String [] args) {
>         String str_re = "\\1";
>         try {
>             System.out.println("replaceFirst = " + "abc".replaceFirst(str_re, "x"));
>         } catch (Exception e) {
>             System.out.println("unexpected exception: " + e);
>         }
>         try {
>             System.out.println("replaceAll = " + "abc".replaceAll(str_re, "x"));
>         } catch (Exception e) {
>             System.out.println("unexpected exception: " + e);
>             e.printStackTrace();
>        }
>     }
> }
> ================================================
> Output:
> C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -cp . -showversion test
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))
> replaceFirst = abc
> replaceAll = abc
> C:\tmp\tmp17>C:\harmony\classlib1.5\deploy\jdk\jre\bin\java.exe -cp . -showversion test
> java version 1.5 (subset)
> (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> unexpected exception: java.util.regex.PatternSyntaxException: No such group yet exists at this point in the pattern near index: 0
> \1
> ^
> unexpected exception: java.util.regex.PatternSyntaxException: No such group yet exists at this point in the pattern near index: 0
> \1
> ^
> java.util.regex.PatternSyntaxException: No such group yet exists at this point in the pattern near index: 0
> \1
> ^
>         at java.util.regex.Pattern.processTerminal(Pattern.java:950)
>         at java.util.regex.Pattern.processSubExpression(Pattern.java:593)
>         at java.util.regex.Pattern.processExpression(Pattern.java:376)
>         at java.util.regex.Pattern.compileImpl(Pattern.java:279)
>         at java.util.regex.Pattern.compile(Pattern.java:261)
>         at java.util.regex.Pattern.compile(Pattern.java:1155)
>         at java.lang.String.replaceAll(String.java:1782)
>         at test.main(test.java:13)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira