This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 116997 - [60cat] Provide better equals() and hashCode() for array fields
Summary: [60cat] Provide better equals() and hashCode() for array fields
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: Macintosh Mac OS X
: P4 blocker with 1 vote (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-27 23:57 UTC by muhlig
Modified: 2013-09-02 14:23 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description muhlig 2007-09-27 23:57:03 UTC
[ BUILD # : 200709270000 ]
[ JDK VERSION : 1.5.* ]

If you use the "Insert code"-feature to generate your equals() and
hashCode() methods it uses the corresponding member functions of the
array to compare the arrays or to compute their hash code
respectively.

I personally think it would be better if java.util.Arrays.equals()
and java.util.Arrays.hashCode() were used or at least could be chosen
as an option from the code generation popup.

I.e.:
hash = 97 * hash + Arrays.hashCode(this.a);

instead of:
hash = 97 * hash + (this.a == null ? 0 : a.hashCode());
Comment 1 pawel_marchewka 2007-11-17 13:28:56 UTC
I agree with you, completely.

But what about CLCD/MIDP mobility projects? Under the CLCD/MIDP there is not Arrays class available.
I think that under the CLCD/MIDP it should be loop iterating over all the elements just like in the
java.util.Arrays.equals() method.