aspose file tools*
The moose likes Performance and the fly likes What is faster: accessing methods directly or using reflection? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "What is faster: accessing methods directly or using reflection?" Watch "What is faster: accessing methods directly or using reflection?" New topic
Author

What is faster: accessing methods directly or using reflection?

Em Aiy
Ranch Hand

Joined: May 11, 2006
Posts: 226
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?


The difference between <b>failure</b> and <b>success</b> is often being <b>right</b> and being <b>exactly right</b>.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
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

Joined: Oct 29, 2001
Posts: 8968
    
    9

"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


[How To Ask Questions On JavaRanch]
Em Aiy
Ranch Hand

Joined: May 11, 2006
Posts: 226
THanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is faster: accessing methods directly or using reflection?