Bug 153125 - [getter setter] Getters/setters for variables starting with non-Latin letter are generated incorrectly
Summary: [getter setter] Getters/setters for variables starting with non-Latin letter ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 trivial (vote)
Target Milestone: 3.4 M1   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2006-08-08 13:05 EDT by kalle CLA
Modified: 2007-08-03 07:29 EDT (History)
3 users (show)

See Also:


Attachments
Patch for bug 153125: fix case conversion in ScannerHelper#toUpperCase() (799 bytes, patch)
2007-06-28 10:11 EDT, David Foerster CLA
no flags Details | Diff
Fix + Regression test (2.23 KB, patch)
2007-06-28 10:43 EDT, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description kalle CLA 2006-08-08 13:05:41 EDT
Problem occurs on Eclipse 3.2 but does not occur on 3.0.2 (on Windows XP)

1. Create an object which name starts with non-Latin character (i.e ööbik)
2. Choose Source -> Generate Getters and Setters
3. Generate them as usually

Generated methods' names do not meet the naming convention:
for example the get method for variable ööbik is 
  getööbik()
but it should be
  getÖöbik()
-- the variable's name should start with capital letter.

In addition (with the same example), if there is a method
  getÖöbik()
getters/setters generator doesn't recognize that it is there already and lets us choose to generate getters/setters for variable ööbik.

I tried with variables starting with characters:
õ, ä, ö, ü, š and ž.

Again, it is notable, that the error didn't occur on Eclipse 3.0.2.
Comment 1 Martin Aeschlimann CLA 2006-08-29 09:37:54 EDT
Getter and setter names are created using NamingConvention.suggestGetterName. Moving to jdt.core
Comment 2 David Foerster CLA 2007-06-28 01:34:03 EDT
I can reproduce this bug on v3.3rc4 (WinXP) as well as it's non-occurence before v3.2.
Precisely suggestGetterName(), as well as many other methods in NamingConventions, calls suggestAccessorName() to convert the first character to upper case. Unfortunately all character case conversion and testing methods used in NamingConventions rely on jdt.internal.compiler.parser.ScannerHelper which is imho quite inept since it cosiders only the first 128 ASCII character instead of all unicode character classes. Sees like this is a cross platform issue.

As you can see on http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/model/org/eclipse/jdt/core/NamingConventions.java?view=log ScannerHelper is used in NamingConventions since revision 1.33 instead of java.lang.Character -- for performance reasons the annotation says. Character SUPPORTS unicode character classes and case conversion.
Similar changes have been made in quite a lot other JDT-classes. For instance jdt.core.compiler.CharOperation uses ScannerHelper for case-insensitive char array comparison which still sounds quite unbelievable to me.

I will implement a neat little benchmark to compare case conversion in Character and ScannerHelper to see wether there is a serious lack of performance in Character. I might as well use the performance tests in the cvs but until now I don't understand them. ;) Though I don't believe that the difference in performance justifies the disregard of non-ASCII letters which is a violiation of the Java Language Specification (http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.8) and the Unicode Standard Annex #31 (http://unicode.org/reports/tr31/)
Comment 3 David Audel CLA 2007-06-28 04:30:04 EDT
The bug is that ScannerHelper#toUpperCase() call Character#toLowerCase() instead of Character#toUpperCase()

David - Methods of ScannerHelper call methods of Character when the character is above 128. So there is no problem in this area or i misunderstand what you suggest.
If you still think there is a problem in this area please open a separate.
Comment 4 David Foerster CLA 2007-06-28 08:00:53 EDT
David, you didn't misunderstand me. I simply overlooked this. ;)
In this case my task will be a lot easier since I only have to fix this single line in ScannerHelper#toUpperCase(). The patch will be coming right away.
Comment 5 David Foerster CLA 2007-06-28 10:11:50 EDT
Created attachment 72686 [details]
Patch for bug 153125: fix case conversion in ScannerHelper#toUpperCase()

Here is the patch.
ScannerHelper#toUpperCase() now calls Character#toUpperCase().
Comment 6 David Audel CLA 2007-06-28 10:43:48 EDT
Created attachment 72691 [details]
Fix + Regression test

Patch proposed by David Foerster + Regression test
Comment 7 David Audel CLA 2007-06-28 10:47:53 EDT
Released for 3.4M1.

Test added
  NamingConventionTests#testSuggestGetterName008()
Comment 8 Frederic Fusier CLA 2007-08-03 07:29:25 EDT
Verified for 3.4M1 using build I20070802-0800.