Java Reflection Performance

前端 未结 14 1625
感动是毒
感动是毒 2020-11-22 08:25

Does creating an object using reflection rather than calling the class constructor result in any significant performance differences?

14条回答
  •  花落未央
    2020-11-22 08:58

    There is some overhead with reflection, but it's a lot smaller on modern VMs than it used to be.

    If you're using reflection to create every simple object in your program then something is wrong. Using it occasionally, when you have good reason, shouldn't be a problem at all.

提交回复
热议问题