-
Bug
-
Resolution: Fixed
-
P4
-
7u51
-
b24
-
x86
-
windows_7
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8056765 | emb-9 | Unassigned | P4 | Resolved | Fixed | b24 |
FULL PRODUCT VERSION :
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Client VM (build 24.51-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601] (Windows 7, 32-bit)
A DESCRIPTION OF THE PROBLEM :
According to documentation (some parts omitted for brevity)
http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#compile%28java.lang.String,%20int%29
public static Pattern compile(String regex,
int flags)
[...]
Throws:
IllegalArgumentException - If bit values other than those corresponding to the defined match flags are set in flags
However, the class doesn't check the flag at all.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just compile a Pattern with 0xFFFFFFFF (all bits set)
Pattern.compile("d", 0xFFFFFFFF)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
IllegalArgumentException, since not all 32 bits are used by the flags
ACTUAL -
No Exception thrown
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/* Author: Hong Dai Thanh/nhahtdh */
import java.util.regex.*;
class BugCompileBadFlag {
public static void main(String args[]) {
try {
System.out.println(Pattern.compile("d", 0xFFFFFFFF));
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
}
}
}
---------- END SOURCE ----------
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Client VM (build 24.51-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601] (Windows 7, 32-bit)
A DESCRIPTION OF THE PROBLEM :
According to documentation (some parts omitted for brevity)
http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#compile%28java.lang.String,%20int%29
public static Pattern compile(String regex,
int flags)
[...]
Throws:
IllegalArgumentException - If bit values other than those corresponding to the defined match flags are set in flags
However, the class doesn't check the flag at all.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just compile a Pattern with 0xFFFFFFFF (all bits set)
Pattern.compile("d", 0xFFFFFFFF)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
IllegalArgumentException, since not all 32 bits are used by the flags
ACTUAL -
No Exception thrown
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/* Author: Hong Dai Thanh/nhahtdh */
import java.util.regex.*;
class BugCompileBadFlag {
public static void main(String args[]) {
try {
System.out.println(Pattern.compile("d", 0xFFFFFFFF));
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
}
}
}
---------- END SOURCE ----------
- backported by
-
JDK-8056765 Pattern.compile(String, int) fails to throw IllegalArgumentException
-
- Resolved
-
- duplicates
-
JDK-8055696 java.util.regex.Pattern documentation is not correct.
-
- Closed
-
There are no Sub-Tasks for this issue.