Bug 66256 - Array equals method semantics wrong
Summary: Array equals method semantics wrong
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 major (vote)
Target Milestone: 3.0 RC2   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-09 04:05 EDT by Xavier Serret CLA
Modified: 2004-06-09 04:44 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.