Why is reflection slow?

后端 未结 5 1493
灰色年华
灰色年华 2020-12-03 10:09

Is it because we should load class (by string for example), create instance, then search for appropriate method, pack parameters, and then just invoke method? S

5条回答
  •  一向
    一向 (楼主)
    2020-12-03 10:26

    As an addendum to Jon Skeet's answer above (I need more reputation in order to be able to comment.):

    Reflection is dependent on CPU resources being available; if you have problem with your application being slow, reflection won't solve anything, just make it slower.

    Like Java itself, reflection isn't slow any more - it is more of an old rumor ;)

提交回复
热议问题