Name: gm110360 Date: 01/27/2004
FULL PRODUCT VERSION :
java version "1.4.2_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
win 2000, build 2195, sp4
A DESCRIPTION OF THE PROBLEM :
when you try to match a string that ENDS with a backslash, the runtime will crash.
String test = "c:\test";
System.out.println(test.replaceAll("\\", "repl"));
will give:
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Replace the backslash in c:\test with 'repl'
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.replaceAll(Unknown Source)
at TestDriver.main(TestDriver.java:9)
Exception in thread "main"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class TestDriver
{
public static void main(String[] args)
{
String test = "c:\test";
System.out.println(test.replaceAll("\\", "repl"));
}
}
---------- END SOURCE ----------
(Incident Review ID: 230841)
======================================================================
- duplicates
-
JDK-4783892 Pattern.compile("\\") throws internal error
-
- Closed
-