• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class Loader performance  RSS feed

 
Shekar Atmakur
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would like to know which is better way of doing things from performance perspective.These are the two options.
1>Use Java Reflection to introspect the methods of a class and invoke corresponding methods or
2>Instantiate the classes at run time using a ClassLoader and invoke the methods on the class.(All classes implement the same interface and hence the same method signature. I use a Factory Pattern here).

I guess all i'm asking is whether a Java Reflection is a memory Hogger or is it the ClassLoader.

Any help is appreciated.

Thanks,
shekar
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For reflection to work with a class, the class must first be loaded anyway.

If you want to call a method of an interface that you know the class supports, then it's definitely better to simply load and use the class.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!