Bug 363350 - [getter setter] Incorrect parameter name in setter
Summary: [getter setter] Incorrect parameter name in setter
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows 7
: P5 minor (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-09 11:35 EST by Ivan CLA
Modified: 2022-10-22 14:31 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan CLA 2011-11-09 11:35:42 EST
Build Identifier: 20110615-0604

If we have a field called e.g. "OID", getter and setter are generated as follows:

	/** @return The oID. */
	public int getOID() {
		return OID;
	}
	/** @param oID The oID to set. */
	public void setOID(int oID) {
		OID = oID;
	}

However they should be ("OID" instead of "oID"):

	/** @return The OID. */
	public int getOID() {
		return OID;
	}
	/** @param OID The OID to set. */
	public void setOID(int OID) {
		this.OID = OID;
	}

I know spec recommends to call field as "oid", but "OID" is inevitable here.

Reproducible: Always

Steps to Reproduce:
1. Create a field with two first letters upper-cased
2. Generate getter and setter for it
Comment 1 Ivan CLA 2011-11-09 11:41:02 EST
Btw the constructor too:
	public MyClass(int oID, String desc) {
		OID = oID;
		this.desc = desc;
	}
Comment 2 Deepak Azad CLA 2011-11-15 03:58:39 EST
Setters for constants are fairly uncommon (see also bug 85782 comment 1), however I think we can leave the first character in the parameter as is if the first 2 characters in the field name are uppercase.
Comment 3 Ivan CLA 2011-11-17 07:48:54 EST
Here it is not a constant, it is "private int OID;". I know this is not recommended, however we should follow some forced legacy standards for a couple of classes.
In any case I like your suggestion:
> we can leave the first character in the parameter as is if the first 2 characters in the field name are uppercase
Comment 4 Eclipse Genie CLA 2020-09-28 12:45:08 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 5 Eclipse Genie CLA 2022-10-22 14:31:50 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.