-
Bug
-
Resolution: Fixed
-
P4
-
1.4.1_01, 1.4.2, 5.0
-
b57
-
x86
-
linux, windows_2000
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux bertha 2.6.8-1-686-smp #1 SMP Thu Oct 7 01:53:29 EDT 2004 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The exception's message text isn't descriptive enough for direct presentation to the user; this means that application code has to repeat the parse to decide what the exact problem was, even though the missing information is known by the throwing code.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
bertha:/tmp$ cat > bug.java
class bug {
public static void main(String[] args) {
"hello world".replaceAll("l", "$monkey");
}
}
bertha:/tmp$ javac bug.java
bertha:/tmp$ java bug
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference 'm'
at java.util.regex.Matcher.appendReplacement(Matcher.java:706)
at java.util.regex.Matcher.replaceAll(Matcher.java:806)
at java.lang.String.replaceAll(String.java:2000)
at bug.main(bug.java:3)
ACTUAL -
Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference
at java.util.regex.Matcher.appendReplacement(Matcher.java:706)
at java.util.regex.Matcher.replaceAll(Matcher.java:806)
at java.lang.String.replaceAll(String.java:2000)
at bug.main(bug.java:3)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class bug {
public static void main(String[] args) {
"hello world".replaceAll("l", "$monkey");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
modify java/util/regex/Matcher.java thus:
} else if (nextChar == '$') {
// Skip past $
cursor++;
// The first number is always a group
char refChar = replacement.charAt(cursor);
int refNum = (int)refChar - '0';
if ((refNum < 0)||(refNum > 9))
throw new IllegalArgumentException(
"Illegal group reference '" + refChar + "'");
cursor++;
###@###.### 2004-11-11 00:14:49 GMT
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux bertha 2.6.8-1-686-smp #1 SMP Thu Oct 7 01:53:29 EDT 2004 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The exception's message text isn't descriptive enough for direct presentation to the user; this means that application code has to repeat the parse to decide what the exact problem was, even though the missing information is known by the throwing code.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
bertha:/tmp$ cat > bug.java
class bug {
public static void main(String[] args) {
"hello world".replaceAll("l", "$monkey");
}
}
bertha:/tmp$ javac bug.java
bertha:/tmp$ java bug
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference 'm'
at java.util.regex.Matcher.appendReplacement(Matcher.java:706)
at java.util.regex.Matcher.replaceAll(Matcher.java:806)
at java.lang.String.replaceAll(String.java:2000)
at bug.main(bug.java:3)
ACTUAL -
Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference
at java.util.regex.Matcher.appendReplacement(Matcher.java:706)
at java.util.regex.Matcher.replaceAll(Matcher.java:806)
at java.lang.String.replaceAll(String.java:2000)
at bug.main(bug.java:3)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class bug {
public static void main(String[] args) {
"hello world".replaceAll("l", "$monkey");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
modify java/util/regex/Matcher.java thus:
} else if (nextChar == '$') {
// Skip past $
cursor++;
// The first number is always a group
char refChar = replacement.charAt(cursor);
int refNum = (int)refChar - '0';
if ((refNum < 0)||(refNum > 9))
throw new IllegalArgumentException(
"Illegal group reference '" + refChar + "'");
cursor++;
###@###.### 2004-11-11 00:14:49 GMT
- duplicates
-
JDK-4783892 Pattern.compile("\\") throws internal error
-
- Closed
-