There was no danger that javac was going to eliminate the call to
Arrays.fill. javac could not guarantee that the java.util.Arrays that
would be used at run time would have no side effects. The JITC is a
different story.
Did you check using the circumstances where the JITC is most likely to
eliminate the zeroing? I.e., where the zero values in the array can
obviously never be used. I believe that would be
A. a local array variable
B. that is never passed as an argument to any constructor or method
except Arrays.fill
C. where Arrays.fill is obviously the last reference to the array before
the array goes out of scope
We might note that calling Arrays.fill is less likely to be eliminated
than a loop. So if you ever zeroize with a loop, you should check that, too.
We might also note that zeroizing is not the only alternative.
Randomizing, although it has more overhead, is just as good.
Mike Amling