Does reflection breaks the idea of private methods, because private methods can be access outside of the class?

前端 未结 14 1067
甜味超标
甜味超标 2020-11-28 08:06

Does reflection break the idea of private methods? Because private methods can be accessed from outside of the class? (Maybe I don\'t understand the meaning of reflection or

14条回答
  •  Happy的楠姐
    2020-11-28 08:57

    It does, as other already stated.

    However, I remember that in Java there can be a security manager active, that could prevent you from accessing any private methods, even with reflection, if you don't have the rights to do so. If you run your local JVM, such a manager is usually not active.

提交回复
热议问题