On this example is presented a way how to call a private method of class A, from another class?
Since on "regular way" we can not use this, is this violating of encapsulation?
On this example is presented a way how to call a private method of class A, from another class?
Since on "regular way" we can not use this, is this violating of encapsulation?
Yes its a violation. And that is one of the reasons why you should carefully use Reflection. For more look here. It can be somewhat controlled by using SecurityManager
Yes, it is, and using reflection is explicitly a means of evading the usual access controls. If it's really important to prevent this, you can install a SecurityManager
that limits reflection.