I tried running the exact code you gave on OpenJDK 7 and got the following output:
Testing 1 3 9 11 33
It could be that your JRE's implementation of BigInteger creates new instances of BigIntegers for zeros, rather than re-using the existing
BigInteger.ZERO instance. You should use
.equals() instead of
== to compare objects; this should work even if you have two instances of zero.