Bug 66256

Summary: Array equals method semantics wrong
Product: [Eclipse Project] JDT Reporter: Xavier Serret <xavier.serret>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: major    
Priority: P3    
Version: 2.1   
Target Milestone: 3.0 RC2   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Xavier Serret CLA 2004-06-09 04:05:17 EDT
The documentation of the equals method from object states that comparisons must 
be per semantic value.

array.equals compares per reference value.

The following code does not act consistently

int[] rba, vba;

....

vba.equals(rba)) --> false;

Nevertheless this test is succesfull:

assertEquals(vba.length, rba.length);
for (int i = 0; i < rba.length; i++)
{
   assertEquals(vba[i],rba[i]);
}
Comment 1 Philipe Mulet CLA 2004-06-09 04:44:46 EDT
This is a language spec issue, nothing to do with our compiler.

Object#equals is implemented as an identity check, and clients may refine it 
to be more tolerant (i.e. compare held values instead).
array #equals is spec'ed to use the Object method implementation.

Please complain against the owner of the language spec, we have to comply.