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 123295 - Generator for equals() and hashCode() allows to create invalid code
Summary: Generator for equals() and hashCode() allows to create invalid code
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 2 votes (vote)
Assignee: Dusan Balek
Depends on:
Reported: 2007-12-03 22:08 UTC by Petr Jiricka
Modified: 2015-07-26 12:00 UTC (History)
2 users (show)

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2007-12-03 22:08:24 UTC
1. Create a new class in a Java project, add some bean properties
2. Go to Source -> Insert Code... -> equals() and hashCode()
3. Select some properties for equals() and their superset for hashCode() - this breaks the contract for hashCode()
4. Click Generate - the invalid equals() and hashCode() is generated without any warning

There should be a warning or an error that prevents this.

BTW, enhancement 28862 would be useful for implementing this check.
Comment 1 Jiri Prox 2008-04-11 00:51:27 UTC
moving opened issues from TM <= 6.1 to TM=Dev
Comment 2 Jan Becicka 2008-08-25 15:58:48 UTC
This is rather enhancement.
Comment 3 David Konecny 2008-08-26 00:41:21 UTC
Enhancement? There are so many ways to look at this request. From the point of view of product feature matrix we've got
the tick and feature is done; this is an enhancement. From quality point of view we have very primitive implementation
allowing user to generate bad code, user eventually figure it out (painful way) and will never trust NB generated code
again. From developers point of view this is trivial fix. From issuezilla point of view this enhancement is lost forever
as nobody has time to evaluate enhancements. From my point of view we should actually pay a lot more attention to
details/issues like this because it is easy to fix yet it contributes to the prestige of IDE. That's why people love
IntelliJ - it always does the right thing. My two cents.