@
sinsin 说到首词只有一个字母时,我不得不提一下java bean spec里的一个烂坑
···
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”
···
如果你不巧有一个bean,它有一个field名字叫做uRL, 然后它的getter叫getURL
那么在introspect这个bean时,jdk会认为你有一个property叫做URL,而不是uRL