Java: getter / setter methods

How do getter bean methods get called and set in different frameworks? is it only through reflection?

+5
source share
1 answer

Yes, most frameworks use reflexes for this, with the supposed requirement that you use the correct getter / setter naming convention (getXXX and setXXX, or isXXX and setXXX for a boolean property).

Performance may be a problem, but if you do not evaluate your application and do not think that reflections are the main bottleneck, I would advise you not to prematurely optimize and use reflections as the simplest solution. With that said, you might want to take a look at this article about replacing reflections with code generation:

http://www.ibm.com/developerworks/java/library/j-dyn0610/

+2
source

All Articles