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 227171

Summary: generated hashCode method has special treatment of enums for no reason.
Product: java Reporter: swpalmer <swpalmer>
Component: SourceAssignee: Jan Lahoda <jlahoda>
Status: VERIFIED FIXED    
Severity: normal CC: mmirilovic
Priority: P3    
Version: 7.3   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: IDE log

Description swpalmer 2013-03-07 14:18:04 UTC
Product Version = NetBeans IDE 7.3 (Build 201302132200)
Operating System = Windows 7 version 6.1 running on x86
Java; VM; Vendor = 1.7.0_15
Runtime = Java HotSpot(TM) Client VM 23.7-b01

I have a class that looks like this:
class MyClass {
	String variable;
	String path;
	MyEnum type;
}

This is what NetBeans generated:
		@Override
		public int hashCode() {
			int hash = 7;
			hash = 29 * hash + Objects.hashCode(this.variable);
			hash = 29 * hash + Objects.hashCode(this.path);
			hash = 29 * hash + (this.type != null ? this.type.hashCode() : 0);
			return hash;
		}

The treatment of the member "type" is just a hard-coded version of what Objects.hashCode is doing for the other memebers.  Why not use Objects.hasCode for enums as well?
Comment 1 swpalmer 2013-03-07 14:18:15 UTC
Created attachment 132340 [details]
IDE log
Comment 2 Jan Lahoda 2013-04-04 11:13:46 UTC
Fixed in the trunk:
http://hg.netbeans.org/jet-main/rev/4f0eb668a631
Comment 3 Jiri Prox 2013-04-15 14:11:19 UTC
verified in trunk
Comment 4 Jan Lahoda 2013-05-03 07:32:30 UTC
release73:
http://hg.netbeans.org/releases/rev/3a416ad27ba2
Comment 5 Quality Engineering 2013-05-05 00:27:02 UTC
Integrated into 'releases', will be available in build *201305042200* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/3a416ad27ba2
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #227171: use Objects.hashCode also for fields with an enum type.