Skip to content

Commit 0a84e8e

Browse files
manish3499cyrille-artho
authored andcommitted
Rectifies the java.lang.NoSuchMethodError when usinf printf (#172)
* Rectifies the java.lang.NoSuchMethodError: java.util.regex.Matcher.find(I)Z error by overloading the find() method in native peer classes * adds unit test
1 parent d275f72 commit 0a84e8e

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/classes/java/util/regex/Matcher.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public Matcher reset(CharSequence inp) {
6767
public native boolean matches();
6868

6969
public native boolean find();
70+
71+
public native boolean find(int start);
7072

7173
public native boolean lookingAt();
7274

src/peers/gov/nasa/jpf/vm/JPF_java_util_regex_Matcher.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ public boolean matches____Z (MJIEnv env, int objref) {
7373
return matcher.matches();
7474
}
7575

76+
@MJI
77+
public boolean find__I__Z (MJIEnv env, int objref, int i) {
78+
Matcher matcher = getInstance( env, objref);
79+
return matcher.find(i);
80+
}
81+
7682
@MJI
7783
public boolean find____Z (MJIEnv env, int objref) {
7884
Matcher matcher = getInstance( env, objref);

src/tests/gov/nasa/jpf/test/java/io/PrintStreamTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
*/
3131
public class PrintStreamTest extends TestJPF {
3232

33-
@Test // currently fails with: java.lang.NoSuchMethodError: java.util.regex.Matcher.find(I)Z
33+
@Test
3434
public void testPrintCharFormat () {
3535
if (verifyNoPropertyViolation()){
3636
ByteArrayOutputStream baos = new ByteArrayOutputStream(1);
3737
PrintStream baps = new PrintStream(baos, true);
38-
// baps.printf("%c", 'a'); // fails
39-
// assert (baos.toByteArray()[0] == 97);
38+
baps.printf("%c", 'a');
39+
assert (baos.toByteArray()[0] == 97);
4040
}
4141
}
42-
}
42+
}

0 commit comments

Comments
 (0)