• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is faster: accessing methods directly or using reflection?

 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to know that if i am accessing the methods of a class using Reflection then will it be faster comparatively to accessing methods of that class directly?

I read somewhere, don't remember where that reflection is much faster than accessing things directly. Can any one help me in this regard?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A compiled method call is always going to be MUCH faster than any process using reflection. Just think about the steps involved.
Bill
 
Joe Ess
Bartender
Posts: 9256
9
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Using reflection is basically an interpreted operation, where you tell the JVM what you want to do and it does it for you. This type of operation is always going to be slower than just doing the same operation directly."

Java Programming Dynamics
 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic