This fixes a bug in java.util.regex.Matcher whereby
the append position is not reset when reset() or
reset(String) is called.

This bug was discovered when trying to build OpenJDK7 b33.
The NIO generating script that we used to have to patch to use
/bin/bash instead of /bin/sh has been replaced by Spp.java
(avoiding problems with the shell trying to handle content
like $replType$).  It instantiates one Matcher instance and
resets it with a new String each time.  As the append position
was not been reset, we then try and append to the end position
in the old string which ends up with an IndexOutOfBoundsException.
This simple fix solves this issue.  As this obviously won't propogate
to distros for a while, I've patched Spp.java instead to create a
new Matcher for each String.  More details of that on the IcedTea
list when I have a working b33 build...

ChangeLog:

2008-08-23  Andrew John Hughes  <[EMAIL PROTECTED]>

        * java/util/regex/Matcher.java:
        (reset()): Reset append position so
        we don't try and append to the end of
        the old input.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
Index: java/util/regex/Matcher.java
===================================================================
RCS file: /sources/classpath/classpath/java/util/regex/Matcher.java,v
retrieving revision 1.22
diff -u -u -r1.22 Matcher.java
--- java/util/regex/Matcher.java        16 Aug 2008 23:32:15 -0000      1.22
+++ java/util/regex/Matcher.java        21 Aug 2008 23:40:42 -0000
@@ -337,6 +337,7 @@
     match = null;
     regionStart = 0;
     regionEnd = input.length();
+    appendPosition = 0;
     return this;
   }
   

Reply via email to