bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/22873] java.util.regex.Matcher.group(int) differs from Su


From: gcc-bugzilla at gcc dot gnu dot org
Subject: [Bug classpath/22873] java.util.regex.Matcher.group(int) differs from Sun's API
Date: 16 Oct 2005 01:27:32 -0000

According to Sun's API documentation, java.util.regex.Matcher.group(int)
returns null if the specified group didn't match. This isn't mentioned in the
documentation of the respective method in Classpath 0.13. Further, the
implementation is to return gnu.regexp.REMatch.toString(group), which is an
empty string in this situation.

There is also a related internal inconsistency in Classpath resulting from this
implementation, because REMatch.toString(int) doesn't throw the exception that
Match.group(int) promises in case the group doesn't exist in the pattern.

Attached is a test program that prints two OKs on Sun's JDK
1.5.0 and two shoulds on Kaffe 1.1.4 and Sablevm 1.1.9.


------- Comment #1 from from-classpath at savannah dot gnu dot org  2005-05-10 
22:22 -------
java.util.regex.Matcher returns IllegalStateException for itself, see
assertMatchOp at the end of Matcher.java; so gnu.regexp.REMatch doesn't have to
throw it.

/gnu/regexp/REMatch.java, however, does incorrectly return empty strings
instead of null values for groups that are outside the range of the regex's
result.

Attached is a simple patch that corrects the issue in REMatch.java.


------- Comment #2 from from-classpath at savannah dot gnu dot org  2005-05-10 
23:02 -------
My patch was not done with following the patch-from-project-root-directory
convention, I have attached a corrected patch.  I have also renamed it.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22873





reply via email to

[Prev in Thread] Current Thread [Next in Thread]