Bug 201874 - error generating getter/setter for field with second character in uppercase
Summary: error generating getter/setter for field with second character in uppercase
Status: VERIFIED DUPLICATE of bug 154823
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.5 M7   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-31 05:56 EDT by Daniele Pirola CLA
Modified: 2009-08-10 12:55 EDT (History)
4 users (show)

See Also:


Attachments
test case getter (1.63 KB, text/plain)
2007-08-31 09:41 EDT, Daniele Pirola CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniele Pirola CLA 2007-08-31 05:56:21 EDT
Build ID: I20070809-1105

Steps To Reproduce:
1. create a field in a class with second character in Uppercase (eg. tStart )
2. generate getter and setter
3. methods signature generated are incorrect 
 - public void setTStart(...)
 - public Date getTStart()

instead of 
 - public void settStart(...)
 - public Date gettStart()


More information:
This is the JavaDoc of the method Introspector.decapitalize used when converting getter and setter method name to field name:

...
     * Utility method to take a string and convert it to normal Java variable name capitalization.  
This normally means converting the first character from upper case to lower case, but in the (unusual) special case when there is more than one character and both the first and second characters are upper case, we leave it alone.
     * <p>
     * Thus "FooBah" becomes "fooBah" and "X" becomes "x", but "URL" stays as "URL".
...


You can see that in case of a method named getTStart the field retreived is TStart and not tStart.

This is not a so unusual case when the bean class is a POJO's that map a database table with fields like T_START
Comment 1 Olivier Thomann CLA 2007-08-31 08:37:28 EDT
Move to JDT/UI
Comment 2 Martin Aeschlimann CLA 2007-08-31 08:47:28 EDT
We are using
org.eclipse.jdt.core.NamingConventions.suggestGetter/SetterName(...)
Comment 3 Daniele Pirola CLA 2007-08-31 09:41:00 EDT
Created attachment 77463 [details]
test case getter

In this test case there are two nested class named OK and NOOK.
The first has a field tStart with getter and setter handmade (gettStart ...)
The second has the same field but with getter and setter made by Eclipse (getTStart).

Via methods Introspector.getBeanInfo -> beanInfo.getPropertyDescriptors()
the first class/field is correctly recognized
but the second test fails because the field name for the BeanInfo class is TStart
and not tStart.
Comment 4 David Audel CLA 2009-06-29 06:11:53 EDT

*** This bug has been marked as a duplicate of bug 154823 ***
Comment 5 Ayushman Jain CLA 2009-08-05 02:08:25 EDT
Verified for 3.6M1 using I20090802-2000
Comment 6 Olivier Thomann CLA 2009-08-10 12:55:46 EDT
Verified.