Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: generate getter/setter method bug #1454

Closed
ydq opened this issue Aug 12, 2017 · 6 comments
Closed

Bug report: generate getter/setter method bug #1454

ydq opened this issue Aug 12, 2017 · 6 comments

Comments

@ydq
Copy link

ydq commented Aug 12, 2017

The standard Javabean specification specifies the getter / setter method as follows:

uName -> getuName / setuName

But Lombok generated the code is getUName / setUName

Eclipse: Oxygen Release (4.7.0)
Lombok: v1.16.18

image

@ydq ydq changed the title generate getter/setter method bug Bug report: generate getter/setter method bug Aug 12, 2017
@o-pikozh
Copy link

I what place does JavaBeans specification say that a getter should be named getuName instead of getUName?

@cardamon
Copy link
Contributor

Certainly not in section 8.3.1 😉

@Maaartinus
Copy link
Contributor

Maaartinus commented Aug 14, 2017

Duplicate of #1453, #757 and many others.

Javabeans is fubared. Some long time ago I was unhappy about Lombok mistreating my "uShaped" property and wrote manual etters as a workaround. IIRC it didn't work either, because some other tool didn't understand it in the opposite direction (setuShaped -> uShaped), so I ended using "shapedAsU" instead. 🙄

@ydq
Copy link
Author

ydq commented Aug 15, 2017

@o-pikozh @cardamon

At least jsp think so...

lombok1

I use Eclipse to generate getter / setter to keep it correct

lombok2

Then the jsp show the correct results

lombok3

@o-pikozh
Copy link

o-pikozh commented Aug 15, 2017

@ydq

I already see that it indirectly comes from § 8.8 “Capitalization of inferred names”. It says:

Thus when we extract a property or event name from the middle of an existing Java name, we
normally convert the first character to lower case. However to support the occasional use of all
upper-case names, we check if the first two characters of the name are both upper case and if
so leave it alone. So for example,
        “FooBah” becomes “fooBah”
        “Z” becomes “z”
        “URL” becomes “URL”

Therefore getABcdABcd. So the only remaining way for aBcd is getaBcd. Additionally this is confirmed by:

We provide a method Introspector.decapitalize which implements this conversion rule.

— and Introspector.decapitalize works in that way (aBcdgetaBcd).

Still, you should read the whole discussion. And not duplicate the original report. Probably it will remain "won't fix".

@rzwitserloot
Copy link
Collaborator

Duplicate of #2693

@rzwitserloot rzwitserloot marked this as a duplicate of #2693 Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants