Closed
Description
We discovered a bug affecting Semeru 11.0.21+9 and 11.0.22+7. (I hope that OpenJ9 is the right place for this issue. If not, please point me to the right place.)
The bug happens in the String.lastIndexOf(String)
method which always returns-1
when passing a String with the NULL character ("\u0000"
).
The following code can be used to reproduce the issue:
import java.util.stream.Collectors;
class Main {
public static void main(String... args) {
String s = args[0] + "\u0000" + args[1];
int index = s.lastIndexOf("\u0000");
System.out.println("string code points: " + s.codePoints().boxed().collect(Collectors.toList()));
System.out.println("last index of NULL character (0): " + index + ", should be: " + args[0].length());
if (index == -1) {
throw new AssertionError();
}
}
}
Just run
javac Main.java
<path to affected java> -cp . Main string1 string2
The following versions of Semeru were found to be not affected:
- 11.0.20.1+1
- 17.0.10+7
- 21.0.2+13