I'm seeing Integer.reverse behaviour change in recent JDK 20 EA builds, I think the culprit is JDK-8290034.
$ java -fullversion
openjdk full version "20-ea+12-790"
$ java -cp ~/ T
Exception in thread "main" java.lang.AssertionError: expected Integer.reverse(1) to be -2147483648, but was 128 after 307906 iterations
at T.main(T.java:9)
class T {
public static void main(String[] args) {
long c = 0;
int expected = -2147483648;
while (true) {
long r = Integer.reverse(1);
if (r != expected) {
throw new AssertionError(
String.format(
"expected Integer.reverse(1) to be %d, but was %d after %d iterations",
expected, r, c));
}
c++;
}
}
}