Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java Pattern Matcher (Pattern.class bug? Stuck in Infinite Loop)

807580Apr 1 2010 — edited Apr 2 2010
Hi,

I'm using the java pattern matcher and it appears to be stuck in an infinite loop and will not return from Pattern.class.

It stays stuck in the following two code sequences...

I'm using the following regex...

java.util.regex.Matcher[pattern=[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|biz|info) region=0,353648 lastmatch=

MAIN BLOCK STUCK IN LOOP:
boolean study(TreeInfo info) {
if (type != INDEPENDENT) {
int minL = info.minLength;
atom.study(info);
info.minLength = minL;
info.deterministic = false;
return next.study(info);
} else {
atom.study(info);
return next.study(info);
}
}

SECOND BLOCK STUCK IN LOOP:
boolean match(Matcher matcher, int i, CharSequence seq) {
// Check for zero length group
if (i > matcher.locals[beginIndex]) {
int count = matcher.locals[countIndex];
if (count < cmin) {
matcher.locals[countIndex] = count + 1;
boolean result = body.match(matcher, i, seq);
// If match failed we must backtrack, so
// the loop count should NOT be incremented
if (!result)
matcher.locals[countIndex] = count;
return result;
}
if (next.match(matcher, i, seq))
return true;
if (count < cmax) {
matcher.locals[countIndex] = count + 1;
boolean result = body.match(matcher, i, seq);
// If match failed we must backtrack, so
// the loop count should NOT be incremented
if (!result)
matcher.locals[countIndex] = count;
return result;
}
return false;
}
return next.match(matcher, i, seq);
}

Is this a bug with the Java 1.6 Pattern Matcher?

Thanks
V$h3r
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 30 2010
Added on Apr 1 2010
19 comments
1,191 views