Improving Reflection Performance
One of the big knocks against Reflection is that it's quite a bit slower than normal field and method access. When you use Reflection as part of your application, there are a few things you can do to speed things up.
First, if you do a lot of method lookups, consider creating a cache of the methods, possibly by some unique name so you don't have to create a description of the method parameters every time. Any time you can avoid creating a new object you'll save time.
Second, consider creating static arrays for some commonly used, read-only object arrays. For instance, when you invoke a get method on an object, you typically pass a zero-length array. You should create a static zero-length object array and use it ...
Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.