Skip to content

the setter method got letter case error... #504

Closed
@lombokissues

Description

@lombokissues

Migrated from Google Code (issue 431)

Activity

lombokissues

lombokissues commented on Jul 14, 2015

@lombokissues
Author

👤 awanabe   🕗 Nov 24, 2012 at 09:07 UTC

What steps will reproduce the problem?

  1. define a bean with format "aBxxx", that means the first letter is lowercase, the second letter is uppercase.
  2. use lombok setter annotation.
  3. the auto set method will be setABxxx()
  4. but the spring know the set method is setaBxxx(). so the bean can not be injected.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
lombo 0.10.8

Please provide any additional information below.

lombokissues

lombokissues commented on Jul 14, 2015

@lombokissues
Author

👤 reinierz   🕗 Mar 11, 2013 at 19:55 UTC

According to the bean spec, spring is in error, so you should probably file this with them.

Actually, the bean spec says that, to maintain all-caps properties, the rule is:

If both the first and second letter of the camelcased (i.e. from setter/getter method name) property name are uppercase, then DO NOT lowercase the first letter to arrive at the property name.

If you take that to its logical conclusion with capitalizing, which the beanspec never actually talks about, and for which there is no method in Introspector, then in your example:

capitalize("aBoo") would seemingly have to become getABoo(), but then if you were to decapitalize this, then according to the very same beanspec, you end up with 'ABoo' as property name. That means the beanspec's own rules aren't idempotent; taking any property name, capitalizing it, and decapitalizing it does not necessary result in the original string.

I'm guessing spring figured out this screwup in the spec and 'fixed it' by basically not changing the casing of anything if the second letter is a capital.

However, we are of the opinion that this alternate rule ("If the second letter is a capital, then, whether capitalizing or decapitalizing, don't change anything") is just crazy and not at all logical. It's also a spring invention (I can see why they did it, but, still, an invention).

Basically, the bean spec is broken in this regard and lombok and spring have chosen different tactics to solve the discrepancy.

We could try and be more compatible with spring, but then we'd be breaking backwards compatibility. Not to mention we're joining this train into crazytown.

If you can find anything from official oracle spec that shows this silly behaviour is in fact what you are supposed to do we'll re-open this issue. Also, if there are other major tools that work the same way and lombok is really the only exception, that too would be reason to re-open this issue.

lombokissues

lombokissues commented on Jul 14, 2015

@lombokissues
Author

End of migration

rzwitserloot

rzwitserloot commented on Jan 2, 2021

@rzwitserloot
Collaborator

Duplicate of #2693

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @rzwitserloot@lombokissues

        Issue actions

          the setter method got letter case error... · Issue #504 · projectlombok/lombok