Joe Darcy wrote:
Neal Gafter wrote:
There should be a shortcut in Arrays.deepEquals0 when e1==e2.
That shortcut is in Objects.deepEquals(Object a, Object b) and
Arrays.deepEquals on lines 3947 and 3948. The nested call in
deepEquals0 is to deepEquals rather than deepEquals0 so the shortcut
is used on all levels.
Also, the code will throw an assertion error if e1!=null and e2==null
(which can occur when called from Arrays.deepEquals).
Good catch! Yes, my mistake; only e1 != null is guaranteed when being
called from Arrays.deepEquals.
The simplest way to fix these is to move the if statements from
Objects.deepEquals into Arrays.deepEquals0. Alternately, change the
call of Arrays.deepEquals0 in Arrays.deepEquals to a call to
Objects.deepEquals. If you do the latter, you might as well move all
the code of deepEquals0 into the body of Object.deepEquals.
For correctness, I think removing the assertion that e2 != null in
deepEquals0 is sufficient.
Thanks,
-Joe
The code with both asserts failed the Arrays regression tests with when
run with system assertions enabled. When the second assertion was
removed, the tests passed with system assertions enabled and I've push
that version.
Thanks,
-Joe